ID:155199
 
Basically I have two verbs, Open and Close for the front door. Everything is working correctly, and I even got it so that the door can't be picked up by anyone :D

However, I only want one of the commands to show at a time when the event is met. Say for instance you walk up to a door and the door is closed. Only the open command should show. Once the door is open, only the close command should show. I tried doing things like using set hidden = 1 based on certain variables being met but it just breaks the entire function all together for some reason.

Here is what I have:

obj/Door
icon = 'Door.dmi'

House_Door
icon_state = "Closed"
density = 1
opacity = 1
get = 0

verb

Open()
if(state == 1)
set src in oview(1)
set category = "Door"
icon_state = "Open"
density = 0
opacity = 0
state = 2
Close()
if(state == 2)
set src in oview(1)
set category = "Door"
icon_state = "Closed"
density = 1
opacity = 1
state = 1


That part I did try was this:

Close()
if(state == 1)
set hidden = 1
else
set src in oview(1)
set category = "Door"
icon_state = "Closed"
density = 1
opacity = 1
state = 1


But all it does is hide the close verb altogether.
Verb settings aren't something you can change at run-time. Those are set at compile time for the game to know how to use them.

What you can do to get what you want is modify the verbs list var. You can add and remove verbs from that list, and it will cause them to either show up or not. An easy way for this to work is to make one of those verbs a proc instead of a verb. (So, it won't be in the verb list.) I'll assume the door starts closed, so the Close() verb should be a proc.
Then, in Open you do:
verbs -= .Open //short for /obj/Door/House_Door/verb/Open
verbs += .proc/Close //short for /obj/Door/House_Door/proc/Close

And vice-versa in the Close proc. (I'm using the . path operator there to avoid typing out the entire path tree.)
In response to Complex Robot
I appreciate the answer but this is even more confusing now. I guess I'm going back to read the reference for another few hours X.X
In response to Penguinsandwich
obj/Door
icon = 'Door.dmi'

House_Door
icon_state = "Closed"
density = 1
opacity = 1
get = 0

verb

Open()
if(state == 1)
set src in oview(1)
set category = "Door"
icon_state = "Open"
density = 0
opacity = 0
state = 2
verbs -= /obj/Door/House_Door/verb/Open
verbs += /obj/Door/House_Door/proc/Close

proc

Close()
if(state == 2)
set src in oview(1)
set category = "Door"
icon_state = "Closed"
density = 1
opacity = 1
state = 1
verbs -= /obj/Door/House_Door/proc/Close
verbs += /obj/Door/House_Door/verb/Open

Does this help clarify?
Just read the reference about the verbs list.
In response to Complex Robot
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh XD

I appreciate your help in this. I left that alone for a while as I'm still trying out the new stuff from chapter 5 on variables. I just figured out how to make my life so easy using .variables and I made an examine command for all the objects in the world! This is so much fun :D
In response to Penguinsandwich
There is one problem with this code:
1.Make two doors.
2.Try to open both of them.
After opening one door, you will notice you don't have open verb for another door.
In response to Martys1103
Martys1103 wrote:
There is one problem with this code:
1.Make two doors.
2.Try to open both of them.
After opening one door, you will notice you don't have open verb for another door.


I already figured out how to do that.

obj
verb
// *****Get and Drop*****
get()
if(src.get == 1)
set src in oview(1)
set category = "Object"
loc = usr
drop()
set src in usr
set category = "Object"
loc = usr.loc

// *****Examine*****

examine()
set src in oview(1)
set category = "General"
usr << "This item is a [src.name]. \nA [src.name] is used for [src.function]. \nA [src.name] has a value of [src.value] gold. \nA [src.name] weights [src.weight] lbs."

// *****Doors*****

obj/Door
verb
open()
set src in oview(1)
set category = "Door"
src.icon_state = icon_open
density = 0
opacity = 0
verbs -= .verb/open
verbs += .proc/close

proc

close()
set src in oview(1)
set category = "Door"
density = 1
opacity = 1
src.icon_state = icon_close
verbs -= .proc/close
verbs += .verb/open


And to the object:

obj/Door
icon = 'Door.dmi'

House_Door
icon_state = "Closed"
density = 1
opacity = 1
get = 0
icon_open = "Open"
icon_close = "Closed"
In response to Martys1103
Martys1103 wrote:
There is one problem with this code:
1.Make two doors.
2.Try to open both of them.
After opening one door, you will notice you don't have open verb for another door.

You shouldn't have that problem, since it's modifying the verbs list of the door object itself. (So, it's only modifying that one door.)
If you defined Open and Close verbs/procs on the mob itself, then this problem would happen. (If you were modifying the mob's verbs list.)