This system is not created by me, the credits go to the creator.
Instruction:
~~Controls~~
Movement Train.lua
Talkaction Train.lua
Have Fun!
Instruction:
- put Talkaction Train.lua inisde talkactions/scripts
- put Movement Train.lua inside movements.scripts
- in talkactions.xml add
Code:<talkaction words="train" script="Talkaction Train.lua" />
- in movements.xml add
Code:<movevent event="StepIn" itemid="7131" script="Movement Train.lua" /> <movevent event="StepIn" itemid="7132" script="Movement Train.lua" />
~~Controls~~
- train "left change your direction to the west.
- train "right change your direction to the east.
- train "up change your direction to the north.
- train "down change your direction to the south.
Movement Train.lua
Code:
local storage = 242526
local interval = 500
local function movetrain(p)
p.pos.stackpos = 2
doCreateItem(p.t,1,p.new)
doTeleportThing(p.cid, p.new, FALSE)
doRemoveItem(getThingfromPos(p.pos).uid)
end
function onStepIn(cid, item, pos)
local Rails = {
[7122]={
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2}
},
[7121]={
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[4]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7123]={
[3]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[1]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7124]={
[3]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7131, ns=4}
},
[7125]={
[4]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[1]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7126]={
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7127]={
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7128]={
[3]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7130]={
[4]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[1]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7129]={
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1}
}
}
if isPlayer(cid) == 1 then
pos.stackpos = 1
local Rail = getThingfromPos(pos)
local Move = Rails[Rail.itemid]
if Move then
local Direction = Move[getPlayerStorageValue(cid,storage)]
if Direction then
setPlayerStorageValue(cid, storage, Direction.ns)
doSetItemOutfit(cid, Direction.t, 600)
addEvent(movetrain, interval, {cid=cid, new=Direction.n, t=Direction.t, pos=pos})
end
end
end
return TRUE
end
Talkaction Train.lua
Code:
local storage = 242526
local directions = {
["up"] = {new = 3, name = "Up"},
["down"] = {new = 4, name = "Down"},
["left"] = {new = 1, name = "Left"},
["right"] = {new = 2, name = "Right"},
["stop"] = {new = 0, name = "Stop"}
}
function onSay(cid, words, param)
local ndir = directions[param]
if (ndir ~= nil) then
setPlayerStorageValue(cid, storage, ndir.new)
doCreatureSay(cid, ndir.name, TALKTYPE_SAY)
doPlayerSendTextMessage(cid,22,"New Direction Set, your new direction is " .. ndir.name .. ".")
else
doSendMagicEffect(getPlayerPosition(cid), 2)
doPlayerSendCancel(cid, "Invalid dirextion.")
end
end
Have Fun!