![]() |
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: You may be thinking "Wtf?", but here's how it works. NPC Code: 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: 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 |
this.on=(this.on+1)%2 - shorter
|
Quote:
|
Jagen, you do realise that it is unnecesary to run it through such a math equation don't you?
If it is on and off you could just as well do this.on = abs(1-this.on*2); |
... =(
|
thats a good thing to keep in mind tho Wind... Its something we do In C++ a lot. you could potentially do anything a normal ifelse can do (for setting a varaible atleast), and shorten it to 1 line. its good for compacting things.
this.var = (this.var > 3? 2 : this.var<2 1 : 0); and what not. Although you can also try doing just this.var = (condition); such as this.var = (strequals(#n,Falados)); it would be true if your name was falados, and false if it isn't. You could potentially do it for on/off variable aswell. this.on = (this.on==0); Im not sure graal will necesarily accept that. however it will probably accept this.. this.on=(strequals(0,#v(this.on))); |
Wind, not Cyn. Wind. =P
Cyn is letting me use his forums account, and his player soon. Cyn are no like Grawl nomores. =( |
I will make that change then :)
|
| All times are GMT +2. The time now is 08:37 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.