ID:279743
 
Note: This opening post is just a copy and paste from the dead BYOND Bwicki; information has been recovered via the Wayback machine. Feel free to add your own entries for errors/warnings, and how to fix them. BYOND moderators, feel welcome to fix any errors in this post pointed out if I don't edit them.



the "»" symbol within DM tags represents an indentation.

Dream Maker Error Code Listing


Listed below are the error codes from Dream Maker, if you see someone asking a question in the forum or elsewhere for an error, post the fix you gave here under the error code itself. Over time it is my hope that people can be referenced here to just look up error codes they get in Dream Maker, by Error code, and find a solution to their problem.





error: expected a constant expression

Problem: Trying to assign a variable with a random result at compile-time
Example: mob/var/hitpoints = roll("2d4")
Fix: It's not a constant value that can be calculated at compile-time. Hence the error. To fix the problem, you need to set the variable at run-time; the easiest way to do this is inside the New() proc (which belongs to all objects in the DM programming language)
mob
» var/hitpoints = 0 //placeholder value

» New()
» » ..() //Perform default New() procedure (almost always necessary!)
» » hitpoints = roll("2d4") //When mob is created, assign random value to hitpoints var

This is also a common mistake with strings. You can't use brackets to include another value at compile-time, like so
mob/icon_state = "[class]"


error: [variable name] :duplicate definition

Problem: Declared the same variable twice.
Example:
mob/var/a

mob
» Login()
» » ..()
» » world<<"[src] says \"Howdy.\""
» var
» » a
» » b
» » c

Fix: Delete or change the name of one them
mob/var/a2

mob
» Login()
» » ..()
» » world<<"[src] says \"Howdy.\""
» var
» » a
» » b
» » c


error:: Inconsistent indentation.

Problem: Failing to correctly indent a line where it is an obvious error.
Example 1:
mob
» » verb/Hi()
» » » // Code goes here.

Example 2: [note: In this case, _ represents a space ( )
mob
» _verb/Hi()
» » // Code goes here.

Fix: Go over the block of code that the error leads to. Try scanning upward from there. On every line, delete all of the tabs and spaces and re-indent it to its proper level -- make sure you understand what proper indentation is, though! The above example should look like
mob
» verb/Hi()
» » // Code goes here.


Dream Maker allows you to use either tabs or spaces for indentation. The only requirement is that you be consistent for any given block of code. If you prefer to use 3 spaces instead of tabs, DM will let you, but you can't mix and match them within any already indented block of code. Use Ctrl+T in the editor to make tabs and spaces visible, which will make it easier to spot stray spaces in your code.

error: [variable name] :invalid variable name: reserved word

Problem: Your trying to name a variable the same as one of BYOND's reserved words.
Example:
mob/var/if

Fix: Just change the name of the variable, if you really like the name you can just put an underscore in front of it
mob/var/_if


error:: missing comma ',' or right parenthesis ')'

Problem: One line of code is missing one of the two above symbols. Also note that the line the error message is reported on is usually the line following the error, not the line the error appears on!
Example:
mob
» var/strength = 50
» var/toughness = 64
» var/hitpoints = 0 //will be filled in at run-time (in New())
» var/stamina = 0

» New()
» » src.hitpoints = 25*(strength**(toughness-32) + 64
» » src.stamina = 5*hitpoints
» » ..()

Fix: Locate the line above the line that the error is reported on, and count each parenthesis. For every left parenthesis "(", mentally increase a number by one. For every right parenthesis ")", mentally decrease that number by one. By the time you reach the end of the line, your number should be zero. If not, you'll have to figure out where you need to put the parenthesis
» New()
» » src.hitpoints = 25*(strength**(toughness-32) /*add one paranthesis-->*/ ) + 64
» » src.stamina = 5*hitpoints
» » ..()


error: No such node: mob/var/[number]

Problem: You have a variable that's name starts with a number.
Example:
mob/var/1_Piece_Of_Pie

Fix: Make sure the number isn't the first character of the variable name
mob/var/_1_Piece_Of_Pie


error: proc definition not allowed inside another proc

Problem: A proc or verb has been defined inside another proc or verb. The line the error message is reported on is usually a line below the real error for this one as well.
Example:
mob/verb
» Say(msg as text)
» » if(msg)
» » » view()<<"[usr] says \"[msg]\""
» » Shout(msg as text)
» » » if(msg)
» » » » world<<"[usr] shouts \"[msg]\""

Fix: This one should be obvious once you get the error, just un-indent the proc or verb to the correct spot
mob/verb
» Say(msg as text)
» » if(msg)
» » » view()<<"[usr] says \"[msg]\""
» Shout(msg as text)
» » if(msg)
» » » world<<"[usr] shouts \"[msg]\""

This is often caused by an indentation error as well. If the indentation looks correct like the second part of this example, then there's probably a mix of tabs and spaces in the indentation. Press Ctrl+T in the editor to see them.


error: Undefined variable

Problem: Most often, this happens when you didn't tell DM that the var you were using should be a certain type.
Fix: Change the var's type, or create a new var with the type you want to use.
Example:
mob
» var/hp = 20

» verb/Attack(M as mob in oview(1))
» » if(!M) return
» » M.hp -= rand(3,8)
» » M. DeathCheckusr)

Here M is never defined as a /mob type. The "as mob" clause only limits Dream Seeker to choosing mobs, but Dream Maker doesn't automatically expect M to be a /mob. The solution is to define M as mob/M. Although you can use the : operator to get out of this, it's sloppy. You should use a technique called type casting to avoid the problem.
Example:
mob/player/var/kills = 0

mob/creature/verb/Kill()
» set src in oview(1)
» var/mob/player/M = usr // this is type casting
» ++M.kills // usr is /mob, but M is /mob/player
» del(src)

If you try to change usr.kills directly here, you'll get the error because usr is always a /mob type as far as Dream Maker is concerned. usr's actual type may really be /mob/player, but since DM doesn't know that in advance, it assumes usr is a generic mob. ++usr:kills would have worked, but ++M.kills is a much cleaner solution.

error: compile failed (possible infinite cross-reference loop)

Problem: Usually this happens because you're using a var the same place you first define it.
Fix: Define the var first, then change it.
Example:
var/thing = "This is a [thing]."

That line is prefectly legal without the var/ part, if thing is defined somewhere else.
var/thing = "duck"
thing = "This is a [thing]."









Dream Maker Warning Code Listing



Listed below are the warnings from Dream Maker, if you see someone asking a question in the forum or elsewhere for an error, post the fix you gave here under the error code itself. Over time it is my hope that people can be referenced here to just look up warnings they get in Dream Maker and find a solution to their problem.




Warning: empty switch statement

Problem: The choices of the switch statement has not been correctly indented.

Example:

mob/proc/gender()
» switch(input(src, "What is your gender?","Gender") in list("male","female"))
» if("male")
» » gender="male"
» else gender="female"


Fix: Indent the choices in
mob/proc/gender()
» switch(input(src,"What is your gender?","Gender") in list("male","female"))
» » if("male")
» » » gender="male"
» » else gender="female"



[variable] :warning: variable defined but not used

Problem: The variable shown is not being used (does not matter if it was defined).

Example:

mob/proc/gender()
» var/name2="LoL"
» var/gender2=input(src, "What is your gender?","Gender") in list("Male","Female")
» gender=ckey(gender2)

Note that name is defined but nothing is done with it.

Fix: Use OR delete the variable.
mob/proc/gender()
» var/name2="LoL"
» var/gender2=input(src, "What is your gender?","Gender") in list("Male","Female")
» gender=ckey(gender2)
» name=html_encode(name2)




Note: This opening post is just a copy and paste from the dead BYOND Bwicki; information has been recovered via the Wayback machine. Feel free to add your own entries for errors/warnings, and how to fix them, in the form of a new post. BYOND moderators, feel welcome to fix any errors in (or add anything to) this post.
This error signifies something has gone amiss in one of the associations that make up the map's array. Generally if you've removed a set variable or an icon file has gone missing.
Funnily enough, there's also a length limit of procs. Nice sticky though. Now if we could somehow combine the run-time and compile-time errors into one big post...
Oh! My mistake, I was thinking of another error that pertains to maps.

BYOND has an object* limitation of 256^2 (65,536) at compile time, though at run time you can have up to 256^3 (16,777,216) objects present. Objects that qualify for these limits are objs, mobs, datums, and lists.

Turfs and objs are two very different objects, yes. Turfs represent static backgrounds and should be used if a background object does not require movement. Objs on the other hand tend to be for interactive things, items, they can be used for on-screen menu displays, etc. Since they also inherit from /atom/movable, objs can move.

* An object is not the same as a class of type /obj. Object refers to an instance of a class.

Edit: Mixed up run time and compile time. Thanks for pointing that out Kaiochao!
Fairly certain it is for the entire game.
I've put this resource into a Google Document, where a select handful of people have access. They can help with updating it, and styling, and whatever.

It's available here, embedded into the page:
http://files.byondhome.com/SuperSaiyanX/CompilerErrors.html