Skip to content

Scripts for beginners.

User Avatar
#207
Auto-translated
Could you tell me what exactly it writes? I'm running a bit short on ideas. Just now, I realized that the player number is passed to the a1 function, but ideally, this shouldn't affect anything. Novik, in his manual, describes how to create hooks; you can use it.
void errorHook( fCallback ) Allows you to set an error handler. By default, when a script error occurs, the current thread terminates. Thanks to this function, you have the opportunity to adjust this behavior – before stopping, control will be passed to the fCallback function. Example: function onError() print("Error occured ") end function SetArtefactUntrans(nArtefactName) errorHook(onError) RemoveArtefact("Berein",nArtefactName) GiveArtefact("Berein",nArtefactName,1) end If an error occurs in the SetArtefactUntrans function (for example, if the hero does not have the required artifact), the string "Error occured " will be displayed in the console. Note that this very informative string will not save you from the thread stopping (nor from displaying diagnostics in the console). The hook will work in all script threads (and not just in the one that called it) until errorHook is called with the parameter nil. I also recommend paying attention to the fact that the hook only works on runtime errors; it does not affect interpretation errors. Regarding the example provided, it is much more reasonable to check the hero for the presence of the required artifact instead of using a hook.
 

К А
Стикеры GBF в Telegram