I'd like to be able to expand some of our variables, and have actual math expressions that make use of them. This is either out of Nib's BAL or inspired by it.
The following would be for turning in diamonds in the newbie area. In this example, there is a give script for the various gems. Token 3500 would track that, and value 3, specifically, would be for tracking diamons. When you wanted your reward, you would say 'redeem gems' which would fire this script.
The script would check for the player having token 3500, and if so, if value 3 of token 3500 was greater than 0\. If so, it would do some math, multiplying value 3 of the token by 1000, and awarding the total in experience to the player. It would then set value 3 to 0.
````
if hastoken $n 3500
and tokenvalue $n 3500 3 > 0
mob awardxp $n $[$[tokenvalue $n 3500 3] * 1000]
token adjust $n 3500 3 = 0
else
mob echoat $n {DYou haven't turned any diamonds in yet.{X
endif
````
This script would fire if the player said something like 'gem count' It checks each value, and returns the count of each gem in an echo (or tells the player that none of each type have been turned in). If the player has at least one unredeemed gem, it also displays a total count of gems, by adding values 0 - 3 together, and printing the total in an echo to the player.
````
if tokenvalue $n 3500 0 > 1
mob echoat $n {DYou can redeem $[tokenvalue $n 3500 0] rubies.{X
else
mob echoat $n {DYou haven't turned in any rubies.{X
endif
if tokenvalue $n 3500 1 > 1
mob echoat $n {DYou can redeem $[tokenvalue $n 3500 1] sapphires.{X
else
mob echoat $n {DYou haven't turned in any sapphires.{X
endif
if tokenvalue $n 3500 2 > 1
mob echoat $n {DYou can redeem $[tokenvalue $n 3500 2] opals.{X
else
mob echoat $n {DYou haven't turned in any opals.{X
endif
if tokenvalue $n 3500 3 > 1
mob echoat $n {DYou can redeem $[tokenvalue $n 3500 3] diamonds.{X
else
mob echoat $n {DYou haven't turned in any diamonds.{X
endif
if tokenvalue $n 3500 0 > 1
or tokenvalue $n 3500 1 > 1
or tokenvalue $n 3500 2 > 1
or tokenvalue $n 3500 3 > 1
mob echoat $n {DYou have a total of $[$[tokenvalue $n 3500 0] + $[tokenvalue $n 3500 1] + $[tokenvalue $n 3500 2] + $[tokenvalue $n 3500 3]] gems available for redemption.{X
endif
````
This can ideally be used for any checkable value, tokens are simply the big thing lately and it made sense to use them for the example.