GS1 booleans


#1

If someone has the time, could you possibly show me an example of a simple script containing booleans?
I’m currently learning it in Python, and would like to be able to apply it in gs, more specifically with the stats&battle system I’m trying to build.
An example would be: If HP is less than 1, Player is Dead - Cannot act on turn. If HP is greater than 0, Player is Alive - Can act on turn.
The example doesn’t have to be something so specific, I’m just trying to understand how to create conditional branches using numbers in gs
(excuse my retardedness :P)


#2

it’s been a long long long time since i messed with gs1 (> 10 yrs?). this is completely from memory.

[CODE]if (created) {
this.playerhealth = 3;
timeout = 0.05;
}

if (timeout) {
if (strtofloat(#v(this.playerhealth)) > 0) {
// alive??
}

timeout = 0.05;
}[/CODE]

something like that anyway, hopefully i was of some help.


#3

Thanks, this is a big help. I’ve been dissecting scripts to learn how to execute various commands. (Constantly referring to commands.rtf)
I’ve been having trouble finding examples for scripts I’m trying to make though, so I’m trying to start from scratch and learn some basic functions that I need to create complex scripts.
I understand how trigger actions and conditional branches work, I’ve just been having trouble translating it in gs.
(I wish I had your memory xD)


#4

I’m pretty sure Joey just converted a number to a string, then back to a number again. You could directly do “this.playerhealth > 0”. Anything inside of a conditional statement will be coerced into a boolean value. So you could even do “if (playerhealth)”, which would execute the “true” code if playerhealth was non-zero.


#5

i initially had it use setstring to set the variable (only way to set a player flag i think?) but yeah it’s been a very long time since i’ve done any graal scripts.


#6

I’ll try both ways out. There’s a few skills and items that depend on playerhealth > 0, as well as being considered “alive”. I mainly needed this example to use for other conditions aside from health as well.
I’m making pre-made npc’s that I can quickly alter to fit what I need to make production a little faster.


#7

No need to try both ways out in this circumstance. In this example, Codr’s way is best since Joey’s way is redundant.


#8

Was there not flags for that stuff already? if (playerisdead) or something. Bah, to lazy to check :smiley:


#9

Yes there are but they won’t work in this situation.