ID:173890
 
Can someone help me out on making a Pushing/Pulling Verb?
CrazyFighter wrote:
Can someone help me out on making a Pushing/Pulling Verb?

Without offering specifics, this is the most I can give:

mob/verb
Push()
var/obj/O = locate() in get_step(src,src.dir)
if(O)
step(O,src.dir)

Pull()
var/obj/O = locate() in get_step(src,src.dir)
if(O)
step(src,turn(get_dir(O,src),180))
step(O,turn(src.dir))
In response to Malver
Malver wrote:
CrazyFighter wrote:
Can someone help me out on making a Pushing/Pulling Verb?

Without offering specifics, this is the most I can give:

mob/verb
> Push()
> var/obj/O = locate() in get_step(src,src.dir)
> if(O)
> step(O,src.dir)
>
> Pull()
> var/obj/O = locate() in get_step(src,src.dir)
> if(O)
> step(src,turn(get_dir(O,src),180))
> step(O,turn(src.dir))
>


Thanks
In response to CrazyFighter
I feel guilty that I provided this code without explaining how it works. The last thing I want is a simple copy+paste job without you understanding what you've done. Here's a commented version:

mob/verb
> > Push()
> > var/obj/O = locate() in get_step(src,src.dir) // This assigns 'O' to the first object found in the turf directly in front of 'src'. If there is none, then it returns 'null'
> > if(O) // If 'O' is NOT 'null'...
> > step(O,src.dir) // Move the object one space in the direction that it was pushed
> >
> > Pull()
> > var/obj/O = locate() in get_step(src,src.dir)
> > if(O)
> > step(src,turn(get_dir(O,src),180)) // This may be confusing. This moves 'src' one step away from the object, and the following line moves the object towards 'src', making the effect of the object being pulled
> > step(O,turn(src.dir))
> >


Hope that clarifies. Play around with the code to get a better understanding as to how it works. Trust me, the last thing you want to do is copy+paste code without knowing how it works.
In response to Malver
in pull i get a error :error:turn :expected 2 arguments (found 1). at step(O,turn(src.dir))
In response to CrazyFighter
He forgot to add the ",180" as the last paramiter.

Does step() check for dense objects before it moves something?
In response to Malver
Push()
var/obj/O = locate() in get_step(src,src.dir)
if(O)
step(O,src.dir)

Pull()
var/obj/O = locate() in get_step(src,src.dir)
if(O)
step(src,turn(get_dir(O,src),180))
------->step(O,turn(src.dir))<-------


I PUT THAT but it says Turn:Expected 2 arguments found 1 one the one pointed to!
In response to Yota
Yota wrote:
Does step() check for dense objects before it moves something?

It uses Move(), so yes.
In response to Shadow9191
Shadow9191 wrote:
------->step(O,turn(src.dir))<-------
I PUT THAT but it says Turn:Expected 2 arguments found 1 one the one pointed to!

It means it's expecting 2 arguments for turn(), not for step(). You need to add the argument after src.dir; for example:

<code>step(O,turn(src.dir, 180))</code>
In response to Crispy
Hey when i put the code it works and every thing but when he pulls he waqlks forwasrd how do i fix that?
In response to Shadow9191
* walkins forwasrd* please help
In response to Shadow9191
When i try to pull the item he moves forwaard...i want him to move backward so that he moves with the item now when i try to move some thing with density he wont do it cuz he wants to move foreward PLZ HELP!
In response to Shadow9191
Don't bump your post three times within six hours. This is a FORUM, not a chatroom. If you hadn't been so rude about bumping, I might actually be inclined to help you.
In response to Crispy
sowwy =''(
In response to Shadow9191
I would also Like to know how to do this to I have fixed the pushing so now he walks with the boulder but the pull does not completely work I have the boulder to move but not him.
obj/Boulder
icon = 'Turfs.dmi'
icon_state = "Rock1"
density = 1
verb
Push()
set src in oview(1)
var/obj/O = locate() in get_step(usr,usr.dir)
if(O)
step(O,usr.dir)
step(usr,O.dir)
Pull()
set src in oview(1)
var/obj/O = locate() in get_step(usr,usr.dir)
if(O)
step(usr,turn(get_dir(O,src),180))
step(O,turn(usr.dir,180))