Hi!
I have this script. It gets messages from another script, which processes input. When it receives the message, the property self.number[9] is set to “true” (and it prints as that). But, it only prints like that for one update cycle. Then it prints as “why” twice (the original value as set in init). Then it prints as “true” again.
I have checked and there is no where else that could set self.number[9] to “why”.
Can anyone help? What mistake have I made?
go.property("stage", 0) -- goes from 0 to 1000 where 1000 is finished.
go.property("animdone", false) --checks if all animation is finished.
go.property("animtimer", 100)-- ignore this.
--there is no self.state, it is controlled by animdone.
local function animdone(self, url, property)
self.animtimer = 100
self.animdone = true
end
function init(self)
math.randomseed(os.clock()*os.clock()*os.clock()*1212121)
local random = math.random(1,1000)
local random = math.random(1,1000)
local random = math.random(1,1000)
local random = math.random(1,1000)
local random = math.random(1,1000)
local random = math.random(1,1000)
self.randomtable = {math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9),math.random(0,9)}
self.number= {false,false,false,false,false,false,false,false,"why"}-- controltables
self.arrow= {false,false,false,false}-- controltables
self.letter= {false,false,false,false,false,false}-- controltables
self.enter= {false}-- controltables
end
function update(self, dt)
pprint(self.number[9])
if self.animdone then
if self.stage == 1 then
elseif self.stage == 2 then
elseif self.stage == 3 then
elseif self.stage == 4 then
elseif self.stage == 5 then
elseif self.stage == 6 then
elseif self.stage == 7 then
elseif self.stage == 8 then
elseif self.stage == 9 then
elseif self.stage == 10 then
end
end
end
--message[1] = number/letter/arrow/enter
--message[2] = true/false
--message[3] = value (1-9) or 99 for enter.
function on_message(self, message_id, message, sender)
if message_id == hash("inputtedvalue") then
pprint(message)
if message[1] == "number" then
self.number[message[3]] = message[2]
elseif message[1] == "letter" then
self.letter[message[3]] = message[2]
elseif message[1] == "arrow" then
self.arrow[message[3]] = message[2]
elseif message[1] == "enter" then
self.enter[message[3]] = message[2]
end
end
if message_id == hash("activate") then
self.stage = 1
go.animate("#", "animtimer", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_LINEAR, 5, 0, animdone)
end
end