Pixel Movement

by Forum_account
Pixel Movement
A pixel movement library for isometric and top-down maps.
ID:697767
 
mob
bump(mob/box/b, d)
if(istype(b))
b.move(d)
..()

box
pwidth = 16
pheight = 16
icon = 'General.dmi'
icon_state = "box"
set_state()

obj
door
icon = 'General.dmi'
icon_state = "doorclosed"
density = 1

turf
button
icon = 'General.dmi'
icon_state = "button"

stepped_on(mob/box)
for(var/obj/door/d)
d.icon_state = "dooropen"
d.density = 0

stepped_off(mob/box)
for(var/obj/door/d)
d.icon_state = "doorclosed"
d.density = 1


Alright so I have it so when a player pushes a box on to a button the door opens. If the box is off the button it closes.

Now the only problem I'm having is if a player also steps on the button while the box is on it, the door closes. So how could I make it so the player doesn't effect the button?
If you want to make players just not affect the button at all, you can do this:

turf
button
stepped_on(mob/box/b)
// if b isn't of the /mob/box type, we do nothing
if(!istype(b)) return

// b is a box so we open the door.

If you want to fix the problem where stepping off the button closes the door (this would happen if you push two boxes on the button, then push one off), you'd need to check if there are any other objects on the button when an object steps off:

turf
button
stepped_off(mob/m)
// if there's still a mob inside the button,
// we don't want to close the door yet
for(var/mob/m in inside())
return

// if we get to this point, the mob that stepped
// off the button was the last mob on it, so we
// close the door.
for(var/obj/door/d)
d.icon_state = "doorclosed"
d.density = 1
Now its working right, thank you!