Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-07-2002, 06:02 AM
Graal518 Graal518 is offline
Foolish Dreamer
Graal518's Avatar
Join Date: Dec 2001
Location: Montana
Posts: 2,140
Graal518 is on a distinguished road
Scripting Lesson: ?

?
This is a very useful little... thing. Kaimetsu taught me how to use it, and it comes in handy for things like switches, or turning on NPCs by firing it. Here is an example of how to use it.
NPC Code:

if (weaponfired) this.on = this.on==0?1:0;


You may be thinking "Wtf?", but here's how it works.
NPC Code:

if (weaponfired) this.on = this.on==0?1:0;


This section is basically like a flag checker. If this is true, it will do what's in front of the colon. If it's false, it will do what's behind it. The main purpose of this tool thingie is to shorten script.

You could do this without the ?, although it would be a bit longer
NPC Code:

if (weaponfired){
if (this.on==0){
this.on=1;
}else this.on=0;
}


Or... something. o.O!
Now back to the ? part.
Lets say you fire the weapon, and this.on equals 1. The flag checker thingie part will read this.on==0 as false, and do what's behind the colon, which is a 0. This.on will be set to 0. Got it? You'd better, cause i'm tired of typing.


-Wind Seablaze
__________________


Can there be a guiding light I've yet to see? I know my heart should guide me, but...
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:38 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.