|
Author
|
Topic: Strings
|
|
Gautier UK |
posted 31-03-2003 16:05 GMT
im trying to make it so that if the string #endurance# is less than or equal to 16, then #HP# is set to 20. then i made another condition, that if the string #endurance# is greater than or equal to 17, then #HP# is set to 25. but no matter what #endurance# is, its always 20. =S HELP!
|
|
Alex
|
posted 31-03-2003 16:35 GMT
It's probably better to use numeric variables rather than strings for this. In either case, the number one suspect when your conditions fail is missing "#" or "%" characters around your string or numeric variable. If you leave them out, the test won't work. So make sure you really are checking "#endurance#" rather than just "endurance". (Also, consider changing it to a numeric variable, which is specifically designed for numbers - then you would use "%endurance%" instead) |
|
Gautier UK
|
posted 31-03-2003 22:26 GMT
well, this is wot i have.....command <roll> { set <Strength; $rand(8;21)$> set <Intellect; $rand(8;21)$> set <Agility; $rand(8;21)$> set <Endurance; $rand(8;21)$> set <Knowledge; $rand(8;21)$> set <Charisma; $rand(8;21)$> if ( %Endurance% <= 16 ) then set <HP; 20> else {if ( %Endurance% >= 17 ) then set <HP; 25>} if ( %Knowledge% <= 16 ) then set <MP; 12> else {if ( %Knowledge% >= 17 ) then set <MP; 20>} msg <|clYour stats are now.....|cg|n|n-Strength |cr#Strength#|cg|n-Intellect |cr#Intellect#|cg|n-Agility |cr#Agility#|cg|n-Endurance |cr#Endurance#|cg|n-Knowledge |cr#Knowledge#|cg|n-Charisma |cr#Charisma#|cg|n|n|cb> if ask <Re-Roll?> then exec <roll> else goto <Tavern> } |
|
Alex
|
posted 01-04-2003 12:01 GMT
Make sure your "Endurance" variable is set up explicity as a numeric variable before this code is executed - for example in your startscript. You need to have something like:set numeric <Endurance; 12> If that's donem then from what I can tell, it looks like your script should work. One small tweak I can suggest (though it won't make it work if it's still broken) is that you don't need to write: if ( %Endurance% <= 16 ) then set <HP; 20> else {if ( %Endurance% >= 17 ) then set <HP; 25>} - the "else if" seems a bit redundant, as the "else" will execute anyway if endurance is 17 or greater. So, this should work the same: if ( %Endurance% <= 16 ) then set <HP; 20> else set <HP; 25> and it's a bit less typing :)
|
|
Gautier UK
|
posted 01-04-2003 15:12 GMT
arg! nothing seems to work! would anybody be willing to make a small roller and help me to fix the problem? |
|
Gautier UK
|
posted 01-04-2003 15:15 GMT
i think it could be the HP variable itself though. i did a small test, where if i typed "change hp", the HP variable changes to 100, but that didnt work, so it must either be my coding, or the status variable. |
|
Gautier UK
|
posted 01-04-2003 15:56 GMT
ok so i worked out that, i think ill just make it so that the player starts off with a set amount of HP, and MP, instead of going through all the trouble of trying to fix it. |