Ancores
Active Member
- Joined
- Jan 17, 2010
- Messages
- 538
- Reaction score
- 28
Long time ago I released something, so here's a rail system for TFS 1.0.
Set action id on an ore wagon depending on direction:
actions.xml
actions/scripts/cart.lua
Set action id on an ore wagon depending on direction:
Code:
North - 3013
East - 3014
South - 3015
West - 3016
actions.xml
Code:
<action actionid="3013" script="cart.lua"/>
<action actionid="3014" script="cart.lua"/>
<action actionid="3015" script="cart.lua"/>
<action actionid="3016" script="cart.lua"/>
actions/scripts/cart.lua
Code:
local directions = {
[3013] = 0, -- North
[3014] = 1, -- East
[3015] = 2, -- South
[3016] = 3, -- West
}
local railIds = {7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130}
local rails = {
[7121] = {[0] = 0, [2] = 2},
[7122] = {[1] = 1, [3] = 3},
[7123] = {[0] = 1, [3] = 2},
[7124] = {[1] = 2, [0] = 3},
[7125] = {[3] = 0, [2] = 1},
[7126] = {[1] = 0, [2] = 3},
[7127] = {[0] = 0, [2] = 3, [1] = 0},
[7128] = {[1] = 2, [3] = 3, [0] = 3},
[7129] = {[1] = 0, [3] = 3, [2] = 3},
[7130] = {[0] = 0, [2] = 1, [3] = 0}
}
local speed = 125
local allowWalk = false
local function drive(cid, dir)
if(isPlayer(cid)) then
local player = Player(cid)
local pos = player:getPosition()
local nextPos = (dir == 0 and pos + {y = -1} or
dir == 1 and pos + {x = 1} or
dir == 2 and pos + {y = 1} or
dir == 3 and pos + {x = -1})
for i = 1, #railIds do
if(getTileItemById(nextPos, railIds[i]).uid > 0) then
doMoveCreature(cid, dir)
doSetItemOutfit(cid, dir == 0 and 7132 or dir == 2 and 7132 or 7131, -1)
Position(pos):sendMagicEffect(CONST_ME_POFF)
addEvent(drive, speed, cid, rails[railIds[i]][dir])
break
else
player:removeCondition(CONDITION_OUTFIT)
mayNotMove(cid, false)
end
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
if(not player:getCondition(CONDITION_OUTFIT)) then
player:teleportTo(toPosition, true)
mayNotMove(cid, not allowWalk)
addEvent(drive, speed, cid, directions[item.actionid])
end
return true
end
Last edited: