ID:172062
 
Ithere a way to make an atom have an effect when a var is changed? Example: (I know this doesn't work but it's for an idea.)

turf/door_step
Enter(mob/M)
objectvar = "open" // when it is entered, obj/automatic_door changes.

obj/automatic_door
if(objectvar == "locked")
icon = 'icon.dmi'
icon_state = "locked"
density = 1
if(objectvar == "open")
icon = 'icon.dmi'
icon_state = "open"
density = 0
It would be better to just have a proc be called instead of having to check the variable within a loop, which is the way you would have to do it otherwise.

turf/door_step
Enter(mob/M)
var/obj/automatic_door/O = locate(src) //Looks through all objects located on that turf.
if(O != null)
O.Do_Action("Open")

obj/automatic_door
proc/Do_Action(DoWhat)
switch(DoWhat)
if("Locked")
icon = 'icon.dmi'
icon_state = "locked"
density = 1
if("Open")
icon = 'icon.dmi'
icon_state = "open"
density = 0



//Then if you want to check if it is open or not, simply check it's density.
In response to Kunark
So as soon as the action required to activate it is taken. The icon or whatever will change?

And im meaning this too.


ex: joe steps on a turf at 1,5,1. The turf at 1,1,1 becomes dense.


What goes on the arg: Dowhat?
In response to ZLegend
If want to do that, then you do this:

turf/door_step1
Enter(mob/M)
var/obj/automatic_door/O = locate(1,1,1) //Looks through all objects located on that turf.
if(O != null)
O.Do_Action("Open")

obj/automatic_door
proc/Do_Action(DoWhat)
switch(DoWhat)
if("Locked")
icon = 'icon.dmi'
icon_state = "locked"
density = 1
if("Open")
icon = 'icon.dmi'
icon_state = "open"
density = 0



//Then if you want to check if it is open or not, simply check it's density.

In response to Kunark
Ok. Know what do u do in the arg "DoWhat"?


Could you also tell me what if(O != null) does? I know what the ! operator does. But no idea what it has to do with the variable O.




Runtime Error:

runtime error: undefined proc or verb /turf/floor/Do Action().

proc name: Enter (/turf/door_step1/Enter)
source file: turfs.dm,541
usr: Zlegend2 (/mob)
src: the door step1 (19,5,1) (/turf/door_step1)
call stack:
the door step1 (19,5,1) (/turf/door_step1): Enter(Zlegend2 (/mob))
Zlegend2 (/client): Move(the door step1 (19,5,1) (/turf/door_step1), 2)
In response to ZLegend
ZLegend wrote:
Ok. Know what do u do in the arg "DoWhat"?

DoWhat is a variable. It would be the same as typing, (var/DoWhat)... Except you can define this variable elsewhere. If you need to close a door, just call Do_Action("Locked") because within the Do_Action proc, it checks what DoWhat is, and does the nessisary action.


Could you also tell me what if(O != null) does? I know what the ! operator does. But no idea what it has to do with the variable O.

!= mean "Is not that of". So this statement would be, "If the variable, "O", is not that of null (or doesn't exist, in other words), then proceed."

So, it checks if locate found anything on that turf... If it doesn't find anything, simply calling O.DoAction("Open") is only going to give you a "Cannot execute null.DoAction()" because nothing was there.