Scripting question.

Post » Fri Mar 19, 2010 11:16 am

Ok well, it looks like I will be trying some more complicated scripting in the very near future, so I figure I might as well ask and get some things cleared up. Can someone explain to me in detail, preferably with examples, the difference between a Float, Short, Long, Int, and Ref variable that can declare in a script. I know you use short for things like Task or DoOnce, and float for things like Timers, but not the actual difference. Is it just how many digits it records? Like short, is something simple like 1 or 5, long is something like 1205 or 10965. Int is any whole number and float is a few decimal places? Is this all they are or do I have it way wrong? And like is there a difference between using Int and Short or Long? Since all those do is store numbers? I looked at the GECK wiki page on variables, but it didn't really clear up what the difference was, all it gave me was the size constrictions. Sorry if this is so basic, but I just would like to clear this up before getting into more complicated longer scripts so I understand. Thanks guy.

Gunmaster95
User avatar
Cedric Pearson
 
Posts: 3487
Joined: Fri Sep 28, 2007 9:39 pm

Post » Fri Mar 19, 2010 7:01 am

Cipscis said to me earlier that short and int are the same pretty much.

In my own use, float and short are like this:

Some stuff must use FLOAT values, such as additemhealthpercent.
Some stuff must use SHORT or INT, such as getweaponhealthperc.

... in the above case, that's kinda sick, isn't it.

I use SHORT variables all the time, for what I do, unless the game forces me to use FLOAT for something.

I can convert a short into a float like this:

short WeapHealthfloat WeapHealthFloatBEGIN whateverset WeapHealth to NPCREF.getweaponhealthpercset WeapHealthFloat to WeapHealthset WeapHealthFloat to WeapHealthFloat * .01end


A REF variable stores a ref ID that you snatch out of the game in realtime. Like. if I am in combat with Fawkes, and I run the script commands:

ref CombatTargetbegin gamemodeset combattarget to player.getcombattargetend


My value in the REF variable CombatTarget will equal 0002d9cf. That's Fawkes' REF in-game, not his Object ID. If something was spawned by placeatme, it'll have a weird REF ID, like FF00dfskjjsdsf .

Hope that helps..
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Fri Mar 19, 2010 3:52 pm

Ok, that really cleared up the REF variable for me. Thanks. However, I am still a bit confused as to what the difference between float, short, and long is. I get that Int is just a whole number (Or an integer...), and if its the same as short pretty much, then what is Long for? Is it even ever used?
User avatar
candice keenan
 
Posts: 3510
Joined: Tue Dec 05, 2006 10:43 pm

Post » Fri Mar 19, 2010 6:04 am

Ok, that really cleared up the REF variable for me. Thanks. However, I am still a bit confused as to what the difference between float, short, and long is. I get that Int is just a whole number (Or an integer...), and if its the same as short pretty much, then what is Long for? Is it even ever used?


My understanding is that Short and Int don't get to have decimal point values after them. Float does. And Float numbers can hold values that are larger than Short ant Int - - like, really, really huge values, bigger than almost anyone would have a use for.\

I don't know what LONG is.
User avatar
Monika
 
Posts: 3469
Joined: Wed Jan 10, 2007 7:50 pm

Post » Fri Mar 19, 2010 8:51 pm

Ok, so short and int are almost the same, for small numbers with no decimals. I get it now. And float are for number with decimals, like timers hence like 5.2358 seconds went past, or REALLY huge numbers. Ok thanks that clears it up. However I am curious as to what a LONG variable would be used for. Does it even exist? On the variable page it says "Although you can declare a variable to be Short or Long, both produce the same result as Int. " So there should be a LONG variable right? Maybe we need Cipscis or WillieSea in here >:D
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Fri Mar 19, 2010 11:47 am

Ok, so short and int are almost the same, for small numbers with no decimals. I get it now. And float are for number with decimals, like timers hence like 5.2358 seconds went past, or REALLY huge numbers. Ok thanks that clears it up. However I am curious as to what a LONG variable would be used for. Does it even exist? On the variable page it says "Although you can declare a variable to be Short or Long, both produce the same result as Int. " So there should be a LONG variable right? Maybe we need Cipscis or WillieSea in here >:D


I've never used a LONG variable for like, anything, it's sorta a nonissue I think.
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Fri Mar 19, 2010 10:03 pm

This is a 'scripting' language, not a 'programming' language. All those terms are mostly meaningless.

You basically only have Short, Float and Ref variable declarations to use.
http://geck.gamesas.com/index.php/Declaring_Variables

Long and Int are probably just substitutes you can use for the word 'Short'. And to me, using them just confuses the scripts when somebody not familiar with them looks at them.
User avatar
Jessica Raven
 
Posts: 3409
Joined: Thu Dec 21, 2006 4:33 am

Post » Fri Mar 19, 2010 7:57 pm

http://geck.gamesas.com/index.php/Declaring_Variables is the full explanation.

Float means floating point... which means has a "point" in it.

"Short" for the Geck is a 32 bit signed integer. This is large enough that you will not likely overrun it.

For http://cs.elderscrolls.com/constwiki/index.php/Declaring_variables, short is only a 16 bit signed integer. Still pretty large.

In summary, use floats when you need fractional parts, use short otherwise.
User avatar
megan gleeson
 
Posts: 3493
Joined: Wed Feb 07, 2007 2:01 pm

Post » Fri Mar 19, 2010 3:20 pm

If I am not mistaken, Short, Int and Long are all the same in the Geck. So there are only three types to use: Float, Ref & (Short/Int/Long).
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Fri Mar 19, 2010 9:46 am

Alright thanks guys I have figured it all out. Along with your help, I asked my friend about it today at school. He has been learning how to program in C++ and java and all that since he was about 7 (he is now 16) so he really knows a crapload. He also helped clear that up. Thanks again.
User avatar
Steeeph
 
Posts: 3443
Joined: Wed Apr 04, 2007 8:28 am

Post » Fri Mar 19, 2010 1:10 pm

For http://cs.elderscrolls.com/constwiki/index.php/Declaring_variables, short is only a 16 bit signed integer. Still pretty large.
Ah, I thought I'd heard Oblivion Ints were stored in-engine as Floats.
User avatar
Angus Poole
 
Posts: 3594
Joined: Fri Aug 03, 2007 9:04 pm

Post » Fri Mar 19, 2010 10:24 am

This is a 'scripting' language, not a 'programming' language. All those terms are mostly meaningless.

You basically only have Short, Float and Ref variable declarations to use.
http://geck.gamesas.com/index.php/Declaring_Variables

Long and Int are probably just substitutes you can use for the word 'Short'. And to me, using them just confuses the scripts when somebody not familiar with them looks at them.

If I am not mistaken, Short, Int and Long are all the same in the Geck. So there are only three types to use: Float, Ref & (Short/Int/Long).

Ditto what they said.

Since using the GECK, I use only REF, FLOAT, and INT variables.

I prefix my variables with the first letter of the type of variable it is.
For example:
int iVariableName
float fVariableName
ref rVariableName

I stay away from labeling the INTs as SHORTs, because FOSE allows STRING variables, so
string sVariableName
won't get confused with
short sVariableName

Like WillieSea, I try pretty hard to format and comment my scripts so that they are more easily understood, should someone else take a look at them.
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am

Post » Fri Mar 19, 2010 11:22 am

That's the naming convention that I use, as well. I used to use "short sVarName" until I realised that it would clash with string variables once they became available. I also prefix variables that will only ever be given values of 0 or 1 (i.e. boolean variables) with the letter b, i.e. "int bVarName" which helps when specifying efficient conditions for them.

For information on the values that can be stored in the various variable types, see this page on the GECK Wiki - http://geck.gamesas.com/index.php/Declaring_Variables

As noted on that page, one more alias available is "reference", which can be used to declare "ref" variables.

Cipscis
User avatar
Lyd
 
Posts: 3335
Joined: Sat Aug 26, 2006 2:56 pm

Post » Fri Mar 19, 2010 5:39 pm

Awsome guys, thanks again. I and I'm sure many others, found this incredibly educational and helpful! I am off to script something complicated now that I know the difference with all this :P

Gunmaster95
User avatar
David Chambers
 
Posts: 3333
Joined: Fri May 18, 2007 4:30 am


Return to Fallout 3