ID:2114049
 
(See the best response by Lummox JR.)
Code:


Problem description:
Following http://zilal.byondhome.com/tutorials/zbt.html guide and i'm at the part where i'm supposed to test out the bug and kill it. but it's not appearing on my map or my tree? I have gotten this problem before when i was learning how to code. But I can't remember how to solve this problem. thanks

edit: Where can i post a copy of the project so you guys can help me out?

You don't need to post the whole project, simply post the code that's giving you a problem within your post surrounded by <DM> tags.
// Assume mob is on the line below,
// otherwise this snippet is questionable.
// ...
bug //new prototype
icon = 'bug.dmi' //override the parent's icon, which was 'person.dmi'


The above is the snippet from the tutorial with a comment of my own added at the top.

Your problem is caused by the fact that you have not defined your new mob/bug type, or defined it wrong.

Take this example where I define a new obj type, fruit:

obj
fruit
icon = 'fruit.dmi'


In the snippet above, I override the default characteristics given to /obj instances and provide my fruit type with appropriate information -- in this case, the fruit.dmi icon.

Let's say I wanted to get more specific and add in some fruits.

obj
fruit
icon = 'fruit.dmi'
apple
icon_state = "apple"
pear
icon_state = "pear"
banana
icon_state = "banana"


Again, I set the default characteristics for my new fruit obj prototypes, apple, pear, and banana. Their icon was already set appropriately because they inherited that information from their parent type fruit. So in this case, all I needed to do was specify which icon_state they should use from the parent's icon so that they appear correctly in-game. Had I not done this, they would default to using the last (if I remember correctly) blank state in the icon.

All of these objects are going to appear in the map editor as they should because they have been defined in the code.
mob
icon= 'person.dmi' //make it so that all mobs will be created with the person icon.
var
HP =30 //Declares a new variable called HP, with a value of 30.
wealth
bug // new prototype
icon='bug.dmi' //override the parent's icon, which was 'person.dmi'
Del()
var/obj/gold/G=new(loc) //create a new obj from the gold blueprint
G.amount = rand(1,100) //set its amount variable randomly
..() //call the parent

This is the code. I'm not getting errors. all i'm getting is a grey box where the icon should be.
What do the icons look like? If you have state names set you'd need to use those as icon_states. Sounds like that's what happening, as it's compiling to the point of actually showing the type in the tree, it boils down to the icon not being set up correctly.
Fixed it. I guess adding a name confuses the engine? first add icon_state to the code for the icon then saw it appear. So i looked back and realized i didn't have a name for my grass so i guess that's where i went wrong. With that being done i have finished this introductory guide. Do you guys know how i can learn more things? this is my first language and i'm lost as to where i should start.
I don't understand your explanation of what was wrong. In other words, it doesn't make much sense. Mind showing the working code so one of us can point you to what the problem actually was? I would avoid dismissing problems even when they seem to have fixed themselves -- especially during the learning phase. They could easily occur again (and very likely will).

As for making progress in learning DM: I think you are starting out nicely by going through that tutorial (though it could use some updating).

Continue familiarizing yourself with the engine and the language, and also don't be afraid to ask questions as you did in this topic. Get comfortable writing in DM and slowly work toward your goals. Do not rush yourself, focus more on being consistent in your practice. Additionally, try to work within your ability scope -- which brings me to my next point.

You mentioned in another topic that you want to create a "big game". Grand ideas are good to have, but it's important to realize your own capabilities and start at an appropriate "start point" in order to reach your goals. So if a big game is your goal, I'd suggest breaking this game down into smaller components and tackling things slowly, making sure you grasp the concepts involved.

There are some developers here who take the mini-game approach and create small games that implement a single concept that they are considering for a larger game. Not only does this help them learn technique, it gives them an idea of how it will play out in a larger environment.

Be patient with yourself, and like I said, be consistent. Building a game, especially a big one, won't happen quickly. Just do what's within your ability to move forward and you will reach your goals. This forum is usually active so do use it when you need assistance. Google is also a valuable resource to learn pretty much anything related to topics from programming to game design.
In response to FKI
FKI wrote:
I don't understand your explanation of what was wrong. In other words, it doesn't make much sense. Mind showing the working code so one of us can point you to what the problem actually was? I would avoid dismissing problems even when they seem to have fixed themselves -- especially during the learning phase. They could easily occur again (and very likely will).

As for making progress in learning DM: I think you are starting out nicely by going through that tutorial (though it could use some updating).

Continue familiarizing yourself with the engine and the language, and also don't be afraid to ask questions as you did in this topic. Get comfortable writing in DM and slowly work toward your goals. Do not rush yourself, focus more on being consistent in your practice. Additionally, try to work within your ability scope -- which brings me to my next point.

You mentioned in another topic that you want to create a "big game". Grand ideas are good to have, but it's important to realize your own capabilities and start at an appropriate "start point" in order to reach your goals. So if a big game is your goal, I'd suggest breaking this game down into smaller components and tackling things slowly, making sure you grasp the concepts involved.

There are some developers here who take the mini-game approach and create small games that implement a single concept that they are considering for a larger game. Not only does this help them learn technique, it gives them an idea of how it will play out in a larger environment.

Be patient with yourself, and like I said, be consistent. Building a game, especially a big one, won't happen quickly. Just do what's within your ability to move forward and you will reach your goals. This forum is usually active so do use it when you need assistance. Google is also a valuable resource to learn pretty much anything related to topics from programming to game design.

Yeah basically I wanted to know where I should start since this language can be pretty challenging. I looked at the tutorial/snippets and it seems like really complex stuff should i start there? sorry if im repeating im just really confused as to where to start first. lol

also the code is a direct replica of the guide with no errors, aside from realizing what the problem is, i don't really know how i can explain to you what i was talking about lol i could copy and paste the code but that would seem redundant?
In response to FKI
In response to SigmaWolf
Yes.
In response to SigmaWolf
Best response
SigmaWolf wrote:
Fixed it. I guess adding a name confuses the engine? first add icon_state to the code for the icon then saw it appear. So i looked back and realized i didn't have a name for my grass so i guess that's where i went wrong. With that being done i have finished this introductory guide. Do you guys know how i can learn more things? this is my first language and i'm lost as to where i should start.

I think what you're saying is you gave a name to the bug's icon in bug.dmi. That is, instead of leaving the icon with a blank state name, you may have called it "bug" or something.

In general, you want to make sure that when you give an object an icon, that the icon_state var (it defaults to blank) matches up with the individual icon state in that file that you want to show. For instance, a player icon might have a blank state that's the default, and it might then also have icons like "death" and "attack" and "hurt" to show various other states/poses.
In response to Lummox JR
I see what you're saying Lummox, thanks.

Another question I have is i just made a new branch in the obj tree and put sword. the code looks like this:

sword
icon='sword.dmi'
density=1
verb
get()

usr<<"you pick up the sword."

When i compile and run it doesn't show the sword on the map after i plant it on the turf. edit:fixed it, But i want to be able to pick the sword up and have it dissapear? what am i missing in my code for that to happen?

Also how do i make extra verbs like laughing,get,cry etc.
Also this code i just typed
turf
wall
icon='wall.dmi'
density=1
but i get the error saying it cannot find the file even though I have a wall.dmi? any explanation to this?
You should put your code inside <dm> ... </dm> tags so the indentation is clearer.

If you wanted to make a get() verb work, what you have to do is add this line:

loc = usr

That says src.loc, src being the sword, is changed to usr--the player who initiated this verb. In other words, src is put into usr's contents.

The missing wall.dmi file case sounds very strange. Is the icon perhaps in a subdirectory, not in the main project directory? If so, you'll need to go to the Buld menu and turn on a setting in the project preferences to automatically set FILE_DIR. That will allow the compiler to search all subdirectories for the file.