Assigning a description to an attribute?

katheb
07 Jul 2012, 00:41
Hello,



I am new to this interesting program and was wondering.

Let's say I set an attribute called weight and set a few different objects thier own weight. [like the tutorial]

object one = 1kg

object two = 50kg

object three = 1000kg

when I put the commant to look at object instead of having it say [object one weighs 1kg] is there a way to set the weight between 1 and 49 to be "light" 50 to 999 to be "moderatly heavy." and 1000+ to be "Too heavy it is impossible to lift"


so if I look at object two it would say

object two is moderatly heavy.


if anyone can help me with this I would be greatful

thank you.

sonic102
07 Jul 2012, 06:45
I have two suggestions:

1---Instead of putting the value of the weight attirbute to an integer, put it to a string. Then type in whatever you want.(example- type in "moderately heavy")

2---In the weigh command, inside the 'If object has attirbute 'weight' ', check if object.weight > 50, then if true print "object is light". In the else if check if weight > 1000 and print "it is moderately heavy" if it is true. In the else script print "too heavy it is impossible to lift"

The first one is more easier, but the second one has it's advantages. If you need to check the weight of an object anytime outside the command, I recommend the second one.

katheb
07 Jul 2012, 09:42
EDIT: HUZZAH! I got it, the switch was what I was looking for. it is kinda like loads of if statements in one. I had a weight set for the player then added a switch to read the weight and display a message of light medium heavy dependant on the numbers and then added an item the increaed the weight if you ate it so it worked! I think the second option is closer to what I want to do.

but let's say I wanted more steps than light moderate heavy.

looking at the help wiki I saw something called "SWITCH" where you can put quite a few in there

0 = weightless
1 = light
2 = average
3 = heavy
4 = very heavy
5 = extreamly heavy
6 = unmoveable!

ect ect

but I have no idea how to pull that information into a printed message based on the current items number/weight

look at box1 [le't say box one is 3]

and have it print out

box1 is heavy

so later I could add something to the box and have it become [4]

box1 is very heavy

I aprecieate the info thank you.