ID:139886
 
Code:
obj/Trees/tree_bberry
icon='tree_bberry.dmi'
verb
Pick()
set src in oview(1)
new/obj/Berrys/Bberry in usr.contents
usr << "You begin picking for berries!"
sleep(55)
usr << "[usr.name] gets [src.name]."


obj/Berrys/Bberry
icon='bberry.dmi'
verb
Get()
set src in oview(1)
src.Move(usr)
usr << "[usr.name] gets [src.name]."
Drop()
src.Move(usr.loc)
usr << "[usr.name] drops [src.name]."
Eat()
set src in usr
usr.Hunger-=5
usr<<"You ate a BlueBerry!"
del(src)


Problem description:
I cant seem to get a Berry out of this code, The idea is to stand next to the tree, click on the Pick verb, and it adds a berry to your inventory, alswo is there a way to make it every time you pick the tree looses a berry and the icon changes??

This is incorrect syntax:

new/obj/Berrys/Bberry in usr.contents


This is what you want:

new/obj/Berrys/Bberry(usr)


That creates a new /obj/Berrys/Bberry, and the first argument sent to New() is usr. When creating atoms, the first argument always becomes its loc (if possible), so that's the same as doing this:

var/obj/Berrys/Bberry/B = new
B.loc = usr


Actually I recommend this for your pick verb instead:

usr << "You begin picking for berries."
sleep(55)
var/obj/Berrys/Bberry/B = new(usr)
usr << "You get \a [B]."


Lummox JR
In response to Lummox JR
Thank you, At first it didnt work, Becuase i took out the "set src in oview(1)" part, but i added it in, Now is there any way to change the icon after you pick the berry, like instead of three berries on the tree once you pick one it only shows to left, How would i do that, Also how do i make it where you cant click the Pick verb more than once at a time? Sorry im new to DM coding, And i want a very successful game :)
In response to Kkirk15
For the changing icon, you'll want to change its icon. Or even better, its icon_state. You're going to have to draw the cleared bush state, of course.
To disable picking, you're going to want a variable for the mob to let the game know it can't pick yet.
mob/var/tmp/picking // a non-saving variable to show this mob's picking a bush. Reccommended you use a more generic term for more actions, like "locked".

// in Pick():
usr << "You is now picking teh bush."
usr.picking = 1
sleep(55)
usr.picking = 0
usr << "No longer picking the bush"
In response to Kaiochao
the code you gave me has no effect on making a wait time, I put it along with the original code and it does nothing, am i doing something wrong

mob
var
tmp
locked

obj/Trees/tree_bberry
icon='tree_bberry.dmi'
density = 1
verb
Pick()
set src in oview(1)
usr.movement_locked += 1
usr.movement_used += 1
usr.locked += 1
usr << "You begin picking for berries."
sleep(55)
var/obj/Berrys/Bberry/B = new(usr)
usr << "You get \a [B]."
usr.movement_locked -= 1
usr.movement_used -= 1
usr.locked -= 1
In response to Kkirk15
Forgot to mention, you need a conditional check for those variables.
// if locked, stop the proc here
if(usr.locked) return

// continue verb
In response to Kaiochao
Ok I got it, Now what would i do to change the icon of the tree with berries every time i took a berry, if each tree has only 3 berries and i take one i want it to display only 2 on the tree,
In response to Kkirk15
Change the icon_state to the state drawn in the icon file.
I suggest reading a bit more of the Dream Maker beginners' guides. You're obviously getting ahead of yourself here.
In response to Kaiochao
I will read more guides, But i mean dont i got to make a proc or something to check and then tranform the original icon, I mean i already have the new icons drawn out, But how do i make it transfer in game
In response to Kkirk15
By changing the icon_state of the tree. Using the = operator.
Would you mind me asking where you found, or how you figured the new/typepath in usr.contents syntax?
It seems to become rather common as of late.
In response to Garthor
oh ok i see now
In response to Schnitzelnagler
Im pretty sure it was because a demo!
In response to Kkirk15
Which is exactly why I wondered if you could name that demo, or even better present a link towards it, we could leave a message to the responsible developer to please change this (and maybe even better yet to only ever provide learning material once the respective developer understood what s/he's trying to teach).
In response to Schnitzelnagler
Well ill have to look for it, Notice though ive read over 30 demos and dont exactly remember where i got it from, Im thinking it was something like a fishing verb demo or something!