what is wrong in this?
var
//stats
str = 0
dex = 0
agi = 0
dur = 0
int = 0
wis = 0
wil = 0
//stat modifications
str_mod = 0
dex_mod = 0
agi_mod = 0
dur_mod = 0
int_mod = 0
wis_mod = 0
wil_mod = 0
//stats current
str_cur = str + str_mod
dex_cur = dex + dex_mod
agi_cur = agi + agi_mod
dur_mod = dur + dur_mod
int_cur = int + int_mod
wis_cur = wis + wis_mod
wil_cur = wil + wil_mod
it gives me these errors in //the stats current part:
str : ivalid variable
str_mod : invalid variable
= :expected constant expression
and so on for all the stats
ID:180790
Feb 16 2001, 5:47 am
|
|
In response to Guy T.
|
|
damn, why can't I use tabs in this forum. it really looks like this:
var //stats str = 0 //stats current str_cur = str + str_mod I removed a tab in front of the "stat"_cur part, now it tells me that all those vars are bad. any ideas? |
In response to Kaidorin
|
|
On 2/16/01 9:11 am Kaidorin wrote:
damn, why can't I use tabs in this forum. it really looks like this: Variables don't like to be set to non-constant values at compile time. In other words, if you try to set a variable to another variable, it won't work unless it is inside a proc. You can do the same thing, albeit in a few more lines: mob var str = 0 str_mod = 0 str_cur = 0 //etc. New() ..() str_cur = str + str_mod //etc. |
In response to Spuzzum
|
|
mob
var str = 0 str_mod = 0 str_cur = 0 //etc. New() ..() str_cur = str + str_mod //etc. will these update automatically during runtime? |
In response to Kaidorin
|
|
On 2/16/01 1:32 pm Kaidorin wrote:
mob No, in that case you want str_cur to actually be a function. Anytime you need to figure out something in realtime to provide the value, it should be handled by a function. So to get current strength, you could have this: mob/proc/CurrentStrength() return str + str_mod |
In response to Kaidorin
|
|
On 2/16/01 1:32 pm Kaidorin wrote:
mob Nope. You'd need to do something else instead: mob var str = 0 str_mod = 0 str_cur = 0 dex = 0 dex_mod = 0 dex_cur = 0 //etc. New() ..() UpdateStr() UpdateDex() //etc. mob/proc/UpdateStr() str_cur = str + str_mod spawn(rand(1,10)) UpdateStr() mob/proc/UpdateDex() dex_cur = dex + dex_mod spawn(rand(1,10)) UpdateDex() //etc. |
In response to Deadron
|
|
now it works perfectly!!!
thanks Deadron, Guy T and Spuzzum!! |
It looks like you have "var" indented more than the code underneath it. Also, the code that adds the modifiers should be outdented one level.