ID:1901440
 
(See the best response by Kaiochao.)
Code:
            Sharinnegan/verb
Amenotejikara()
set category = "Ninjutsu"
set name = "Amenotejikara"
if(usr.dead){usr<<"You may not use Jutsu Here!";return}
if(usr.rest){usr<<"Not while resting!";return}
if(usr.fired){usr<<"You must wait!";return}
if(usr.chakra<=0){usr<<"You dont have enough chakra for this jutsu!";return}
if(usr.chakra>=1000)
usr.chakra-=1000
usr.fired = 1
for(var/mob/M in view(6))
var/Swap=usr.loc
var/MSwap=M.loc
M.move = 1
usr.move = 1
M.loc=Swap
usr.loc=MSwap
usr<<"You Switch Places With [M]"
usr.move = 0
M<<"Huh?"
sleep(5)
M.move = 0
sleep(20)
usr.fired = 0


Problem description:

it seems when i call this verb there's a small slight delay when swapping places with a person i was wonder if there's a way to make it instant and also how can i make it so you can swap with objects?
Best response
You seem to be swapping places with every mob in your view. It should be obvious that you're starting by swapping with yourself, especially since it should have told you that.

I think you need something other than a for() loop if you want a "targeted skill" that lets you swap places with any movable atom. Maybe left-click something after using the skill?
Also, look up what sleep does. You might notice that your delay has good reason.
The Sleep Has Nothing To Do With The Delay, lol. I Think U Misread It @Ter13
In response to Narutogx2
The sleep does affect the delay. It sleeps before moving on to the next mob in the loop.
lol He Coded It Wrong Then, Cuz Its Not Supposed To Be A Loop. I Know Cuz He Got The Concept From Me, lol.
In response to Narutogx2
loln00b,lol
lol Zag.
i already fixed it it works perfectly now
for(var/mob/M in view(6))

Not supposed to be a loop.

sleep(20)

Sleep doesn't affect delay...

I Think U Misread It @Ter13

While it's possible, this is one of those "you should look into who you are talking to" situations.
lol Well It Wasn't Supposed To Be A Loop, As I Said Daiguren Coded It Wrong, He Based It Off My Coding :P Its Supposed To Be A Targetted Swap Skill Via View, Not The For Shit, lol.
It would be a lot more efficient to just use a variable toggle and add in the switch with click

can switch with objects or w/e u want that way too, but i can see that being ridiculously abusable
Doesn't Matter Cuz He Said He Solved It, lol.
In response to Ter13
Ter13 wrote:
for(var/mob/M in view(6))

Not supposed to be a loop.

sleep(20)

Sleep doesn't affect delay...

I Think U Misread It @Ter13

While it's possible, this is one of those "you should look into who you are talking to" situations.

The Sleep Is For A Cooldown Period In Between Swaps, lol. He Meant A Delay In The Swap Itself.
In response to Narutogx2
Do You Have Any Idea How Ridiculous Typing Like This Looks?
Do U Have Any Idea How Little I Care? An Admin Should Close This Page Since Its Already Been Resolved Btw.
Alternatively, it makes you look like a certain webcomic character.
I Don't Know What Ur Referring To.
Awww mayne, someone doesn't know how loops work. Probably learned how to use goto from some rip and never heard of spawn. One moment, I'll edit links to the reference in.

sleep causes a proc/verb to STOP for the set time(in tenths of a second), then proceeding with the rest of the pric/verb. What you were wanting to refer to for a "cool down"(since the sleep would be the delay, when coupled with the loop) is spawn, which'll allow the proc/verb to continue while performing the following(indented/included) code after the set time(in tenths of a second).

Loops will wait for sleep, then continue the loop, unless you use break. while and for are really your most viable options for any sort of loop and you both should look into how they work.

Also, on a side note; Programming a Rip: How To has a bit I think you could benefit from.
Dude, A. Its Not Supposed To Be A Loop, Keep Up With The Conversation. B. He Knows What Spawn Is, As Well As Sleep. Btw, We Both Know What They Do. As I Said Earlier, He Miscoded It As A Loop Instead Of Just A Normal Verb. Also, This Page Is Closed Because He Resolved The Issue.
Page: 1 2