Skip to content
#4033
Auto-translated
Dogenator
Regarding point 2, I didn't quite understand what you mean by "function_1" and "function_2"... Are these the names of the functions themselves? Or are they functions similar to function first_day, but for checking other days?
These are just function names, for example. Let's say you want to create two events for one trigger:
function first_day ()
...
end;
Trigger(NEW_DAY_TRIGGER, 'first_day' );

function Spawn_army()
....
end;
Trigger(NEW_DAY_TRIGGER, 'Spawn_army' );

The second trigger will overwrite the first, and it won't work. An equivalent of this structure:

function NewDayTrigger()
first_day();
Spawn_army();
end
Trigger(NEW_DAY_TRIGGER, 'NewDayTrigger' );

That is, to execute a function, you don't necessarily need Triggers, startThread's, etc.; you just write the function name and parentheses. Anywhere, in any quantity. Your functions are no different from built-in functions, like print().

If something doesn't work, you need to debug it step by step. Probably, everyone has encountered a situation where they added a lot of code, made a syntax error in it, for example, wrote pint() instead of print(), and it's almost unnoticeable. The game engine simply executes the map script line by line - it reaches an incorrect function name, doesn't understand what it is, and crashes. That's it, the script is no longer executed. You don't understand what's wrong, and you start trying to write some other code, but it doesn't work either. You can rack your brains thinking about what you're doing wrong, but in reality, the script execution didn't even reach your new code; it crashed earlier. Therefore, it is very important to put print statements everywhere to understand which section of the code was executed and which was not. I guarantee that if you copy a specific piece of code from the FAQ and paste it into the map (and don't make mistakes in the names of objects and files), it will definitely work.

Statistics

Welcome our newest member: Emil

Users Online 3 users 1400 guests