ID:141788
 
Code:
var
stayLosses = 0
stayWins = 0
switchLosses = 0
switchWins = 0
tmp
stage = 1 //The game has two basic stages, and stage 3 occurs when the game is over.
doors[3] //A list of all doors in the world---necessary to ensure that the door with the car does not open.
obj/Door
carDoor
openDoor //The first door that the host opens.
firstChoice //The first door that the user picks.

mob
Login() //Assign door numbers and call new_game.
var
n = 1 //Assigns each door its door number.
obj/Door
doorOne = new(3, 3, 1)
doorTwo = new(3, 5, 1)
doorThree = new(3, 7, 1)
for(var/obj/Door/D in world)
D.doorNumber = n
n++
new_game()
return ..()

verb
new_game() //Set game variables to initial values.
firstChoice = null
carDoor = null
openDoor = null
var/obj/Door/D
for(D in doors)
doors.Remove(D)
for(D in world)
doors.Add(D)
stage = 1

obj/Door
var/doorNumber
icon = 'door.dmi'

New()
icon_state = "closed"
return ..()

verb
select() //Pick a door.
if(src == openDoor && stage < 3) //If it's the third stage, the game will restart anyway.
usr << "That door is already open."
else
switch(stage)
if(1) //Open a random door
src.icon_state = "selected"
firstChoice = src
carDoor = doors[rand(1, 2)]
doors.Remove(carDoor) //To ensure that the car door is not opened.
if(src != carDoor) //Otherwise, a runtime error could occur.
doors.Remove(src) //To ensure that the door the user picked is not open.
openDoor = doors[rand(1, doors.len)]
openDoor.icon_state = "goat"
usr << "You pick Door [src.doorNumber]. Monty Hall opens Door [openDoor.doorNumber] to reveal a goat. Do you switch or stay?"
stage = 2
if(2) //Open the door the user picks and see if he wins. Increment the appropriate variable.
carDoor.icon_state = "car"
usr << "You open Door [src.doorNumber] and find . . . "
if(src == carDoor)
usr << "a car! You'll be cruising in style from now on."
for(var/obj/Door/D in world) //This is necessary to open the remaining door.
if(D.icon_state == "closed")
D.icon_state = "goat"
if(src == firstChoice)
stayWins++
else
switchWins++
else
usr << "a goat! (And you don't actually get to keep it, either.)"
src.icon_state = "goat"
if(src == firstChoice)
stayLosses++
else
switchLosses++
stage = 3
else //Restart.
usr << "Game is completed, so restarting now . . ."
return usr.new_game()

Click()
if(stage < 3)
select()
else
return usr.new_game()


Problem description:

All of the relevant code is basically at and before the Door.New() method. When I start the game, all I see is a blank screen. What am I doing wrong?

nvm -_-
In response to Chowder
Chowder wrote:
Just a question..Did you make a map?
and...

obj/Door
var/doorNumber
icon = 'door.dmi'

New()
icon_state = "closed"
return ..()

should be..

obj/Door
var/doorNumber
icon = 'door.dmi'
icon_state = "closed"

Which leads me to belive you didn't make a map o.o

Well, I don't see a locate code anywhere in there.
Add this to your Login().
src.loc = locate(1,1,1) // In X,Y,Z form. You can change it to whatever you want.
In response to Euphemism
That's irrelevant. BYOND automatically locates someone to the closest open turf upon Login() as long as you call the parent/don't override it.


If he has a custom skin, he needs to make sure the map control is set to default.
In response to Jeff8500
I rushed threw with my first one and sounded stuiped so now it says nvm

Anyways...o.o

I ran the code in dm and it was fine so the problem is not in that code do you have anything else that happens on Login then what is shown in your code? By the screen is black your probably in the null void or loc 0 0 0 and you end up there when the login proc dosn't get to finish you could have a curupt savefile and if you have modified move and dont make exceptions for login it will also cause the black screen
In response to Chowder
No, I've seen it in text form, and I exist in a location. I got the doors to exist--but I got a runtime error when clicking on them: "Cannot modify null.icon_state."

The problem may just be that I am running this on Linux Wine.