X
Xikini
Guest
The Forgotten Server, version 0.3.7_SVN (Crying Damson)
Alright, I'm terrible with loops, but I'm still trying to use them.
The entire script I'm trying to create will be, oh so much easier, if loops are involved.
The loop/function/action I'm trying to create is for all the lever's to be randomized, when a 'master lever' is used.
Before they are randomized, I also need to check the current state of the levers. Currently attempting to patch in..
But of course if someone knows a better way, please show. 
For reference, this is the test area I'm using for the script.
The error I'm getting in the initial script is
This is the current loop (dare I say the word?!).
It's most likely hideous, but I'm trying.
And for clarity, this is my actions.xml
Alright, If you have any questions feel free to ask.
I've been trying for awhile, and will still be trying for awhile, but figured after a few hours it was time to get support.
Xikini
Alright, I'm terrible with loops, but I'm still trying to use them.
The entire script I'm trying to create will be, oh so much easier, if loops are involved.
The loop/function/action I'm trying to create is for all the lever's to be randomized, when a 'master lever' is used.
Before they are randomized, I also need to check the current state of the levers. Currently attempting to patch in..
Code:
if getTileItemById(pos[1], config.item).uid == 1945 then
if getTileItemById(pos[2], config.item).uid == 1945 then
if getTileItemById(pos[3], config.item).uid == 1946 then
if getTileItemById(pos[4], config.item).uid == 1946 then
doCleanTile(wall[1],false)
end
end
end
end
For reference, this is the test area I'm using for the script.
The error I'm getting in the initial script is
Code:
[7:21:40.007] [Error - Action Interface]
[7:21:40.007] data/actions/scripts/aaCarlExampleScripts/random switch.lua:onUse
[7:21:40.007] Description:
[7:21:40.008] ...tions/scripts/aaCarlExampleScripts/random switch.lua:21: 'for' limit must be a number
[7:21:40.008] stack traceback:
[7:21:40.008] ...tions/scripts/aaCarlExampleScripts/random switch.lua:21: in function <...tions/scripts/aaCarlExampleScripts/random switch.lua:20>
It's most likely hideous, but I'm trying.
Code:
local leverPos = {
[1] = {x = 1562, y = 1497, z = 8}, -- top left
[2] = {x = 1563, y = 1497, z = 8},
[3] = {x = 1565, y = 1497, z = 8},
[4] = {x = 1566, y = 1497, z = 8}, -- top right
[5] = {x = 1562, y = 1498, z = 8}, -- top middle left
[6] = {x = 1563, y = 1498, z = 8},
[7] = {x = 1565, y = 1498, z = 8},
[8] = {x = 1566, y = 1498, z = 8}, -- top middle right
[9] = {x = 1562, y = 1500, z = 8}, -- bottom middle left
[10] = {x = 1563, y = 1500, z = 8},
[11] = {x = 1565, y = 1500, z = 8},
[12] = {x = 1566, y = 1500, z = 8}, -- bottom middle right
[13] = {x = 1562, y = 1501, z = 8}, -- bottom left
[14] = {x = 1563, y = 1501, z = 8},
[15] = {x = 1565, y = 1501, z = 8},
[16] = {x = 1566, y = 1501, z = 8} -- bottom right
}
function onUse(cid, item, frompos, item2, topos)
for i = 1, leverPos do
local check = getTileItemById(leverPos[i]).uid
if(math.random(1,2) <= 1) then
doTransformItem(check.uid, 1946)
else
doTransformItem(check.uid, 1945)
end
end
return true
end
Code:
<action actionid="45152" event="script" value="aaCarlExampleScripts/random switch.lua"/>
I've been trying for awhile, and will still be trying for awhile, but figured after a few hours it was time to get support.
Xikini
Last edited by a moderator: