ID:164845
 
Learn how to program in Dream Maker, they said. It's fun and not too complicated, they said. I'm finding Dream Maker to be more complicated than C++ itself, which is saying something. A very, very big something.

I need tips. I need them badly. I need to find some way, first, to stop my code from becoming a mishmash of jumbled things all over the place as I set different procs and try to fumble my way through making the procs I need for certain situation, encountering 1238513831 seperate errors because of one thing or another. Not just mispellings. I mean, it's amazingly picky - variables have to be defined within brackets within brackets within brackets within brackets within brackets, and if you miss so much as one tab you can spend hours trying to figure out what you did wrong. I have tried both starting from scratch and building from Step BYOND, but all these complicated verb and var forms make my head spin. I always end up getting something wrong.

What really frustrates me is the fact that the error messages are so vague. I have not gotten a single parse error that accurately stated itself as such - just confusing sentence after sentence that gives me no real insight into the problem itself. When I try to define vars, it gives me warnings about how I've defined them but not used them - and then later down in the code, when I'm USING THAT SAME VAR IN THE SAME SECTION OR IN A DIFFERENT SECTION WITH THE APPROPRIATE REFERENCE TO THE VAR'S SECTION, it says I haven't defined that variable. I have. The one time I managed to fix this, it was because I accidentally inserted a new tab into the equation - which somehow got the thing working. How, I will never know and have pulled my hair out trying to figure out.

I know I'm being vague and you can't really help me with all these minor hassles which I'll probably figure out myself. But right now, I really need some help with certain things:

1. Understanding vars, what is the EXACT formulation for accessing a var in a different place (for instance, accessing an obj var from the mob section)
2. How exactly to make my procs all nice and neat, and more importantly, how to get these procs to work right instead of giving me a thousand seperate errors to the point where I just double back on using the original, which is so incredibly limited I get even MORE errors trying to implement it the way I want before I realize it won't work. Rinse and repeat until I have no hair left to lather.
3. Ideas for making random generation systems. More importantly, how to modify the if proc to give me more than just a true/false, but let me identify a variable's exact value and then act if it's a certain number. For instance, if it's 10 I want a certain thing to be displayed, if it's 9 I want something different, if it's 8... you get the picture.
4. How the heck do you make icons draggable?
5. I don't quite understand how to change the variables for a specific instance of an object, either. Whenever I try to do it it ends up changing the variables for _all_ the objects in existance, either that or I get something so hopelessly messed up with all the [src]/obj/whatever/somethingelse if rawr etc.
6. No tutorial I have seen covers how to make an area. Could use some help on this.
7. I don't really understand how to order things in the proper... well, order. Can I have multiple obj, mob, etc tags all over the place, so I can define variables for one section, move on to another so I can use that part to set the variables in the PREVIOUS section, then go back to define more variables if something happens?

I might be so confused I'll need someone to walk me through, step by step, the basic tutorials once _again_ so that I can understand all the nuances, because my understanding of the system seems... flawed, at best. I really want to code for BYOND, but alas... maybe it isn't for me...
Jetman123 :
> What really frustrates me is the fact that the error messages are so vague. I have not gotten a single parse error that accurately stated itself as such - just confusing sentence after sentence that gives me no real insight into the problem itself.

Yeah, for some of them, you just have to memorize what it's saying. I like the "warning, empty else clause" the best - it means often that you missed parentheses on some for or if statement way above the else in question.

> 1. Understanding vars, what is the EXACT formulation for accessing a var in a different place (for instance, accessing an obj var from the mob section)

You use the . operator, as in:
obj/var/value = 0
mob
verb
accessInventoryValues()
for(var/obj/K in src.contents)
src << "[K]: [K.value]"

You find a way to isolate the object in question, store it as a variable, then use the "." operator. Beware, though: If a variable is defined under a daughter class of obj and the variable it's stored in is var/obj/K, you won't be able to access daughter class variables. You'd have to define the variable as var/obj/ObjType/K - in other words, be specific in defining a variable for this purpose.

C++ can do something similar with objects, but it's more popular in Java.

2. How exactly to make my procs all nice and neat, and more importantly, how to get these procs to work right instead of giving me a thousand seperate errors to the point where I just double back on using the original, which is so incredibly limited I get even MORE errors trying to implement it the way I want before I realize it won't work. Rinse and repeat until I have no hair left to lather.

Post the proc you have the most trouble with in the "Code Problems" forum. Barring that, be sure to:
  • Define variables correctly and in the right place for what you want - for example, don't expect for a variable defined in a loop to be usable outside the loop.
  • Avoid the use of the usr operator in procs.
  • Since you come from C++ (As do I, and I'll do this), check to be sure you aren't substituting C++ code for DM code. (You have no idea how many times I accidentally define vars with int, bool and char)

    3. Ideas for making random generation systems. More importantly, how to modify the if proc to give me more than just a true/false, but let me identify a variable's exact value and then act if it's a certain number. For instance, if it's 10 I want a certain thing to be displayed, if it's 9 I want something different, if it's 8... you get the picture.
mob
verb
RollD6()
var/Guess = input("What's your guess?", "Roll a die") as num
if(Guess > 6)
usr << "Invalid guess."
return
var/Roll = rand(1,6)
if(Roll == Guess)
usr << "Good guess."
else usr << "You have guessed poorly."

Would that be what you are looking for?

Also, you can use something like this to create a long list of actions dependent on a single random value.
var/K = rand(1,50)
switch(K)
if(1)
// whatever you want to do if K is 1
if(2 to 8)
// whatever you want to do if K 2,3,4,5,6,7,8
if(9)
// whatever you want to do if K is 9
// and so on



> 5. I don't quite understand how to change the variables for a specific instance of an object, either. Whenever I try to do it it ends up changing the variables for _all_ the objects in existance, either that or I get something so hopelessly messed up with all the [src]/obj/whatever/somethingelse if rawr etc.

Hmm... I'd like to see some code on that. Simplify it, please - I don't need to see the parts that don't pertain to this problem.

> 6. No tutorial I have seen covers how to make an area. Could use some help on this.

area
SpecialArea
Entered(mob/M)
M << "Welcome, [M], to a special area."

You just paint them on the map after you code them. The code is remarkably similar to other types of atom.

> 7. I don't really understand how to order things in the proper... well, order. Can I have multiple obj, mob, etc tags all over the place, so I can define variables for one section, move on to another so I can use that part to set the variables in the PREVIOUS section, then go back to define more variables if something happens?

You can't define more variables for an atom conditionally. You can set the variables you have whenever, but you can't create new vars for anything unless it's in that atom's code.

> I might be so confused I'll need someone to walk me through, step by step, the basic tutorials once _again_ so that I can understand all the nuances, because my understanding of the system seems... flawed, at best. I really want to code for BYOND, but alas... maybe it isn't for me...

If you learned C++ prior to learning DM, that put you a few steps ahead of people who try DM as their first programming language. I suggest:
  • If you haven't already read the DM Guide, it's be a good idea to at least take a look.
  • Check the DM Reference entry on built in procs you are having trouble with. It's a hard read, but I find it's a good reference, especially with the magical Ctrl-F hotkey. Don't even think about trying to read it through, though.
  • Watch these forums for problems you have, most problems encountered by newer programmers are repeated on the forums often.
  • Don't be afraid to post some of your most frustratingly hard-to-fix code in "Code Problems", but try to keep the total amount of code per post down to a minimum - I'm sure I'm not the only one that skips over the really long code.


    --Vito
In response to Vito Stolidus
Thanks! I'll give the tips you've shown a try, and I'm sure it will improve the general quality of my code quite a bit. I did learn C++, though only the basics, and I still am learning it as a matter of fact - it's really just the nuances of the new system that confused me, since it's the same as C++ in some areas and radically different in others.

I'll try to code some more, but unfortunately the project I was having trouble with I can't find. Ah well. If I'm having any more persistent problems, I'll make sure to post them here!

I really appreciate the helping hand, and I'll definitely check out the places you mentioned more. I went through all the tutorials and thought I understood it, but like I said... I think I lost a few things in translation. :/
In response to Jetman123
Honestly I found this to be much more simple than C++. I picked this up much faster.
In response to Pyro_dragons
DM is a lot easier imo. It's a lot harder to "break". C/C++ are very picky. DM is not which is nice, but also makes it easier to make dumb mistakes.
Sorry if the following may seem rude or mean, but-

Jetman123 wrote:
Learn how to program in Dream Maker, they said. It's fun and not too complicated, they said. I'm finding Dream Maker to be more complicated than C++ itself, which is saying something. A very, very big something.

Yes, it says you're a bad learner, or not learning correctly. :O And you're whining about doing mistakes, which everybody does. Calm down, and take it easy. Learning and getting used to stuff takes time. Also, don't jump right in - learn to swim first.

I need tips. I need them badly. I need to find some way, first, to stop my code from becoming a mishmash of jumbled things all over the place as I set different procs and try to fumble my way through making the procs I need for certain situation, encountering 1238513831 seperate errors because of one thing or another.

Well, yeah, way too vague. The only answer for that is, learn to [DM] code properly

I mean, it's amazingly picky - variables have to be defined within brackets within brackets within brackets within brackets within brackets,

What? Actually, Dream Maker is mostly very flexible.
And defining variables doesn't require any type of brackets...

and if you miss so much as one tab you [...]

Er, what would you expect? Dream Maker uses indentation to group blocks of code (which is damn convenient, consider most people use indentation anyway in compilers that aren't that way) - of course it may not work if you do that incorrectly. The same with C, you'll also have a problem if you use the braces incorrectly (and BTW, Dream Maker DOES support C).


What really frustrates me is the fact that the error messages are so vague. I have not gotten a single parse error that accurately stated itself as such

True, sometimes the compiler confuses errors or is inaccurate with them, mainly with parse errors, but if you take the time to properly learn the syntax and usage first you won't have a problem with that. Also, the compiler pretty much always outputs the correct error line (which note, may be a line above or before where the actual line with the mistake is, depending on the code and error).

- just confusing sentence after sentence that gives me no real insight into the problem itself.

The error messages make sense once you've delved deep enough into the language; if you're having trouble deciphering them, a quick [forum] search for them will yield more info about them.

When I try to define vars, it gives me warnings about how I've defined them but not used them - and then later down in the code, when I'm USING THAT SAME VAR IN THE SAME SECTION OR IN A DIFFERENT SECTION WITH THE APPROPRIATE REFERENCE TO THE VAR'S SECTION, it says I haven't defined that variable. I have.

Well, with those 2 errors, it depends on your code. Dream Maker may very well be right after all; you may be not understanding what exactly your particular code does/how it works. Getting confused with one of them is pretty common, and I can also see situations you could get so with the other.


1. Understanding vars, what is the EXACT formulation for accessing a var in a different place (for instance, accessing an obj var from the mob section)

<small>lal, 'formulation'</small>
Well, see, that question shows you need to grasp a better general understanding of the language (and what those 'sections' are) before having a go with it.

2. How exactly to make my procs all nice and neat

Heh, again, don't delve too quickly. First learn how to actually use the language and feel comfortable with it before you want stuff 'nice and neat'.

[...]

Well, the rest there is too vague, yes.

3. Ideas for making random generation systems.

Well, the basic thing is to look up randomization functions in the DM Reference, but really, see the previous point - don't dive right in.

More importantly, how to modify the if proc

Right, well, you don't modify the if() "proc", as you know. Try to word your questions better.

to give me more than just a true/false

'True' can be an infinite range of values -- see, this is also where you need to learn more about the language first.
What you're doing is alike to asking questions in the middle of a lecture, before the lecturer got to that part (yas, of course thats why they say to ask questions at the end).

but let me identify a variable's exact value

Um.. can you get more basic than that? Have you actually tried to learn first... Unless you mean something different, this is simply using the '==' comparison operator.

4. How the heck do you make icons draggable?

Well, again, too vague, though I guess you mean atoms. In case you're not, what icons?

5. I don't quite understand how to change the variables for a specific instance of an object, either. Whenever I try to do it it ends up changing the variables for _all_ the objects in existance,

Again basic... as implied above, obtain a reference to that object, then use the '.' operator on it (make sure its defined as the correct type, that has the variable or proc you're trying to access, or else it won't compile).

6. No tutorial I have seen covers how to make an area. Could use some help on this.

Making them is in fact as implied, same as making other atoms, or more closely, same as making turfs. The actual results are different of course, which is what you should learn about if you haven't yet.

7. I don't really understand how to order things in the proper... well, order. Can I have multiple obj, mob, etc tags all over the place, so I can define variables for one section, move on to another so I can use that part to set the variables in the PREVIOUS section, then go back to define more variables if something happens?

What do you mean by 'tags'. Again you need to learn about 'sections' (it'd also help to know for sure what you're referring to by that).

I might be so confused I'll need someone to walk me through, step by step, the basic tutorials once _again_ so that I can understand all the nuances, because my understanding of the system seems... flawed, at best.

Re-learning it "from scratch" now will be wise, yes.

I really want to code for BYOND, but alas... maybe it isn't for me...

Well, as said, it IS waay simpler than C++, so you should get the hang of it well enough eventually. Just, again, learn in slow, baby steps, and learn first before attempting things.

P.S: avoid ripped sources like the plague; you'll learn bad practices from them, if anything. If you don't know what they are, basically - anime game sources posted around here.
In response to Vito Stolidus
Vito Stolidus wrote:
  • Check the DM Reference entry on built in procs you are having trouble with. It's a hard read, but I find it's a good reference, especially with the magical Ctrl-F hotkey.

    An important thing to note that the DM Ref is very easily and conveniently accessible by pressing F1 in Dream Maker, and that you should always make sure you've looked up things (procs,operators,vars) you're using.

    Don't even think about trying to read it through, though.

    Actually, doing so would be pretty wise, akin to reading the DM Guide. You'll gain knowledge on how to do things, the built-in functions, tricks about the language and it's usage and whatnot.
  • Watch these forums for problems you have, most problems encountered by newer programmers are repeated on the forums often.

  • Yeah - to emphasis on that - when you have a problem, search first. Its likely been answered (multiple times) already.
  • Don't be afraid to post some of your most frustratingly hard-to-fix code in "Code Problems", but try to keep the total amount of code per post down to a minimum

  • Yeah, also make sure to post relevant details; what is the problem, what do you want the code to actually do, what you've tried, your code (yes, some people omit that..), the lines compile/runtime errors occur on (if any), etc.

    - I'm sure I'm not the only one that skips over the really long code.

    cough. You're not. >_>
Make sure you dont use one big code file. I have 30 of them. Sure, alot, but it is very organized.
In response to Revojake
Revojake wrote:
Make sure you dont use one big code file. I have 30 of them. Sure, alot, but it is very organized.

Whoa! I don't agree with those last sentences! Sure, you should have multiple files to make it organized. But 30?! (damn I hope your game is already in a complete state :P) Thats far from organized - its overdone.