ID:143747
 
Code:
var/level = 1     
mob
var/moves //tracks player moves
var/obj/stone/holding //a variable to keep track of held stones
verb
say(msg as text) //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output


obj //new obj prototype,
stone //a stone,
icon = 'stone.dmi' //with the 'stone.dmi' icon assigned

Click() //overrides its Click() proc
if (usr.holding)
usr.holding.loc = loc //puts held stone on clicked stone's square
usr.moves++ //increments usr's move number
if (ColorChange(usr.holding)) //if ColorCheck() returns 1 to ColorChange()

usr << "You beat the level in [usr.moves] moves!"
usr.moves = 0 //resets move count
level++ //increments the level
Reset()
usr << "Level [level]..."
usr.loc = locate(1,1,level) //relocates the player to new coordinates

else
MoveCheck() //if the game wasn't won, see if it's been lost

usr.holding = null //makes it so usr is no longer "holding" anything

else
loc = null //takes the clicked stone off the board
usr.holding = src //but "remebers" it

..() //calls the parent, just in case

New() //overrides its New() proc
icon_state = pick("color1","color2")//set each stone's icon state randomly

turf
square //defines a "square" prototype, a kind of turf...
icon = 'square.dmi' //and has an icon named 'square.dmi'. In single quotes!

world //we set one of our world's characteristics:
turf = /turf/square //its default turf is the square turf.
New() //overrides its New() proc
for (var/turf/square/T in world) //loops through all squares,
new /obj/stone(T) //putting a stone on each

..() //calls the parent

proc
Cleanup()
for (var/obj/stone/O in world) //loops through all stones
del (O) //deletes each
ColorChange(var/obj/stone/thestone) //takes a stone as an argument
for (var/obj/stone/O in world) //loops through all stones
if (O.x == thestone.x || O.y == thestone.y)
O.icon_state = thestone.icon_state //changes those in same row or column

return ColorCheck(thestone.icon_state) //calls the color checking proc

ColorCheck(color) //takes a color as an argument
for (var/obj/stone/O in view(7)) //loops through all stones
if (O.icon_state != color) return 0 //returns 0 if one is a different color

return 1 //returns 1 if the game is won

MoveCheck()
var/maxmoves //new variable for maximum moves
switch (level) //evaluates the level
if (1) maxmoves = 8 //use whatever maxmoves # you want for each level
if (2) maxmoves = 7
if (3) maxmoves = 6

if (usr.moves == maxmoves)
usr << "You've used up all your moves. Game over!"
Cleanup()

else
usr << "You have [maxmoves-usr.moves] move\s remaining."
Reset()
for (var/obj/stone/O in world) //loops through all stones
del (O) //deletes each
for (var/turf/square/T in world) //loops through all squares,
new /obj/stone(T) //putting a stone on each
..() //calls the parent


Problem description:

it insists upon giving me a runtime error whenever i try to play the game and beat the first level, any help? it is related to my Reset() proc somehow, not sure what is wrong there...
It would help if you copied and pasted the full error.
In response to Naokohiro
runtime error: Cannot execute null.Reset().
proc name: Reset (/proc/Reset)
usr: Square4ever (/mob)
src: null
call stack:
Reset()
Click(the square (3,3,3) (/turf/square))

that is the error it gives when playing the game...
In response to Shardok
    Reset()
for (var/obj/stone/O in world) //loops through all stones
del (O) //deletes each
for (var/turf/square/T in world) //loops through all squares,
new /obj/stone(T) //putting a stone on each
..()//Remove this, because it calls world.Reset()

I think that ..() was trying to do world.Reset() when there are no arguments in Reset(). Therefore it was trying to do null.Reset() and the game doesn't get it. All the stones still probably would have loaded before everything stopped, right?(So remove that "..()")
In response to Naokohiro
"null.Reset()"

This is (arguably) the most common runtime error. You tried to access or modify a var or proc belonging to an object, but the object reference was null. For example, you tried to access O.somevar but the O var was null.

Note that if you're trying to access src.somevar or src.someproc() from within a Del() proc, make sure that your parent call (the ..() line) is at the end rather than at the beginning, or src will be deleted before try to you access src.somevar or call src.someproc(). Also note that src.client is sometimes null in mob/Logout(); try using client/Del() instead of mob/Logout() if you need to access anything belonging to the client.

This often happens when you set up a proc to receive an argument, but when you call it forget to pass that argument in. DeathCheck() procs commonly experience this problem.

In response to Naokohiro
it didnt work... it just stops it from using the reset proc which is not what i wanted and allows them to continue after losing...
In response to Smokey Joe
couldnt quite understand ya, smokey...
In response to Shardok
Well lets see.
Lets say you have variable x, which is var/mob/x.

What is happening is your calling the Reset() proc to x (x.Reset()) when x = null.

Make sense?