ID:1276697
 
(See the best response by Headshot007.)
In my trails of mapping and creating my first game, I thought:" It would be cool to add doors". I remember that from "Step in Byond" and "Your First World" that bumping and the door proc or what ever. Any one know a simple way to use a code such as these to make doors?



Best response
this is what I use to make doors, works pretty well but is probably a bit more complex than what your looking for. this is a whole demo, all you would need would be the icons and icon states and a map and this would work.

turf //making the ground
ground // grass and such
icon = 'ground.dmi'
opacity = 0 //doesn't block line of sight
density = 0 //doesn't stop movement
wall //walls and such
icon = 'wall.dmi'
opacity = 1 //stops line of sight
density = 1 //stops movement
doors //the parent for all doors
opacity = 1 //when the game starts door will be closed
density = 1 //and therefore block line of sight and movement
var
openstate //the icon state of the door while open
closedstate //the icon state of the door while closed
basicdoor // one type of door
icon = 'door.dmi' //make and icon with 2 states: closed and open
icon_state = "closed"
closedstate = "closed"
openstate = "open"
mob
Login() //create player
icon = 'player.dmi'
loc = locate(/turf/ground)
Bump(turf/doors/D) //whenever player bumps into a door
if(istype(D,/turf/doors)) //check to make sure its a door
D.icon_state = D.openstate // make the icon state equal to the open state
D.opacity = 0 //make it not block line of sight
D.density = 0 //make it not stop movement
sleep (20) //wait 2 seconds
D.icon_state = D.closedstate // make the icon state closed
D.opacity = 1 // stop LOS
D.density = 1 // stop movement
In response to Headshot007
Density is by default 0 (1 for mob) and opacity is by default 0.


~Deathscyth
In response to Headshot007
why is there a D. in front of icon_state, density, and opacity?
In response to Thedeadwarrior123
In the Bump() procedure, he's specified an argument named D of type /turf/doors. This argument will behave as a local variable to the function, allowing you to access properties of D. D.icon_state for example, allows you to set the state of the particular door the player bumped into, and so forth.