How can I make persistent changes with triggers?

Question

I've made a box that fires of a lua script when a hero enters or leaves it. The problem is that function calls made that way behave like they are instanced, so that all changes I make within my script get discarded as soon as the call ends. Any ideas how change that?

Posted Aug 11, 2014, 5:44 AM UTC

22
Sma11P1ays•

I had this issue for 2 days and I'm not exactly sure how I fixed it. I ended up re-formatting all my code to run the way it does in the nian example at yrrep.me/dota. I guess one of those functions fixed it.

1
ArthurAutomatonPeon•

You could try saving your data on the addon object: Normally you'll have something like this in the Activate function in addon_game_mode.lua:

GameRules.AddonTemplate = CAddonTemplateGameMode()

This creates an instance of the CAddonTemplateGameMode class and then stores a reference to it in the AddonTemplate field. Your triggered code could do something like this:

	GameRules.AddonTemplate.foo = "Some data I want to save"
1