Skip to content
#3393
Auto-translated
Esteemed comrades,

I would like to ask you to share your thoughts.
function BindTriggerToObject(object, handler)
Trigger(OBJECT_TOUCH_TRIGGER, object, handler)
end

RPGEngine.Init = function()
for i, player in players do
for j, object in player.RPG.BUILDINGS do
local handler = 'EnterBuilding('..player.key..", "..'"'..object.key..'")'
BindTriggerToObject(object.name, handler)
end
end
end

 

player is a table that needs to be passed as a parameter to the handler. The handler for the object_touch trigger is currently passed as a string (as in the example).

That is, for certain global tables, a field is added with a string containing the exact name of the table, and it is then substituted into the handler (i.e., for the table player1 = {key='player1'}).

However, there are quite a few smaller tables, and writing a key for each one is quite tedious. Wrapping the handler in an anonymous function is pointless - closures are not supported here, and a local function does not have access to the external environment.

If anyone understands this, please let me know.

eugnazaroff
создание скриптов к HOMM V

Statistics

Welcome our newest member: artem

Users Online 1 users 1513 guests