View Single Post
  #24  
Old 01-22-2005, 11:29 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Aethorpe
There was no reason given why this was wrong, and if I want to it execute immediately and regardless of everything else, then why bother?
There is no "immediately". Scripts are processed in response to events. If the code is outside of an event block, it will be executed every time an event is triggered. So:
  1. Putting it in an event block makes the code clearer. It unequivocally states what the script is meant to do, instead of letting its execution depend on external factors. This means that:
    1. The code is futureproof - modifications to Graal's behaviour will not likely break it, and it conforms roughly to GS2's event model.
    2. Other scripters will know what you're doing, and be able to tell that you're not simply misunderstanding the nature of GScript.
  2. Assuming your NPC doesn't just do one thing and then destroy itself, you don't want its code to be executed randomly in response to external events. At best, it's just wasteful. At worst it's destructive.
__________________
Reply With Quote