![]() |
Bool detection
PHP Code:
anyways, the output of the file above: PHP Code:
NPC Code: Is there a way I can check if it is a bool, because if I check with obj.type() it returns integer :( (true = 1, false = 0) Chompy is away for a week, and this has been on my mind, so I thought I could post it here to get the answer. So.., anyone know? |
I see you're using Chompy's style as well. lol
|
PHP Code:
|
if (val == true/false) works I believe.
|
But that doesn't necessarily reflect a true boolean type. As long as var isn't 0/null/"" , it's true. A true boolean type can only be 0 or 1 and Graal doesn't seem to have this type.
|
Chompy is always parsing something.
|
PHP Code:
|
in true scripting you can replace FALSE with 0 and TRUE with 1. This is a binary principle. Since FALSE is a value of nothing, "0" is used and vice versa. JUst check for a 1 or 0.
|
Quote:
|
PHP Code:
|
I think the best thing to do is to stop pretending that Graal has boolean data types.
|
Quote:
|
Well, the problem I thought would arise was when I was going to make it into an object again.. But I guess I'll just do that you guys said, to check if its either 0 or 1..
And about me making a parsing function is basically that Chompy told me that making parsing stuff is good practice :O But some way to detect if it was a bool or an integer would be nice, for example: PHP Code:
Anyways, thanks guys |
Float, integer and boolean values are all floating point numbers in Graal script.
This is made for keeping the scripting simple, since you don't need to convert values all the time. You can just do "myvar = 1.5; myvar++;" and the result will be 2.5, while in some languages you can only use "++" on integers. You can check "if (myvar)" instead of doing "if (bool(mybar))", you can do "myvar = true + true + true" to get three. Basicly the operator automatically converts the variable into the right type if necessary: @ is converting to string, "+" is converting to a number, "&&" is convert to boolean values, "&" is converting to integer (since bit operations only work fine on integer). |
| All times are GMT +2. The time now is 05:00 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.