On tick call method in another file
Posted: Sat Nov 07, 2015 8:46 am
Let's say I want to have a entity with a long onUpdate function to be called every x ticks.
Could I have that method in a seperate file (ex: EntityMobFile.lua) such that all code related to this entity is eaisly found there and not inside a miles long control.lua?
I assume there must be a simple way to get some organization and sepperation when creating a mod with several entities
psudo code to illustrate my thinking:
int y = 0
game.onevent(defines.events.ontick, function(event)
{
y++
if (x %y )
{
EntityMobFile.onUpdate(someData)
}
}
Could I have that method in a seperate file (ex: EntityMobFile.lua) such that all code related to this entity is eaisly found there and not inside a miles long control.lua?
I assume there must be a simple way to get some organization and sepperation when creating a mod with several entities
psudo code to illustrate my thinking:
int y = 0
game.onevent(defines.events.ontick, function(event)
{
y++
if (x %y )
{
EntityMobFile.onUpdate(someData)
}
}