ShiVa3D
checking to see if a variable has changed
All about the StoneScriptchecking to see if a variable has changed
by Osbor » 08 Feb 2012, 22:49
sorry to be asking so many questions, but the documentation for shiva is still very sparse, and the wiki quite empty.
is there any way to do an efficient check to see if an object or a variable or whatever has updated? something with signals would be great. at the moment i have a system which checks the hour of the day every frame, when it only needs to know the hour when the hour actually changes (one frame every hour is a lot less overhead than 30 a second)
is there any way to do an efficient check to see if an object or a variable or whatever has updated? something with signals would be great. at the moment i have a system which checks the hour of the day every frame, when it only needs to know the hour when the hour actually changes (one frame every hour is a lot less overhead than 30 a second)
- Osbor
- Junior Boarder

- Posts: 39
Re: checking to see if a variable has changed
by neilb » 09 Feb 2012, 12:35
There's nothing that does it automatically, but you could use a HUD timer to send a message to your AI to do the hour check once every 30 seconds or however long you want to make the interval.
Re: checking to see if a variable has changed
by NiCoX » 09 Feb 2012, 13:57
Yes, or using something like:
- Code: Select all
function MyAI.onCheckChanges ( )
-- Actual job
--
if ( ... )
then
...
end
-- re-check 30sec later
--
this.postEvent ( 30, "onCheckChanges" )
end
-

NiCoX - Platinum Boarder

- Posts: 5626
- Location: France
Re: checking to see if a variable has changed
by Osbor » 09 Feb 2012, 23:18
NiCoX wrote:Yes, or using something like:
- Code: Select all
function MyAI.onCheckChanges ( )
-- Actual job
--
if ( ... )
then
...
end
-- re-check 30sec later
--
this.postEvent ( 30, "onCheckChanges" )
end
oh man, i totally forgot about postEvent! that would work perfectly, since event sends are very little overhead. i could even set the actual clock function to only update the hour every, well, hour (and on initialization of course)
- Osbor
- Junior Boarder

- Posts: 39
4 posts
• Page 1 of 1