hello again
i have two help needs in one question:
how can i "use" global tables?
i'm defining an object and i want to have many on them on the map but i want the player can use it only one time each object. than i tried with a table, but i can't find a way to use as global table. i did this:
Code: Select all
local mytable = {}
defineObject{
name = "myobject",
baseObject = "base_mybase",
components = {
bla bla bla...
{
class = "Clickable",
offset = vec(0, 1, -3),
size = vec(5, 5, 0),
maxDistance = 2,
frontFacing = false,
--debugDraw = true,
onClick = function(self)
local allow = true
for _, v in ipairs(mytable) do
if v == self.go.id then
allow = false
break
else
allow = true
end
end
if allow == true then
table.insert(mytable,self.go.id)
playSound("secret")
party.party:shakeCamera(0.02,2)
hudPrint("hurray")
end
end
end,
},
it works good, but of corse, "local" is not global. so if i use all of them than i save the game and than i load the game and i use them again they still works. but they shouldn't.
so. how can i solve this problem? maybe with a "disableself" component!?
second question is:
how can i do the same thing but insted using myobject only one time, i want to use it once in a day?
so after 24 hours (game timing) i can use it again.
i hope i've been clear