Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variables
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Variables

I like using booleans in the script, but there are no dedicated functions (like SetLocalVarBool) because it's unnecessary. An int with 0/1 does the same. But bools are still pretty cool.

Now, for a beginner, they probably don't need to worry about it though. Seeing as this is, by the looks of it, a beginners guide to variables, it's fairly good the way you've put it up. On the more technical side, I just wanna mention a few things Tongue

There are a few other variables that can be used, such as a Double. They're used just like floats, pretty much, but they have a greater range (not that it's needed in 99% of cases).

Using the primitive versions is often easier (in my opinion).
PHP Code: (Select All)
int intName 0;
float floatName 1.0f;
double doubleName 1.0d;
string stringName "Hello World";
bool boolName true

So like
PHP Code: (Select All)
int number 1;
if(
number == 1DoSomething(); 
does the same as
PHP Code: (Select All)
SetLocalVarInt("number"1);
if(
GetLocalVarInt("number") == 1DoSomething(); 
so it's mostly down to preference. Mind that they don't work interchangeably though.
PHP Code: (Select All)
SetLocalVarInt("number"1);
if(
number == 1DoSomething(); 
This does not work.

There are more primitives, but the ones above (except the double) are the important ones. They work the same as how you've explained though. Notice the f and d at the end of the float and double values. They simply state that this value is a float or a double. If you do
PHP Code: (Select All)
float f 1.0
Then the game will assume 1.0 is a double, and will therefore convert it to a float. It doesn't really matter since the value was never actually a double, so you won't lose any precision, but it's something to note. It will probably give you a warning in the log file if you do not add the f. The d on the double value is not as important though, since it will already assume it's a double.

Just some extra info for the curious ones Big Grin

PS: Your (assumptions) seem correct to me.

(This post was last modified: 09-15-2014, 12:18 AM by Mudbill.)
09-15-2014, 12:17 AM
Find


Messages In This Thread
Variables - by FlawlessHappiness - 09-14-2014, 10:25 PM
RE: Variables - by Mudbill - 09-15-2014, 12:17 AM
RE: Variables - by FlawlessHappiness - 09-15-2014, 12:25 AM
RE: Variables - by Mudbill - 09-15-2014, 07:32 AM
RE: Variables - by Romulator - 09-15-2014, 08:16 AM
RE: Variables - by FlawlessHappiness - 09-15-2014, 11:46 AM
RE: Variables - by Romulator - 09-15-2014, 12:21 PM
RE: Variables - by FlawlessHappiness - 09-15-2014, 12:47 PM



Users browsing this thread: 1 Guest(s)