ID:160117
 
Just learning a semi new aspect of the return proc for myself.
mob
var
can
cant
proc
check()
if(src.cant) return 0 //Just demo checks
if(!src.cant) return 1
verb
Can()
src.can=1
src.cant=0
Cant()
src.can=0
src.cant=1
Talk(s as text)
if(src.check()==1) //Is there a better way to check this?
world<<"[s]"
if(src.check()==0) //Same deal here
src<<"Cant"



I would be using it to check for multiple instances apon using an ability so having it return negative in multiple cases and saving me tons of lines of code per skill. Is that the best way to use it?
How about:

mob
var
can = TRUE
proc
check()
if(can)
return TRUE
else
return FALSE
verb
Change()
can =! can
Talk(s as text)
if(check())
world<<"[s]"
else
src << "Cant"


I've made it as robust as I could've made it and shorter, I hope it's fine =)

Edit: Why use more than one variable? Boolean variables are a great, and I see you have kind of used them in the code above but with a little more experiance you will learn to use them like I did there. also "can=!can" basicly switches between true and false, e.g. "if can is true" it makes can hold false and vice-versa.

Haywire
In response to Haywire
Close enough. I have a number of vars that need to be checked but that closes in on what I needed. Thank you.
In response to Rtbbvr
I totally forgot to answer your question, Basicly it is pretty much a FINE way to handle it. Personally, I would do the same if not, worse >_>

Haywire
In response to Haywire
That won't even compile, Haywire. <.<

[Edit] Nevermind, thought you wanted to use the != operator.

Confused me a little by seeing can =! can when I always use can = !can
In response to Andre-g1
What the heck? It sure does, Why won't it?
In response to Haywire
Edited.
In response to Andre-g1
ahh yes, That was my messy programming, Nevermind =)