Jump to content

GECK MATH


xab666

Recommended Posts

So i started having problems with what should have been the easiest script ever (except for hello world).

 

I made a Bottlecap press, which when activated gives 50 bottlescap for each scrap metal removed. (going to add more, but thats the jist).

this is when i learned that you cant simply use * to multiple at any time in the geck scripts (like you can in many programming languages).

(script is done, just brought this to light)

 

e.g. I tried before success

player.removeitem caps001 count*5 1

removes count# of caps

player.removeitem caps001 5*count 1

removes 5 caps.

 

how do you multiply successfully? using a second declared variable

short count
short capscount
...
set capscount to (count * 5)
player.removeitem caps001 capscount 1

removes 5 caps for each number in count (5 gives 25 caps)

 

as far as i can tell, math should be carried out when values are assigned. (set to)

 

for timers

float timer
....
if Timer >=1 
set timer to timer - getsecondspassed
elseif timer == 0
...

 

anybody know about divide?

short numer
short denom
short ans
set ans to (numer/denom)

 

but what does that return? a integer? a whole number (rounded how?)

 

honestly, I realize this post isn't a question. but I spent a while looking for this information to no avail, so I'm posting it in hope of others seeing it.

I encourage the enlightened to add relavent information.

Link to comment
Share on other sites

  On 4/4/2011 at 10:36 PM, xab666 said:

So i started having problems with what should have been the easiest script ever (except for hello world).

 

I made a Bottlecap press, which when activated gives 50 bottlescap for each scrap metal removed. (going to add more, but thats the jist).

this is when i learned that you cant simply use * to multiple at any time in the geck scripts (like you can in many programming languages).

(script is done, just brought this to light)

 

e.g. I tried before success

player.removeitem caps001 count*5 1

removes count# of caps

player.removeitem caps001 5*count 1

removes 5 caps.

 

how do you multiply successfully? using a second declared variable

short count
short capscount
...
set capscount to (count * 5)
player.removeitem caps001 capscount 1

removes 5 caps for each number in count (5 gives 25 caps)

 

as far as i can tell, math should be carried out when values are assigned. (set to)

 

for timers

float timer
....
if Timer >=1 
set timer to timer - getsecondspassed
elseif timer == 0
...

 

anybody know about divide?

short numer
short denom
short ans
set ans to (numer/denom)

 

but what does that return? a integer? a whole number (rounded how?)

 

honestly, I realize this post isn't a question. but I spent a while looking for this information to no avail, so I'm posting it in hope of others seeing it.

I encourage the enlightened to add relavent information.

 

player.removeitem caps001 count*5 1 

<< That is wrong syntax I'm pretty sure..

 

If you want "count x 5" caps removed, it should be

player.removeitem caps001 (count*5)

 

I just realized you already have this line:

 set count to count*5
player.removeitem caps001 count

So what's your question? That line should set it then remove the count*5 number of caps.

 

As for divide, I'm not positive but I think it returns a floating point value.

 

I recommend Geck Powerup if you don't have it. Here It helps immensely with syntax errors if any.

Edited by PaladinRider
Link to comment
Share on other sites

if ans is a short, it will be the whole number result of the division with the decimal part truncated. It is never rounded up.

And i've always avoided trying to compound functions - they mostly don't work ;)

Link to comment
Share on other sites

  • 3 weeks later...
  On 4/4/2011 at 11:15 PM, PaladinRider said:

player.removeitem caps001 count*5 1 

<< That is wrong syntax I'm pretty sure..

 

If you want "count x 5" caps removed, it should be

player.removeitem caps001 (count*5)

 

I just realized you already have this line:

 set count to count*5
player.removeitem caps001 count

So what's your question? That line should set it then remove the count*5 number of caps.

 

As for divide, I'm not positive but I think it returns a floating point value.

 

I recommend Geck Powerup if you don't have it. Here It helps immensely with syntax errors if any.

 

that is proper syntax, the 1 afterwords flags wether to inform the player (the messagebox in the top left when the item is removed/added) (http://geck.bethsoft.com/index.php/RemoveItem)

 

My point is that the GECK doesn't always handle math stated as

 Variable1*scalar 

as a multiplication function, and sometimes reads ONLY variable1.

in this case you have to do the multiplication using SET, thats all.

I just wanted to share that, as it caused me a minor headache

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...