ID:175693
 
Hello. It's me yet again. I would like to start by thanking every one who has helped me so far.
Now on to the matter at hand. I have looked through this forum for a way to have a door open and close using commands, instead of opening and then closing a set time after. Unfortunately I Have not found that information, so I have tried to do so on my own with the following faulty results. Please help me get this to work.
Oh, before I forget I am using multiple tiles for this if it makes a difference. The door.png is 2*3 and door open.png is 1*3.

The code is as follows

obj
door
verb
Open()
if(icon == 'door.png')
set src in oview(1)
icon = 'door open.png'
density = 0
icon = 'door.png'
density = 1
..()
Close()
if(icon == 'door open.png')
set src in oview(1)
icon = 'door.png'
density = 0
icon = 'door open.png'
density = 0
..()

Here are the errors it generates.

codes\objs.dm:32:error:Open ;undefined proc
codes\objs.dm:33:error:icon:duplicate definition
codes\objs.dm:33:error:'door.png':duplicate definition
codes\objs.dm:33:error:== :instruction not allowed here
codes\objs.dm:33:error::duplicate definition
codes\objs.dm:41:error:icon:duplicate definition
codes\objs.dm:41:error:'door open.png'duplicate definiton
codes\objs.dm:41:error:== :instruction not allowed here
codes\objs.dm:41:error::duplicate definition
codes\objs.dm:34:error:src:duplicate definition
codes\objs.dm:34:error:1:value not allowed here
codes\objs.dm:34:error::duplicate definition
codes\objs.dm:34:error:in :instruction not allowed here
codes\objs.dm:34:error::duplicate definition
codes\objs.dm:40:error:Close :unidentified definition
codes\objs.dm:42:error:src:duplicate definition
codes\objs.dm:42:error:1:value not allowed here
codes\objs.dm:42:error::duplicate definition
codes\objs.dm:42:error:in :instruction not allowed here
codes\objs.dm:42:error::duplicate definition
codes\objs.dm:31:error:verb :expected proc definition


Thanks again
*Some Guy Named Steve*
obj
door
verb
Open()
if(icon == 'door.png')
set src in oview(1)//Problem, don't put set in a verb.
icon = 'door open.png'
density = 0
icon = 'door.png'
density = 1
..()
Close()
if(icon == 'door open.png')
set src in oview(1)//same problem
icon = 'door.png'
density = 0
icon = 'door open.png'
density = 0
..()
Okay, I took set out and I still get all the same errors.
In response to Goku72
Good job Goku72, you've once again managed to give totally useless advice! Or wait, even better, advice that is DETRIMENTAL to this person's verb! Not only is "set src in oview(1)" perfectly acceptable in a verb, but it is in fact REQUIRED for a verb like this!

The problem is, of course, indentation. Open() and Close() need to be indented once more, and everything except obj, door, and verb need to be indented twice more.
In response to Goku72
ok....no offense GOku, your wrong, whats wrong here is your INDENTATION also, its better to check if the door is dense than to check to see if the doors icon is such
obj
door
icon = 'door.png' //default icon
density = 1 //default density
verb
Open()
set src in oview(1)
if(src.density) //if the src is dense
icon = 'door open.png'
density = 0
Close()
set src in oview(1
if(!src.density) //if the src isn't dense, dont check for the icon
icon = 'door.png'
density = 1
that should do it
In response to Drag0n
Okay here is the fixed code, which works nearly fine now. Except for the fact that it only opens the 2*3 door one tile at a time, instead of all six tiles at once like i need it too. Any thoughts on how I can fix this?

obj
door
icon = 'door.png'
density = 1
verb
Open()
set src in oview(1)
if(src.density)
icon = 'door open.png'
density = 0
Close()
set src in oview(1)
if(!src.density)
icon = 'door.png'
density = 0


In response to Madcrackfiend
Madcrackfiend wrote:
Okay, I took set out and I still get all the same errors.

There are several problems in your code, but the main one is indentation: You're not indenting after verb, and you're not indenting after Open() or Close(). DM is giving you the errors it is because it can't figure out where your procs actually begin, because the indentation isn't right.

Lummox JR
In response to Madcrackfiend
The simplest way I can think of is to loop through nearby doors and change them all. This will be a little buggy if you have doors close to each other, though. (Close being within 2-3 tiles.)

obj
door
icon = 'door.png'
density = 1
verb
Open()
set src in oview(1)
if(src.density)
for (var/obj/door/D in range(2,src))
D.icon = 'door open.png'
D.density = 0
Close()
set src in oview(1)
if(!src.density)
for (var/obj/door/D in range(2,src))
D.icon = 'door.png'
D.density = 1 //Surely you want closed doors to be dense? =D
In response to Crispy
Thanks a lot all of you. The doors are working just fine now.

Until the next problem arises
*Some Guy Named Steve*
In response to Garthor
I meant as in not putting it in the actual context of the verb, sorry if I was mis understood. And when I say context...I mean the actual action of the verb.