In this example, 4 walls will be removed with 2 seconds between them. (gives a nice visual effect)
Let's play with a lever and put it the UID 9999:
data \ actions \ actions.xml
in data\actions\scripts\MagicWall.lua
How it works?
1 - pausa = 2000 (2 secs)
When we call an event, this parameter tells you what the waiting time until the event started running. (in our case 2 secs)
After those 2 secs, the event begins.
2 - addEvent (wait1, pause, wall1pos)
This is how you call an event
WAIT1 is the name of the event
PAUSE pause is explained above
WALL1POS is the variable that will be taken to the event.
WAIT1 the event is called (with waiting 2 secs) and takes the parameter WALL1POS (with the coordinates of the wall)
3 - function wait1 (wall1pos)
This is the event.
thing = getThingfromPos (wall1pos)
Here we take the "thing" that is in WALL1POS (in our case a wall)
I said "thing" because "getThingfromPos" means exactly "catch something of pos"
doRemoveItem remove that wall
and the next line calls the next event with the same pause for 2 secs.
4 - is going well (event calling event) until the last
only removes the wall and do not call no more events
I tried to explain the best way possible.
The other instructions in this tutorial are common and I will not explain.
(eg doTransformItem)
All credits to Conde Sapo
ty, comments...
Let's play with a lever and put it the UID 9999:
data \ actions \ actions.xml
Code:
<action uniqueid="9999" script="MagicWall.lua" />
in data\actions\scripts\MagicWall.lua
Code:
-- Removing walls with time (By Conde Sapo)
function onUse(cid, item, pos)
pausa = 2000 -- 2 sec.
-- wall positions - don't change stackpos.
wall0pos = {x=48, y=38, z=7, stackpos=1}
wall1pos = {x=50, y=38, z=7, stackpos=1}
wall2pos = {x=52, y=38, z=7, stackpos=1}
wall3pos = {x=54, y=38, z=7, stackpos=1}
if item.itemid == 1945 then
doTransformItem(item.uid,1946)
wall0 = getThingfromPos(wall0pos)
if wall0.itemid ~= 0 then
doRemoveItem(wall0.uid,1)
addEvent(wait1,pausa,wall1pos)
end
else
doTransformItem(item.uid,1945)
end
return 1
end
function wait1(wall1pos)
thing = getThingfromPos(wall1pos)
doRemoveItem(thing.uid,1)
addEvent(wait2,pausa,wall2pos)
end
function wait2(wall2pos)
thing = getThingfromPos(wall2pos)
doRemoveItem(thing.uid,1)
addEvent(wait3,pausa,wall3pos)
end
function wait3(wall3pos)
thing = getThingfromPos(wall3pos)
doRemoveItem(thing.uid,1)
-- if you want more walls , only keep adding addEvent's
end
How it works?
1 - pausa = 2000 (2 secs)
When we call an event, this parameter tells you what the waiting time until the event started running. (in our case 2 secs)
After those 2 secs, the event begins.
2 - addEvent (wait1, pause, wall1pos)
This is how you call an event
WAIT1 is the name of the event
PAUSE pause is explained above
WALL1POS is the variable that will be taken to the event.
WAIT1 the event is called (with waiting 2 secs) and takes the parameter WALL1POS (with the coordinates of the wall)
3 - function wait1 (wall1pos)
This is the event.
thing = getThingfromPos (wall1pos)
Here we take the "thing" that is in WALL1POS (in our case a wall)
I said "thing" because "getThingfromPos" means exactly "catch something of pos"
doRemoveItem remove that wall
and the next line calls the next event with the same pause for 2 secs.
4 - is going well (event calling event) until the last
only removes the wall and do not call no more events
I tried to explain the best way possible.
The other instructions in this tutorial are common and I will not explain.
(eg doTransformItem)
All credits to Conde Sapo
ty, comments...
Last edited: