ID:138778
 
Code:
mob/verb/make_potato()
set src in view()
name = "potato"
desc = "Mmm. Where's the sour cream?"
icon = 'items.dmi'



Problem description:
As the title states "learning". I am under the impression that this should be able to change someone in your view to a potato; correct me if I'm sadly mistaken. I have been around BYOND for 5 years under a previous key, and I just mustered up the motivation to kick my rear to learn and comprehend the language. So my situation is I do compile frequently which in my outlooks is a good habit to have as a programmer. After compiling this portion I run and test what I added to the game. I hit the command it turns me into a potato. I am trying to understand why. I'm guessing since there are no other users it just turns me into a potato. What would be causing that? My main theory is no other users and it checks for the next best thing to turn into a potato. I see nothing wrong with the code, but again I'm learning since I gave ya'll a simple code right out the byond guide so if you would direct me in the right path to fix this little mishap I'd appreciate it. If you are not busy and wouldn't mind tutoring me I rather learn from someone who is experienced and has good habits. As I have a game in idea to make, but I lack experience in programming so before I even attempt a shot at the game I want to produce I must build my experience so I'd appreciate all the help and tutoring I can get.

Sincerely,
ECA

It is because you didn't specify what the verb should effect. In the brackets, you insert what is known as an argument. You put like this

mob/verb/make_potato(var/tmp/victim) //you can change victim for whatever you want, you define what the argument is called. tmp makes it a temporary variable that wont save, saving space and preventing lag.
set src in view() //this code is only needed if the verb is attatched to something other than a player. You have coded it so the player always has this verb, so you don't need to have this.
victim.name = "potato" //you put victim. so whoever you choose the "victim" is will be effected.
desc = "Mmm. Where's the sour cream?"
victim.icon = 'items.dmi'

Hope this helps.
In response to Jin150
Jin150 wrote:
It is because you didn't specify what the verb should effect. In the brackets, you insert what is known as an argument. You put like this

> mob/verb/make_potato(var/tmp/victim) //you can change victim for whatever you want, you define what the argument is called. tmp makes it a temporary variable that wont save, saving space and preventing lag.
> set src in view() //this code is only needed if the verb is attatched to something other than a player. You have coded it so the player always has this verb, so you don't need to have this.
> victim.name = "potato" //you put victim. so whoever you choose the "victim" is will be effected.
> desc = "Mmm. Where's the sour cream?"
> victim.icon = 'items.dmi'
>
> Hope this helps.
>

Ahh, appreciative, sorry I am still learning like I said. I have not got to the part about arguments in the DM guide and thats where the snippet of code comes from. They portrayed as if what is there would be what is needed to turn someone into a potato.
In response to EclipseCovertAgent
Yeah the DM guide is pretty confusing. I've read that thing 9 times dude, never once finishing it, because it just confused me more each time. A good way to learn is looking at other game's code whilst reading the guide so you can see how the different code can be used in a practical sense, and using the built in reference in the Dream Maker (Press F1 to bring it up).
In response to Jin150
Jin150 wrote:
Yeah the DM guide is pretty confusing. I've read that thing 9 times dude, never once finishing it, because it just confused me more each time. A good way to learn is looking at other game's code whilst reading the guide so you can see how the different code can be used in a practical sense, and using the built in reference in the Dream Maker (Press F1 to bring it up).

Appreciate it. May I ask which source you would reference, because one my closest friends used zilals tutorial source. I'm well aware of the f1 reference I do use it to help me as much as possible.
In response to EclipseCovertAgent
Personally I used http://www.kujila.com/byond.html scroll to the bottom, he has several sources to download. Some of them aren't coded too greatly, but it helps having any form of game to reference when codeing. Hope they help, and good luck learning ^_^
In response to Jin150
Jin150 wrote:
Personally I used http://www.kujila.com/byond.html scroll to the bottom, he has several sources to download. Some of them aren't coded too greatly, but it helps having any form of game to reference when codeing. Hope they help, and good luck learning ^_^

Once again appreciative of this. I hope they help to!
mob
verb // defining a verb
make_potato() // name of the verb
set src in view() // view() returns a list of objects in view of usr.
// When you click this verb, you are usr.
// src is chosen from the mobs in your view.
// If you're the only mob in your view, it'll
// automatically pick you without any dialog necessary.

name = "potato" // set the name of src

// another way of writing the line above:
src.name = "potato"

desc = "Mmm. Where's the sour cream?" // of course, this sets src's desc variable.

icon = 'items.dmi' // this will set your icon to the file.

/*
Your code doesn't really specify the icon_state. If you have
an icon ('items.dmi') with an icon_state called "potato", then
src will not appear as a potato.
*/

icon_state = "potato" // this would fix that.


I started out by looking at demos and libraries. Whenever I saw an unfamiliar variable or proc, I'd first check the DM Reference by hitting F1 in Dream Maker. If it's not in there, it's probably inside the library/demo's documentation/readme if it's a good resource.
In response to Kaiochao
Kaiochao wrote:
> mob
> verb // defining a verb
> make_potato() // name of the verb
> set src in view() // view() returns a list of objects in view of usr.
> // When you click this verb, you are usr.
> // src is chosen from the mobs in your view.
> // If you're the only mob in your view, it'll
> // automatically pick you without any dialog necessary.
>
> name = "potato" // set the name of src
>
> // another way of writing the line above:
> src.name = "potato"
>
> desc = "Mmm. Where's the sour cream?" // of course, this sets src's desc variable.
>
> icon = 'items.dmi' // this will set your icon to the file.
>
> /*
> Your code doesn't really specify the icon_state. If you have
> an icon ('items.dmi') with an icon_state called "potato", then
> src will not appear as a potato.
> */

> icon_state = "potato" // this would fix that.
>

I started out by looking at demos and libraries. Whenever I saw an unfamiliar variable or proc, I'd first check the DM Reference by hitting F1 in Dream Maker. If it's not in there, it's probably inside the library/demo's documentation/readme if it's a good resource.

aha simple mistake of course. I didn't realize I forgot to add the icon state , that would explain why I was invisible when I used the verb. I kinda presumed in my theory it would pick me since there are no other mobs in view. Appreciate the help and tips to help me with learning the DM I'm going to finish reading the guide and read a tutorial a friend of mine showed me. Hopefully it gives me a lot of knowledge and is easily comprehend able.
Kaiochao has a great answer, but I'd just like to add to it that if you don't want it to affect the user/default to the user when no one is around, use "oview()" instead of "view()"... the "o" is for "other" and so oview() means "view, minus me."
In response to AlexandraErin
AlexandraErin wrote:
Kaiochao has a great answer, but I'd just like to add to it that if you don't want it to affect the user/default to the user when no one is around, use "oview()" instead of "view()"... the "o" is for "other" and so oview() means "view, minus me."

aha that's what I was looking for. appreciate the help!