Community Forum

Is it possible to add an "update functionality" to an object?

Forum Overview >> Scripting

CategoryScripting
Created13.03.2017 23:02


Tim Derks (timmiej93) 13.03.2017 23:04
I know you can add hour/minute (and weather?) -changed listeners to objects by calling "g_currentMission.environment:addHourChangeListener(self)", which then makes the MyMod:hourChanged() function work. Is there a similar thing to make the "MyMod:update(dt)" function work?

Emil Drefers (Unknown) 14.03.2017 07:44
Hi,

yes there is.

g_currentMission:addUpdateable(updateable)

But, the passed element to this function must not be of type class (aslo no inheritance from class object is allowed).

When deleting the elemnt you should call
g_currentMission:removeUpdateable(updateable)

Cheers,
Emil

Tim Derks (timmiej93) 14.03.2017 17:41
Thanks Emil, works like a charm!


Note: Log in to post. Create a new account here.