ID:261641
 
Hi, im currently making a training centre, in this centre i am making punching bag that gain you experiens in attacksing skills, this is randomly between 0-5. The following code is what iv'e come up with, i know that this is sort of like it should look like, i think. Anyways, heres the code, and below the code my errors will be displayed...
turf
pbag
icon='tc.dmi'
icon_state = "pbag"
density = 1
var
amount
verb
Practise_On_Punching_Bag()
set src in oview(1)
usr.Attack+= rand(0,5)
usr<<"You gain [amount] exp!"

//heres the errors
error:set :invalid proc definition
error: += :invalid proc definition
error:<< :invalid proc definition



turf
pbag
icon='tc.dmi'
icon_state = "pbag"
density = 1
var
amount
verb
Practise_On_Punching_Bag()
set src in oview(1)
usr.Attack+= rand(0,5)
usr<<"You gain [amount] exp!"

You had to indent the three lines after Practise_On_Punching_Bag() once more. Also, in the last line, amount is never set to anything, unless its value is set elsewhere.
Thanks a lot, it works well now, one more thing though, when i lay the game, when the user punches the bag, and the text comes up, it doesnt say how much experience he/she gained, i thought puting in [amount] would work but it doesnt, got any ideas?
In response to The Conjuror
this is your code, or something like it:

turf
pbag
icon='tc.dmi'
icon_state = "pbag"
density = 1
var
amount
verb
Practise_On_Punching_Bag()
set src in oview(1)
usr.Attack+= rand(0,5)
usr<<"You gain [amount] exp!"

Your code is correct, but the value of amount is null. So it does technically work, but amount has no value, so it has no value to display. You could put this, when you declare the var:

var
amount = 5

That way whenever you hit it will say you gained 5 exp. Or you could have it pick a random number for the amount of exp you get. Either way you must set amount at one time or another. Also, you never gain the exp, it just says that you do. So if you want to keep track of that exp, you'd have to make a var and add amount to it every time you punch it.
In response to OneFishDown
i know, i already have all this, its included in my stat panel, im doing what you said, and now it shows an amount, but it always only shows 5, which i know you said, but when i put rand in, it sais stuff like and expected a constant expression, i know im giving you head aches right now probably, this is what i'm doing.


turf
pbag
icon='tc.dmi'
icon_state = "pbag"
density = 1
var
amount = rand(1,5)
verb
Practise_On_Punching_Bag()
set src in oview(1)
usr.Attack+= rand(0,5)
usr<<"You gain [amount] exp"

know what to do? Please reply.
In response to The Conjuror
turf
pbag
icon='tc.dmi'
icon_state = "pbag"
density = 1
var
amount
verb
Practice_On_Punching_Bag()
set src in oview(1)
usr.Attack+= rand(0,5)
amount = rand(0,5)
usr<<"You gain [amount] exp"

I just put the rand() statement in the verb itself; that should work.
In response to OneFishDown
Stop misleading the poor ol' guy.
<code> var/X = rand(0,5) usr.Attack += X usr<<"You gain [X] exp" </code>
In response to OneFishDown
Ok Ok, now when i punch the pbag, you see a random number, but thats not the amount you actually gain! So it says for example you gain 4 exp and really you only gain 2, ect. I have seen a punching bag used in some demos before, but there gone now, so i dont know what im going to do, i've tried a lot of stuff, and nothing, well, i gotta go eat something, im starving, but if you get the code, plz post it.
P.S. If its possible, i was wondering if you could add a probability, so your not always getting stats up, kinda cheap, ya know. Or if you can't do that could you add something that for example makes it so that when the user punches the pbag repeatedly, after oh say 5 punches, it says you are tired out, and must rest, the i guess you need to use sleep proc in that, i dont know, i dont want to put pressure on you so you dont have to do this.
In response to OneFishDown
OneFishDown was close, but not quite. This should work better:

Practice_On_Punching_Bag()
set src in oview(1)
var/amount = rand(0,5) // set amount to a random value
usr.Attack+= amount // add it to the Attack
usr<<"You gain [amount] exp" // display it to the player

Please don't cross-post -- place your posts in one forum only. Thanks for your cooperation!
In response to The Conjuror
thanks a lot guys, i now have the right code, thank you! But i still was wondering, if say i made a new stat called stamina, and what happens is when you punch the bag too many times, your stamina lowers, and you must therefore, wait a while for your stamina to fill up again, I know ive been asking a lot, but ive tried playing around with the code a lot and i finally said too my self, ask some people. So if you have any idea how to do the stamina thing, please tell me, id appretiate it a lot, i know it has something to do with sleep() and maybe prob()
I appretiate all the work you all have chipped in, and ill be sure to mension your names in the acknowledgments list.

Thanks
The Conjuror
In response to Garthor
Well I didn't know how he wanted to deal with attack and experience, that's up to him, not me. I just fixed what needed fixing, so that it will run. At least I didn't say that his idea sucked, even before any of us knew what exactly his idea was.
In response to OneFishDown
There's the thing for stamina, it should work perfectly.

Practice_On_Punching_Bag() set src in oview(1)
var/amount = rand(0,5)
if(usr.stamina >= 10)
usr.Attack+= amount
usr<<"You gain [amount] exp"
else
usr<<"You are too tired!"