Stellow
C++/C#/PHP/LUA
If you like to store data while executing an event, you may store these data inside a global table which can or most likely will not make it available for different branches of scripting (creature scripts/movements/actions...).
The best way that I have found to accomplish this is to create a metatable and store it on the database.
Follows the template:
Now if you want to trigger some function you can for example
The best way that I have found to accomplish this is to create a metatable and store it on the database.
Follows the template:
Code:
Event = {}
Event.__index = Event
Event.Config = {
-- config variables/tables/arrays/objects
}
function Event.new(id, morevariables)
local event =
{
id = id,
morevariables = morevariables or default value,
}
setmetatable(event, Event)
return event
end
function Event.get(id)
local tmp = table.unserialize(Game.getStorageValue(id))
return Event.new(tmp.id, tmp.morevariables)
end
function Event:save()
Game.setStorageValue(self.id, table.serialize({
id = self.id,
morevariables = morevariables,
}))
end
function Event:changeState(foo)
self.morevariables = foo
end
Now if you want to trigger some function you can for example
Code:
function onKill(creature, target)
local event = Event.get(storageid)
event:changeState("i dont know")
event:save()
end