Needin' some table education & 2 questions
Posted: Thu Mar 14, 2013 7:16 pm
First generic #1
Following script
functions fine, but
get me a global value = nil error. Why?
generic question #2,
I have 4 buttons. I want each one to assign a value to a counter then call the main script.
doesn't call the main script. What is the proper way to call another script?
Now to the main point of the post. (I can easily work around the other items, just trying to learn a little more stuff)
I have for example a 6x7 area (x grid #'s 12,13,14,15,16,17) and (y grid #'s 16,17,18,19,20,21,22)
and I wan the player to maneuver items around in that space. Now it would be simple if all the squares in that area were available, i.e if x>11 and x<18 and y>15 and y<23 then check if space is empty, move item. But not every space is going to be available because of a few fixed items, and a couple of wall spaces (also in the real situation it's not a perfect rectangle either). So my thought is to have a double layered(?) table with all valid x,y coordinates in it, which I think is possible using the dot, but not quite sure. Something like
PosistionTable = {12.16, 12.17, 13.18} etc, etc.
then I could do something like
(push button to move item north)
local TempPosistionX = itemOne.x
local TempPosistionY = itemOne.y - 1
for i in #PosistionTable
(and at this point I am unsure of the proper way to call the table values)
the compare if there is a match,
if yes check if entitiesAt() shows an empty square,
and if empty move item.
Anyone wish to enlighten me on double layered table use?
And as always I appreciate the time taken to respond.
Following script
Code: Select all
function mainScript()
local dragon = 0
if leverone:getLeverState() == "deactivated" then
dragon = 1
else
dragon = 2
end
end
Code: Select all
function mainScript()
if leverone:getLeverState() == "deactivated" then
local dragon = 1
else
local dragon = 2
end
generic question #2,
I have 4 buttons. I want each one to assign a value to a counter then call the main script.
Code: Select all
function setCounterValue()
RG_Counter:setValue(1)
mainScript()
end
Now to the main point of the post. (I can easily work around the other items, just trying to learn a little more stuff)
I have for example a 6x7 area (x grid #'s 12,13,14,15,16,17) and (y grid #'s 16,17,18,19,20,21,22)
and I wan the player to maneuver items around in that space. Now it would be simple if all the squares in that area were available, i.e if x>11 and x<18 and y>15 and y<23 then check if space is empty, move item. But not every space is going to be available because of a few fixed items, and a couple of wall spaces (also in the real situation it's not a perfect rectangle either). So my thought is to have a double layered(?) table with all valid x,y coordinates in it, which I think is possible using the dot, but not quite sure. Something like
PosistionTable = {12.16, 12.17, 13.18} etc, etc.
then I could do something like
(push button to move item north)
local TempPosistionX = itemOne.x
local TempPosistionY = itemOne.y - 1
for i in #PosistionTable
(and at this point I am unsure of the proper way to call the table values)
the compare if there is a match,
if yes check if entitiesAt() shows an empty square,
and if empty move item.
Anyone wish to enlighten me on double layered table use?
And as always I appreciate the time taken to respond.