Zyntax
*WannaBe Scripter*
I just found a very old script of mine which I used back in like one thousand years ago and I thought it's still funny, so why not share it?
Tested on TFS 0.3.6pl1
What's it doing?
This:
Instructions
Draw some tiles with the ID 100 (black/red ground), big enough to ensure your car doesn't travel into walls.
You'll see how large it has to be when you look at the script further down.
Create a lever and set it's actionID / unuiqeID like that:
data/actions/actions.xml
I took an uniqueID, dunno why but I did it back then
Next, create a new file called "tilecar.lua" at
data/actions/scripts
Copy this code
Well, that's basically it.
Try it out, have fun
Tested on TFS 0.3.6pl1
What's it doing?
This:
Instructions
Draw some tiles with the ID 100 (black/red ground), big enough to ensure your car doesn't travel into walls.
You'll see how large it has to be when you look at the script further down.
Create a lever and set it's actionID / unuiqeID like that:
data/actions/actions.xml
PHP:
<action uniqueid="9005" event="script" value="tilecar.lua"/>
Next, create a new file called "tilecar.lua" at
data/actions/scripts
Copy this code
Code:
-----------------------------------
-------<<< TileCar-Script >>>------
-----<<< created by Zyntax >>>-----
-----------------------------------
local start = {x=389, y=314, z=8} --STARTING Position (right of the lever like in the video, where my char is standing)
local ground = 100 --ItemID you're using as NONWALKABLE ground
local car = 9146 --ItemID of your tiles you create to walk on
local speed = 500 --Every 0.5 seconds a tile will be created, thats just about right
--- 0 = create tile NORTH
--- 1 = create tile WEST
-- -1 = create tile EAST
--- 2 = create tile SOUTH
--EXPLAINING:
-- This path is determined already, so we know where the tiles will be created.
-- You can always change the directions to your needs, just follow the explanation
--local d = {up,up,up,left,left,left,up,up,up,up,right,right,right,right,down,down,down,right,right,up,up,up,up,up,left,left,left,up}
local d = {0,0,0,1,1,1,0,0,0,0,-1,-1,-1,-1,2,2,2,-1,-1,0,0,0,0,0,1,1,1,0}
-- Caution! If you don't know what you're doing leave those lines alone!
local count = 1
local U = 0
local S = 0
local position = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1946 then
doPlayerSendCancel(cid, 'Sorry you have to wait for the reset.')
else
doTransformItem(item.uid, 1946)
addEvent(go, speed, count, start, cid, U, S)
end
return true
end
function go(count, start, cid, U, S)
if d[count] == 0 then
U = U-1
elseif d[count] == 1 then
S = S-1
elseif d[count] == -1 then
S = S+1
elseif d[count] == 2 then
U = U+1
elseif count == (#d+3) then
doTransformItem(getThingFromPos({x=start.x-1, y=start.y, z=start.z, stackpos=1}).uid, 1945)
return true
end
table.insert (position, {x=start.x+S, y=start.y+U, z=start.z})
if count <= 2 then
doCreateItem(car, position[count])
elseif count > 2 and count <= (#d) then
doCreateItem(car, position[count])
doCreateItem(ground, position[count-2])
doSendMagicEffect(position[count-2], 2)
teleport(cid, start, count)
elseif count > (#d) and count <= (#d+2) then
doCreateItem(ground, position[count-2])
doSendMagicEffect(position[count-2], 2)
teleport(cid, start, count)
end
addEvent(go, speed, count+1, start, cid, U, S)
end
function teleport(cid, start, count)
local pos = {x=position[count-2].x, y=position[count-2].y, z=position[count-2].z, stackpos=255}
if isPlayer(getThingFromPos(pos).uid) == TRUE then
doTeleportThing(cid, start)
doSendMagicEffect(start, 10)
doPlayerSay(cid, 'Damn! I\'m too slow!', 19)
end
end
Well, that's basically it.
Try it out, have fun