- Joined
- Nov 17, 2010
- Messages
- 6,795
- Solutions
- 581
- Reaction score
- 5,359
I use 0.3.7, but TFS version doesn't really matter for this.
Let's say I want to register a table for each creature that touches a specific tile, but only from server save to server save.
If creature touches x tile, run movement script and register as true in global table for only that creature.
At the same time, register + 1 to how many times that cid has stepped on the tile.
So, basically once there's 3 people who have touched the tile, it would look like this or this..
Okay.. after writing it I realise #1 makes more sense, as you can just assume that it's true, unless you want it to change from true/false, which then makes #2 make more sense.
In either case, I want to do method #2, but not really sure how.
-- My thinking is we create the table like this..?
-- after this we can just alter the newly-existing table.. like this? (I'm just guessing.. cuz I'm not home to randomly try stuff. Dx)
Can someone guide me in the right direction?
Let's say I want to register a table for each creature that touches a specific tile, but only from server save to server save.
If creature touches x tile, run movement script and register as true in global table for only that creature.
At the same time, register + 1 to how many times that cid has stepped on the tile.
So, basically once there's 3 people who have touched the tile, it would look like this or this..
Code:
--(1)
table_x = {
[111111111] = {1}, -- hit 1 time
[222222222] = {8}, -- hit 8 times
[333333333] = {3}, -- hit 3 times
}
--(2)
table_x = {
[111111111] = {true, 1}, -- hit 1 time
[222222222] = {true, 8}, -- hit 8 times
[333333333] = {true, 3}, -- hit 3 times
}
Okay.. after writing it I realise #1 makes more sense, as you can just assume that it's true, unless you want it to change from true/false, which then makes #2 make more sense.
In either case, I want to do method #2, but not really sure how.
-- My thinking is we create the table like this..?
Code:
if not table_x[cid] then
table.insert[table_x, cid]
table.insert[table_x[cid], true]
table.insert[table_x[cid], 1]
true
end
-- after this we can just alter the newly-existing table.. like this? (I'm just guessing.. cuz I'm not home to randomly try stuff. Dx)
Code:
if table_x[cid][1] == true then
table_x[cid][1] = false
else
table_x[cid][1] = true
end
if table_x[cid][2] == 9 then
table_x[cid][2] = 0
else
table_x[cid][2] = table_x[cid][2] + 1
end
Can someone guide me in the right direction?