ID:161080
 
Hello, I am a novice coder and am having trouble implementing a type of code. What I am trying to do is make it so that the user/player, does not see a verb that an object has unless the object is in a certain state. I have tried using if statements and conditions, but it has not gone well for me. If anyone knows how to do this then I would greatly appreciate your advice. Also, I am looking for a mentor that can aid me with coding. I don't have anything to give to the person that accepts, but appreciation and promise to work hard. My MSN is [email protected]
What you'll want to do is remove the verb from the objects' verbs list when it is in a state where the verb shouldn't be accessible, and re-add it once it gets back into a state where the verb is accessible.

Take a chair, for example:

obj/chair
New()
.=..()
verbs -= /obj/chair/verb/unbuckle //removes the "unbuckle" verb
verb
buckle()
set src = usr.loc //the verb can only be used when you are standing on top of the chair\
the use of "src = list" makes it so that if there are multiple chairs it will pick the first one\
and will not show a list of chairs, ever (even if their names are different)

if(usr.buckled) return //sanity check: don't want to buckle the user in multiple chairs.
usr.buckled = src
usr << "\blue You buckle yourself to the chair."
verbs -= /obj/chair/verb/buckle //this swaps the two verbs around
verbs += /obj/chair/verb/unbuckle
unbuckle()
set src = usr.loc
usr.bucked = null
usr << "\blue You unbuckle from the chair."
verbs -= /obj/chair/verb/unbuckle
verbs += /obj/chair/verb/buckle

mob
var
obj/chair/buckled
Move()
if(buckled) return 0 //physical barrier: strapped in a chair
return ..()


Also note that setting mob.buckled to an object is a good habit in this case. Most newbie programmers set this to a boolean variable (1 or 0) to show whether or not you are buckled into a chair or not, but this isn't good.

Since it's an object, it means that if the chair is somehow deleted, the player that was buckled into the chair will be unbuckled automatically.
In response to Android Data
Android Data wrote:
...

Gah, I was speaking to Data on msn, I was supposed to answer this post. Android Datas a post stealer!
In response to Hulio-G
Thank you very much. I finally got it to work. Thanks once again.