|
bishopnenar Beginner
Joined: 20 Mar 2007 Posts: 27
|
Posted: Wed May 02, 2007 5:09 pm
[1.32] Local variable and #SWITCH |
Code: |
$type = %1
$amount = %2
$person = %3
$pot = @pot
$price = 0
#SWITCH ($type = "health" || "mana") {$price = 75} ($type = "frost" || "epidermal") {$price = 150}
|
For some reason when $type is equal to frost, the $price is still equalling 75. Don't understand why this switch statement is not working.
I can post the full code if need, doubt it will be though. but at the end i I have
Code: |
say (($amount)*($price)) is the cost, please
|
Any thoughts? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed May 02, 2007 5:46 pm |
You need to have a complete expression after the OR. "$type = "health" || "mana"" means "If $type=health is true or if mana is true". "mana" on its own will always evaluate to true and so the #switch will never get past that. Use "$type="health" || $type="mana".
As an aside, you probably don't need the innermost sets of brackets in your say part, and you can directly assign the %n variables to local variables by putting them in the Params box of the package editor. If you put "$type,$amount,$person" in the Params box you can do away with the first three lines. |
|
|
|
bishopnenar Beginner
Joined: 20 Mar 2007 Posts: 27
|
Posted: Wed May 02, 2007 6:31 pm |
So by putting $localvar_whatever in the params box of an alias, elimantes the need to do what I did defining them?
Does this "speed" anything up? or have and other benifit other then having less lines to read through?
And thanks for point this out, still getting use to the $local variables. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu May 03, 2007 5:06 pm |
Yes, it also speeds things up.
|
|
|
|
|
|