Code:
tree
verb
shake()
switch(alert("Do you want to shake the tree?",,"Yes","No"))
if("No")
return
if("Yes")
//chance to drop orange?
Okay so im trying to set it so if a player uses a verb on a tree, theres a chance it will drop an obj, thanks for the help
Code: tree |
In response to NNAAAAHH
|
|
Ahh yea seems we have a few ways to do it :)
don't forget roll(). |
In response to A.T.H.K
|
|
I was woundering what that proc was called, lol. Link to reference:
http://www.byond.com/docs/ref/info.html#/proc/roll Could've sworn there was another proc simular to roll(), but I could just be thinking of Java. |
this is what i've got so far
obj |
In response to Forcorrie1996
|
|
I would go for the prob() proc, it is perfect here
obj |
okay will do, do you know how to make an obj, orange in this case, appear on the floor?
|
under the if(prob(20))
new/obj/Orange(src.loc) // src being the tree in this case. |
Just as a little aside here, Forcorrie1996, I'd recommend checking out the resource repository and reading the tutorials and articles there. Especially the Blue Book/Guide. The questions you've been asking have been about rather basic functions of the language, so it could benefit you quite nicely to read the manual. :)
|
Thanks andrew will do :)
and two problems, one, no errors, but no orange is dropping, (prob is set to 100) two, if i right click the tree, the verb doesnt show, I have to type it in manually |
Assuming you changed the snippet for the Orange I gave you, it would be creating it on the tree (or under) you should move it closer to the player or away from the tree.
|
its not showing up on the same tile as the tree
EDIT. how do i set it so its 1 tile away from the tree? |
In response to Forcorrie1996
|
|
new/obj/item(location) The second allows you to make changes/re-use/move the obj by accessing the variable that relates to it(in this case, o). Location in these examples is any atom available you wish to move the obj to, the obj will be moved into that atom's contents. The contents of areas and turfs are displayed ontop of them, such as a mob in contained inside of the turf it is standing in. You cannot input co-ords into new() without over-writing the new() proc for what you're making. locate(x,y,z) will output the turf at those co-ords. |
yeah, the only problem with using (x,y,z) is that i would have to change it for every tree i want to drop the obj- but if theres no other way round it i will just have to haha
|
src.y-1 src.x-1 should do it.
Although I'm unsure never tried it how about you tell me ;) |
In response to Forcorrie1996
|
|
Can you show your code for creating the orange?
Here's a few proper examples. obj/tree |
it worked, i think the problem was i forgot to use
set src in oview(1) for the shake command, and i also used your random location code kaichao, thanks for the help :) also i tried doing it myself but couldnt manage it,is there a way to set it so if the user has already shaken the tree, it doesnt let it shake it again, i only managed to get it so if i say yes it doesnt let me :( |
And have a look at this example here -
http://www.byond.com/forum/?post=576071#comment1662220