ID:140044
 
ALL RELEVANT CODE NEEDED TO SOLVE THE PROBLEM
obj
verb
take(o as obj)
materialCheck(o)
drop(o as obj)
set src in usr
loc = usr.loc

proc/materialCheck(o as obj, canGet, materialType, material)
if(material == 1)
if(materialType == "wood")
wood = wood + 1
del o
if(materialType == "leather")
leather = leather + 1
del o
if(materialType == "iron")
iron = iron + 1
del o
if(materialType == "fur")
fur = fur + 1
del o
if(materialType == "bone")
bone = bone + 1
del o
if(materialType == "plant fiber")
plantFiber = plantFiber + 1
del o
else
if(canGet == 1)
set src in usr.loc<b>


Okay, so I complied this (no errors with the code) and I ran the game. I went over to a pile of various 'materials' and when I right clicked on them, it didnt create the usual pop-up screen that it usually does when something has a possible verb action. I have no idea wth is going on here so if anyone can help that would be great. NOTE: I didnt post my code for other people to steal/criticize. If you want to use it/have a problem with the way I code my games, message, dont waste a post on the forum. ~Brizzel987

Put a set in your take verb. All I will say about the rest is it works so it must be right!
In response to Ulterior Motives
Im not exactly sure of where a 'set' would help. For storage conservation reasons, instead of making the materials actual single items, I set them as a variable, so when you try to pick up a material, it disappears from view like you would be picking it up, and it adds 1 to the variable of said material. you dont need the set src in usr.loc | loc = usr for that. please specify where I should add this 'set' of yours.

~Brizzle987
In response to Brizzel987
obj
verb
take(o as obj)
set src in oview(1)
materialCheck(o)
In response to Ulterior Motives
Ok well, I can't believe I didn't think of that, but now I altered my code like this:
obj
verb
take(o as obj)
set src in oview(1)
materialCheck()
drop(o as obj)
set src in usr
loc = usr.loc

proc/materialCheck(o as obj, canGet, materialType, material)
if(material == 1)
if(materialType == "wood")
wood = wood + 1
del src
if(materialType == "leather")
leather = leather + 1
del src
if(materialType == "iron")
iron = iron + 1
del src
if(materialType == "fur")
fur = fur + 1
del src
if(materialType == "bone")
bone = bone + 1
del src
if(materialType == "plant fiber")
plantFiber = plantFiber + 1
del src
if(material == 0)
if(canGet == 1)
set src in usr.loc

Don't get me wrong, I can use the verb just fine, but when I use it, nothing happens. The wood doesn't disappear like it is supposed to and my wood variable doesn't go up by 1 either! WTF? Please help!
In response to Brizzel987
I knew you were going to reply back saying your verb wasn't working, but I didn't want to critique your "code". Everything there is extremely wrong, you really need to go look at a tutorial. There is no point in me giving you the answers, because you won't learn a thing and it will just waste both our times.
In response to Ulterior Motives
I really dont see what I did wrong. 1) You try to get the wood {if(material == 1)|if(materialType == "wood")}
2) You add 1 to your wood supply {wood = wood + 1}
3) You delete the wood to make it seem as if you actually picked it up {del src}

Is it really more complicated?
In response to Brizzel987
You are checking if arguments are true that you are not even declaring when calling the procedure. The procedure itself is extremely repetitive and is about 20 lines too long. Then even your verbs are incorrect. Giving them an object for an argument when you need to be using source. Not to mention, you have them under just obj and not any sort of child that belongs to to obj so you will be able to use those verbs on every obj in the game. It goes on and on. I'm telling you take a break and check out some tutorials, or ask someone to teach you.
In response to Brizzel987
Brizzel987 wrote:
I really dont see what I did wrong. 1) You try to get the wood {if(material == 1)|if(materialType == "wood")}

Whose material? Whose materialType?

2) You add 1 to your wood supply {wood = wood + 1}

Whose wood supply?

3) You delete the wood to make it seem as if you actually picked it up {del src}

http://www.byond.com/ members/?command=reference&path=proc%2Fvar%2Fsrc
In response to Ulterior Motives
Most of what you are saying is sensible. Most. Yes, I realize that it got a bit long, but I wanted the player to be able to use this on every object. ITS THE 'get' VERB! I have a variable called 'canGet' which I'm sure was in the code somewhere, and like value, density, etc, I set it to 1 if you are able to pick it up, and 0 if you are not.
In response to Garthor
'material' is a variable. If it is preset to 1, the object that it is tagged to is a crafting material. If it is set to 0, it is not. The variable 'materialType' specifies what material stack to add 1 to after picking a certain material up. For example if you were, say, to pick up iron, the materialType of iron is set to "iron", so 1 is added to the corresponding iron stack.
In response to Brizzel987
You don't need a worthless canGet variable when you can just use the object tree to dictate which items can be picked up. Giving every mob a variable for every obj in the game to see how many they have is ridiculous, and your check_material() can be brought down to about three lines and do the same thing, and much better. You're making things 1000 times harder than they need to be. If you would just take the time out to learn some more it will make your life so much easier.
In response to Brizzel987
My point was that you were not specifying anywhere which object is being talked about. Perhaps get you to notice that you are referring to properties of the obj and properties of the person supposedly picking it up in exactly the same way.

But really, I think you just entirely skipped any sort of tutorials, and so I'll link you to http://www.byond.com/developer/articles/start
In response to Ulterior Motives
I don't give every mob a list of items that can and can't be picked up. You would know that if you actually read what I have been typing. I am giving every OBJECT a variable just like value. But instead, if canGet is 1 it can be picked up, and 0 it cannot. I've already said this.
In response to Brizzel987
I didn't say that at all. I'm referring to how you are giving each mob the wood, leather, iron, etc, etc variables.
Well why not something like this...(caps might be places their not suppose to be...damn spell check >.<)

Obj
Verb
Take()
Set src in oview(1)
Material_check(src, usr)

Drop()
Set src in oview(1)
Loc = usr.loc

Proc
Material_check(obj/o, mob/m)
If(o.material)
Switch(o.materialType)
If("wood")
M.wood+=1
If("leather")
M.leather+=1
If("iron")
M.iron+=1
If("fur")
M.fur+=1
If("bone")
M.bone+=1
If("plant fiber")
M.plantFiber +=1
Del o
Else if(canGet)
O.loc = usr//had no idea what you wanted for this part


I would have done something else but for simplicity's sake there u go, once again if there are caps that aren't supapose to be there its the spell check...gotta turn that off later
In response to Ulterior Motives
I must be living in an alternate universe or something because they're describing exactly what your problem is and you're not listening to their advice and you keep asking the same question.

materialCheck(o)

You are telling DM to call the materialCheck with obj/o as the only variable.

proc/materialCheck(o as obj, canGet, materialType, material)

You have materialCheck proc defined and in it you need the materialType and material vars defined.

You can simplify this proc.

materialCheck(o, usr)

That's what you should be calling and the proc should be:

materialCheck(obj/O, mob/player/P or whatever your mob is)

Once this is done everything in the proc is simple. You use O.type, O.canGet, O.whateverothervarhere and for anything with the player you would do P.whatevervarhere such as "leather = leather + 1" should be changed to "P.leather++" (Shorthand for leather = leather + 1)

Something else that I saw was that you're doing a lot of extra work such as:
if(material == 1) or if(material == 0) when you could simply put if(material) and if(!material).

Please read the advice given to you by senior programmers and don't just discard it as if they're giving you a bum steer. Don't take their advice as insults and reply with snippy comments when they're taking the time to help you either. When people tell you to read the guide it's because the guide is extremely useful. I have the guide and the reference up at all times while I'm programming.