ID:166888
 
Hi
I'm making a game where you pull something off a wall and it appears at your feet.
An example is you pull something off a tree and it appears at the src's location
can anyone help?
--Mrbunny
Maybe like this, i don't know


obj
Apple
icon = 'apple.dmi'
tree
icon = 'lol.dmi'
set src in view(1)
verb
Pick()
var/obj/A = new /obj/Apple(usr.loc)
usr << "You get the apple"

In response to Evidence
Yo thanks man but
equipment.dm:3: Inconsistent indentation.
equipment.dm:4: Inconsistent indentation.
equipment.dm:6: Inconsistent indentation.
equipment.dm:7: Inconsistent indentation.
equipment.dm:9: Inconsistent indentation.
equipment.dm:10: Inconsistent indentation.
equipment.dm:11: Inconsistent indentation.
equipment.dm:12: Inconsistent indentation.
equipment.dm:12: Inconsistent indentation.

New Game.dmb - 9 errors, 0 warnings (double-click on an error to jump to it)
any advice?
In response to Mrbunny88
Don't copy and paste, lol. And also i was just giving an example, that code might not even work. Just learn from the example.
In response to Evidence
kk soz
that helped me a bit anyway coz sum1 who's more advanced about boding helped
In response to XzDoG
ye i know not to use space bar im not that bad
atom/movable/var/grabbable=FALSE
mob/verb/grab(t as null|text)
set desc = "moves any nearby grabbable object into your square, if possible"

var/list/l = new // this will be a list of grabbable objects
for(var/atom/movable/a in orange(1))
if(a.grabbable) l.Add(a) // add grabbables to the list

if(l.len)
var/atom/movable/a
if(!t) //if the user didn't specify anything to grab,
//ask which one is preferable.
a = input("Grab what?","Grab") as null|anything in l
else //otherwise, try to figure out
for(a in l) //which one the player is asking for
if(ckey(a.name)==ckey(t)) break
// ^ in a parsed enviornment, the above code
// ^ ought to be replaced by some sort of name-
// ^ -to-object matcher. Comparing ckeys is a
// ^ pretty rudimentary way to make matches, since
// ^ there could be a "red apple" in a tree, and
// ^ by this system, a player typing "grab apple"
// ^ would be told "there are no apples nearby!",
// ^ which is stupid. But I digress.
else a=null

if(a) //assuming now that we have an object in mind
if(alert("Grab [a.name]?","Grab","Grab","Nevermind") == "Grab")
if(a in orange(1)) // prevent abuse, hopefully
if(!a.Move(src.loc)) src << "It won't budge!"
else view() << "[src.name] grabs [a.name]."
else // by disallowing grab of once-near objets
src << "[a.name] is out of reach now!"

else if(t) //assuming now that no suitable object was specified
var/t_plural=0
if(copytext(t,length(t),0)=="s") t_plural=1
src << "There [t_plural? "are" : "is"] no [t] in your reach."
else src << "Nothing grabbable is in reach!"


I think that might work. I just edited it for (hopefully) greater readability, but have not compiled it for syntax errors.

To use, just set any grabbable object's "grabbable" variable to 1, like so:

obj/apple
icon = 'fruit.dmi' // whatever
icon_state = "apple"
desc = "looks fresh and tasty!"
grabbable = 1 //now it can be grabbed,
//no extra work required!
In response to PirateHead
Pirate, if I may ask, why do you always ... Well, spend 15 minutes on a code someone is bound to use, yet fail to understand? Or do you want to confuse them? I'm lost here. o.o
In response to Mysame
He might enjoy programming, like many others do.

Although, a little explanations and some comments would be nice to whom he's showing it.

O-matic
In response to Mysame
A lot of times, when I write something like that, I bookmark it and come back to it later to stick it into my own projects.

I admit that I get kinda carried away on occasion. That procedure turned out to be a lot more sophisticated than I intended it to be at the outset.

Let me rewrite it a little. I'll add some more whitespace, comments, etc, so that maybe you can follow it better? It's really a pretty simple layout.

Here's another thing to think about: when I write code, I try to write it not only for the person who requested it, but also for the people who (I hope) will find it in the future. Christie (I get the name right?) is pretty new, and probably can't follow that. But, somebody else looking for "grabbable objects" in the future might get more from it.
In response to PirateHead
PirateHead wrote:
Here's another thing to think about: when I write code, I try to write it not only for the person who requested it, but also for the people who (I hope) will find it in the future. Christie (I get the name right?) is pretty new, and probably can't follow that. But, somebody else looking for "grabbable objects" in the future might get more from it.

Bingo; If the answer was only good for one person, it might as well be a private submission system where people can 'answer' you directly without anyone else being able to see.

One of the great advantages of forums is that, over a given length of time you'll probably accumulate a lot of 'know-how' on the forums that people can search through for answers.

Now, as to how often people use the Search function, thats a slightly different story and topic ;)
In response to PirateHead
Hey thnx for this mite be a bit confusing but ill give it a try