ID:143177
 
Code:
proc/hurttrue(obj/bed/B as obj in oview(0))
usr.psionicgraphic()
var/healing = rand(1,usr.psionic)
//stops going through proc here
B.hurtpoints -= healing
if(B.hurtpoints <= 0)
B.icon_state="2"
B.hurt = 0
usr << "<font size = 6></font><font color=[usr.fontcolor]> <b>You've saved the patient!</b></font>"
usr:exp += B.exp
usr << "You gain [B.exp] experience."
usr.credits += B.credits
usr << "You earn [B.credits] credits."
var/obj/item/Blue_Ribbons/R = locate() in usr.contents
var/blueribbon = new/obj/item/Blue_Ribbons
usr<<"You recieve [B.exp] Blue Ribbons."
if(!locate(R) in usr.contents)
usr.contents.Add(blueribbon)
var/obj/item/Blue_Ribbons/L = locate() in usr.contents
L.amount+=max(B.exp-1,0)
L.suffix="[L.amount]"

else
R.amount+=B.exp
R.suffix="[R.amount]"
usr.checkexp()
sleep(200)
B.icon_state="1"
B.hurt=1
B.hurtpoints=B.startinghurtpoints
else
usr << "He begins to mend, but is still in bad shape."


No errors at compile, but when this proc gets triggered it doesn't run the proc past the point I commented in the code, it just ends the proc and does nothing, I have this working fine in another proc but here it won't work not sure why. I'm trying to make the code a bit more modular by putting into another proc what will be done multiple times in another proc. Hope that's enough info

Mike


First problem: "as obj in oview(0)" has no meaning in the argument list of a proc.

Second problem: usr usr usr usr usr usr usr usr USR. usr does NOT belong in procs. Most likely, you should be using an argument, or this should be a proc belonging to mob/ and it should be src. However, usr is almost certainly wrong.

Third problem: the colon operator. This probably stems from problem two.

Really, the big problem here is the gross abuse of usr. Either pass an argument or have this proc belong to a mob.
In response to Garthor
how do you refer to usr in a proc without using src, since src isn't recognized as usr here when i replace it? also if I don't put "as obj in oview(0)" i get an error of it not recognizing my object and interacting with it, colon operator is a relic of my earlier programming and while it works, I'll switch it for a "."

how do you "pass an arguement" (I suspect this is what most of my problems have been coming from lately)

Mike

In response to Kichimichi
In response to Garthor
nm I guess I'll just do it the long way for now, since the encyclopedia and F1 is just not helping me right now, (I've been through it already several times, and it just doesn't give the kind of examples for this that make sense to me)

mike-
In response to Kichimichi
This is a pretty fundamental aspect of every modern programming language.

Scratch that. It's a pretty fundamental aspect of every programming language, ever.

Try http://developer.byond.com/docs/ref/info.html#/proc/ arguments
In response to Garthor
I get what that section is saying mostly, I guess I'm just getting tired and I'm just not seeing how it applies to my situation.

this is a proc that can only be triggered by a usr through a verb so I would think that wouldn't be an issue and no matter how i define usr otherwise or mob in the elipses it won't work in game. I don't know what the specific way to refer to the the mob/client that originally triggered a proc and get it to replace usr in this context. I tried mob/M, I tried mob/M as mob in oview(0), and that's all I've got, neither work, usr works, I'd love to do it the right way, but I still don't think that would solve my problem beyond prettiness, I've put it into the 3 pages of code to get it to work and it works now, but anyhow I don't feel I'm making any progress as far as my knowledge goes on these issues or the efficiency of my code.

proc(someway to refer to mob triggering proc that works/U)

U.stuff

Mike-