Posted: Mon May 30, 2016 4:53 am Post subject: Uncertain why one timer script works while a second doesn't.
I found two examples on the forums:
The first works fine:
Code:
cShip=0
lShip=0
timer = createTimer(nil,true)
timer_setInterval(timer,3000)
function CheckShip()
cShip=getAddress("myShip") --myShip is a registered symbol
Print(cShip)
lShip=cShip
end
timer_onTimer(timer,CheckShip)
The Second just errors out on line 1:
Code:
LastShip = 0
CurrShip = 0
address = 0
function CheckShipStatus(t)
CurrShip = d2h(readInteger(getAddress("myShip")))
print("Current Ship: " .. CurrShip .. " & Last Ship: " .. LastShip)
if (CurrShip ~= LastShip) and (CurrShip ~= 0) then
address = d2h(readInteger([CurrShip +40]))
print("First Pointer: " .. address)
LastShip = CurrShip
end
end
function ActivateTimer()
t=createTimer(nil)
t.OnTimer=CheckShipStatus
t.Interval=3000
t.Enabled=true
end
I have the appropriate enable/disable scripts for both to turn the timers on and off.
Why is the second code not working? The error is unexpected string '[' in line 1 which does not exist! I tried deleting everything but the function calls, but the error message applies to every line in the code.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum