area
var //declare new area variables
north
south
east
west
Hallway
desc = "A dark hallway. It seems to lead further into the ship."
west = "ElysiumControlRoom"
ElysiumControlRoom
desc = "A ships control room. There is a computer in front of you. Lots of buttons but there seems to be no power. "
south = "SleeperPod"
east = "Hallway"
west = "PowerDoor"
SleeperPod //create a new area prototype
desc = "You awake in a hollow pod. You have zero memory of anything. The pod's doors are open."
north = "ElysiumControlRoom"
1
2
ID:139473
Dec 24 2010, 8:33 pm
|
|
I am trying to define multiple rooms. Whenever I go to 4 rooms it starts giving me indintation errors. I am new at this and I got this code from the tutorial. I really tried my best on fixing it but I still dont know what is wrong. If i am missing anything then please tell me and I will further give any other code.
|
In response to Duelmaster409
|
|
Once again. I told you I am new. I am using that code as a starting. like it told me to do so.
|
In response to Peregrinfin
|
|
Peregrinfin wrote:
Once again. I told you I am new. I am using that code as a starting. like it told me to do so. He means to type it in instead of copying and pasting, because if you copy and paste then often it isn't indented correctly. |
In response to Xyphon101
|
|
I did type it. Multiple times. I do not know what is wrong. Everything works in the code until I try to add a 4th room. Even though its the same the rooms above it says I have indentation errors which makes zero sense to me.
|
In response to Peregrinfin
|
|
It might still be the tabs and spaces, 4 spaces aren't the same thing as one tab though it does look the same...
|
In response to Masschaos100
|
|
Ok now that I re-tabbed everything. it gave me 4 indentation errors. The code is like this
area |
In response to Peregrinfin
|
|
I've yet to see an instance where indentation errors are caused by anything BUT actual indentation errors. You might want to look at your entire codebase and make sure it's all tabbed correctly because INCONSISTENT indentation means it's "not with the flow" to put it in simple terms. You have to make sure all of your code is indented with either spaces or tabs, not both.
|
In response to Duelmaster409
|
|
Ok I fixed the indentation. Thank duelmaster. But now I got some more questions. The problem I have no is whenever I try to space names(showed in the code) it gives me an unexpected end of statement error? Is there a way I can space the names(shown in the code) without getting an error?
Hallway // ERROR HERE ONLY WHEN I TRY TO SPACE THIS NAME |
In response to Peregrinfin
|
|
I'll try and explain why you're getting these errors. I'm not sure if this is covered in the DM Guide.
Indentation refers to the placement of text to the right of other text. In programming languages, this is usually used to format your code, making its structure easily understandable. In DM, indentation also tells the computer itself how to run the code*. I'll assume you know what object or proc declarations are. Basically, the compiler sees any code indented under a proc or object as "belonging" to them. This is how it can tell what you expect of it when you use the object or proc. Because you can indent code in many ways (you can use a space to move it to the right, two spaces, a "tab"), DM can get confused. You are therefore required to have a certain indentation style. An indentation style is basically the what you press on your keyboard to move your code to the right. The indentation style has to be consistent throughout your source code**. The reason you got an indentation error earlier is because your indentation is not consistent with the rest of the code. Dan's tutorial uses "tabs" to indent its code. Tabs look like blocks of 4 whitespaces, but they are treated in a special way by the compiler. As such, 4 spaces and a tab are not considered to be of the same "style". The reason you are getting an error now is because your style is not consistent. You'll note you are using 8 spaces to place your code to the right of the 'Hallway' declaration, but Dan is using a tab. The correct way to format your code would be: <code> Hallway [tab]desc = ... [tab]west = ... [tab]ElysiumControlRoom [tab][tab]desc = ... </code> Which will look like: Hallway You'll note I used two tabs for the last line. This is because that line sets the description of the 'ElysiumControlRoom' prototype, and not the Hallway's. If you look at a couple of source codes, you'll quickly get the hang of it. * there are other ways to do this, but indentation is standard. ** or .dm file, or object declaration, I forget which in particular, but in any case it should always be consistent. *** freaking getting used to BBS HTML equivalent. |
In response to Toadfish
|
|
I found a fix in the reference. being underscores = to spaces but whenever I underscore what I show below it still gives me errors. Is there a fix?
Hallway |
In response to Peregrinfin
|
|
Well, that's why you need to read the DM Guide.
|
In response to Toadfish
|
|
That I did mr. toadfish XD. But the underscore method it shows me doesnt work on the names of the room. It gives me errors.
|
In response to Peregrinfin
|
|
You need to tell me which errors and show me the code you're compiling.
|
In response to Peregrinfin
|
|
elysium_control_room |
In response to Vermolius
|
|
Yeah I found that out yesterday. Now im on how to figure out how to get npcs into a room.
|
In response to Peregrinfin
|
|
Set the loc variable when they are created?
There are better ways to deal with rooms to make it a lot easier to manage, using external files, but there's no point in getting into that now. |
In response to ANiChowy
|
|
you mean putting the rooms coding in its own file? I did that already. But with the loc variable, I dont know what that is. Time to hit the reference book! *EDIT* I looked up the loc var. I need to assign a room id to each room right?
|
In response to Peregrinfin
|
|
Forget about loc. Look at the 'population' var in the reference for Dan's library.
|
In response to Toadfish
|
|
Ok will do.
|
1
2
http://www.byond.com/developer/articles/start