Skip to content

Scripts for beginners.

User Avatar
#184
Auto-translated
The whole problem was that the QuestionBox team refers to a new function where the "dwell" value from the "capt_alt_dw" function is lost, so the game cannot determine which dwelling to rebuild at that moment. I have temporarily solved this by comparing the location of objects, but maybe there is a more adequate and simpler way to do this?
You are creating difficulties out of thin air. You save the coordinates in global variables, and then access them in the add_alt_dw() function. You could just as easily save the object's name in a global variable and then use it immediately:
function capt_alt_dw (prevowner, newowner, hero, dwell )
alt_dw_dwell = dwell;
QuestionBox("text with a question blah blah blah", "add_alt_dw", nil);
end;

function add_alt_dw ()
ReplaceDwelling(alt_dw_dwell, TOWN_ACADEMY, 991 );
end;
Also, I would advise using more complex names for functions and global variables if you want to embed them in any map. The more complex, the greater the chance that they will not conflict with anything.
in general, do all these scripts significantly load the game?
Don't worry about it. In my map, the trigger for a new day probably processed about a thousand lines of code each turn, and it was barely noticeable. Only working with objects on the map takes a long time - deleting an object, placing a new one, changing the number of creatures - subjectively, each such operation causes the game to lag for about half a second.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо