Auto-translated
Please advise. I have many identical objects on my map, and a hero can buy creatures from them using a script. The object names are: "dw1", "dw2", "dw3", etc. Is it possible to assign the same trigger to all of them, so that the function receives the object number as a parameter, representing the object the hero entered, as a number. Then, I could define the type, quantity, and cost of creatures for each object using an array.
for i=1,15 do
Trigger(OBJECT_TOUCH_TRIGGER,"dw"..i,"dwellingF")
end;
cr_count={10,30,20.....20}
cr_type={92,94,96.....105}
cr_cost={20,40,80.....1000}
function dwellingF(hero, obj_name)
n=<how do I get the object number here?>
AddHeroCreatures(hero,cr_type[n],cr_count[n])
SetPlayerResource(1,GOLD,GetPlayerResource(1,GOLD)-cr_count[n]*cr_cost[n]);
end;
Создается карта про эльфов: Воссоединение - готовность 71%