ID:1811528
 
(See the best response by Mar big.)
Code:
Summon(mob/M in world)
set category="GM"
if(M.intut)
src<<"<b><font color=red><u>WARNING: [M] is in the tutorial."
return
if(M!=src)
usr.handseals(200,50)
if(!sealpass)return
M.onwater=0
M.onsand=0
M.inzone=0
M.atkdef()
usr.freeze=1
for(var/area/A in oview(0,M))A.Entered(M)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(x,y-2,z))
sleep(10)
new/obj/immortalityfire(locate(x,y-2,z))
sleep(1)
M.alpha=initial(alpha)
sleep(1)
M.loc=(locate(x,y-2,z))
M.shadowoff()
M.shadowsewingoff()
usr.freeze=0
if(GM<3)range(12)<<"<b>[src] summoned [M]."
M.barloc()
record("Summon",user=usr.key,target=M.key,M)


Problem description: I am trying to turn this basic summoning verb to be able to pick 3 people to then summon, instead of 1.

I have tried to think up SEVERAL ways, but it always ends up not working, or just bugging out on me.

Could you guys direct me in the correct way?

Preferably with (locate(x,y,z)) one infront of me, and one at each side of me 2 tiles away like this verb does.


Best response
This code is to just give you an idea of how to approach your problem. I recommend reading Snippet Sunday #6: "Why is my code slow?". You can find a link to that here.

summon()
var
//You will need to keep track of the mobs you want to summon.
list/summoning = list()
//You are going to want to use an angle to place mobs at their correct location.
angle = 90

while(summoning.len < 3)
//creates a list without src(the source).
var/list/choices = players - src
//This allows you to choose up to 3 mobs, but also take null as an argument.
var/mob/m = input(src,"Select a player to summon","Players") as null|mob in choices

//add m to the list of mobs to summon.
summoning.Add(m)

while(summoning.len)
//pick a mob from the list you made.
var/mob/m = pick(summoning)

//check to see if m is real
if(m)
//move m to your location.
m.loc = loc
//This will make m take a step to the side of you or below you.
step(m,turn(dir,angle))
//Makes m face your direction.
m.dir = dir
//Change the angle for the next mob.
angle -= 90

//remove the mob or null from the list.
summoning.Remove(m)
Is that code able to be used as a standalone, or do I need to put in every single var I have used in my source?

Thanks for the help greatly appreciate it.
Summoning(mob/M in world)
set category="GM"
var/list/summoning = list()
while(summoning.len < 3)
var/list/choices=mob/M
var/mob/M=input(src,"Select a player to summon","Players") as null|mob in choices
summoning.Add(M)
while(summoning.len)
var/mob/M=pick(summoning)
if(M.intut)
src<<"<b><font color=red><u>WARNING: [M] is in the tutorial."
return
if(M!=src)
usr.handseals(200,50)
if(!sealpass)return
if(M)
M.onwater=0
M.onsand=0
M.inzone=0
M.atkdef()
usr.freeze=1
for(var/area/A in oview(0,M))A.Entered(M)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(x,y-2,z))
sleep(10)
new/obj/immortalityfire(locate(x,y-2,z))
sleep(1)
M.alpha=initial(alpha)
sleep(1)
M.loc=(locate(x,y-2,z))


Gives me a shitton of problems:

Coding\1.9.Admin Commands.dm:308:error: mob: undefined var
Coding\1.9.Admin Commands.dm:308:warning: M: use of M precedes its definition
Coding\1.9.Admin Commands.dm:309:warning: M: definition is here
Coding\1.9.Admin Commands.dm:312:error: M: duplicate definition
Coding\1.9.Admin Commands.dm:304:error: M: previous definition
Coding\1.6.Mobs.dm:77:error: /mob/Owner/verb: compile failed (possible infinite cross-reference loop)
Coding\1.6.Mobs.dm:79:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Coding\1.6.Mobs.dm:88:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Coding\1.6.Mobs.dm:96:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Coding\1.9.Admin Commands.dm:310:error: M: compile failed (possible infinite cross-reference loop)
Coding\1.9.Admin Commands.dm:961:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Coding\1.9.Admin Commands.dm:977:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Coding\1.9.Admin Commands.dm:993:error: /mob/Mod/verb: compile failed (possible infinite cross-reference loop)
Naruto.dmb - 11 errors, 2 warnings
In response to Seijinz
The mob is only defined under the while loop. That means that you will have to indent the code you added, so that it can fit under the while loop.

You should try to understand what is going on. Otherwise you won't gain the skills to be able to solve these type of problems on your own.
Thanks, how far would I need to ident it in though, and I am learning along the way, I know I ain't a stellar coder yet.

I am more of a visual learner anyways, so if you could help me a little further I would be very thankful.
Anyone can help me a little further?
First,
var/list/choices=mob/M

is not valid, as "mob/M" is not a variable. You probably meant to create a list. If you meant to look through the world for mobs, you should probably be creating a list outside of the loop.

Second, you defined M a second time here
var/mob/M=input(...

Either don't pass in a mob, or choose another variable name.

summoning.Add(M)

is indented too far.

In the
while(summoning.len)

loop, you define M a third time.
Below that, it would appear that you have a large number of indentation errors. Also, that loop will loop forever.

A.Entered(M)

doesn't even make sense, as an area should never enter a mob.

I'm pretty sure that there is quite a bit more, but that should get you started.
Thanks man, I will get on it, when I can, and post if anything comes up. Mucha appreciado <3
SummoningP()
set category="GM"
set name="Summoning Party"
var/list/summoning=list()
while(summoning.len<3)
var/list/choose=list()
for(var/mob/player/M in world)choose.Add(M)
var/cancel="Cancel"
choose+=cancel
var/mob/B=input("Who do you want to summon?") as null|anything in choose
summoning.Add(B)
while(summoning.len)
var/mob/M=pick(summoning)
if(M.intut)
src<<"<b><font color=red><u>WARNING: [M] is in the tutorial."
return
if(M!=src)
usr.handseals(200,50)
if(!sealpass)return
if(M)
M.onwater=0
M.onsand=0
M.inzone=0
M.atkdef()
usr.freeze=1
for(var/area/A in oview(0,M))A.Entered(M)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(x,y-2,z))
sleep(10)
new/obj/immortalityfire(locate(x,y-2,z))
sleep(1)
M.alpha=initial(alpha)
sleep(1)
M.loc=(locate(x,y-2,z))


Compiles nicely, but when I execute the verb ingame while hosting it, it freezes dream daemon, and the game... What happened?
while(summoning.len)


There is nothing under this, and there is never a time this will exit. It loops infinitely.
So I need to indent the lines under it further, or is it a matter of incorrectly written all the way through?
Given the rest of your code, it looks like you probably want to indent everything after it. But even still, it would loop indefinitely. If you plan on continuing to use that loop condition, you would need to remove M from the summoning list. My suggestion would be to just iterate through the list with a for loop, however.

Also note that those sleeps are going to cause delays between the summonings of mobs.
There's actually a lot of redundant code here. It looks like you have no idea how to use a while loop as well. I'm on my phone and frankly don't feel like remaking this for you, but here are a couple of issues/inefficiency problems I've noticed:

You're looping through all of the players in the world and adding them to a list every single time you call this verb. What you should do instead is make a Player's online list and add players to it once they log on and obviously remove them when they log out. This would completely remove the need for your list/choose.

Idk what you're trying to do by adding "Cancel" to your choose list, as that is the whole purpose of "as null"...

Your while loops.. They aren't really doing anything other than crashing your game. You need to indent accordingly, and make a break when it is no longer needed. It seems to me that you shouldn't be using while loops, as u clearly have no idea how they work.

I'm basically too tired to criticize anything else. The fact that you have variables such as "onwater" suggests bad habits, which is pretty obvious just by looking at your code. If you're using a ripped source(which appears to be the case), you should just give up on it and start from scratch. The whole block of code you posted is just so broken that it'd do you good to just delete everything.

Sorry if this reply sounds harsh, because I don't mean to be.
Seijinz wrote:
Code:
> Summon(mob/M in world)
> set category="GM"
> if(M.intut)
> src<<"<b><font color=red><u>WARNING: [M] is in the tutorial."
> return
> if(M!=src)
> usr.handseals(200,50)
> if(!sealpass)return
> M.onwater=0
> M.onsand=0
> M.inzone=0
> M.atkdef()
> usr.freeze=1
> for(var/area/A in oview(0,M))A.Entered(M)
> new/obj/immortality(M.loc)
> sleep(10)
> new/obj/immortalityfire(M.loc)
> sleep(1)
> M.alpha=0
> sleep(1)
> new/obj/immortality(locate(x,y-2,z))
> sleep(10)
> new/obj/immortalityfire(locate(x,y-2,z))
> sleep(1)
> M.alpha=initial(alpha)
> sleep(1)
> M.loc=(locate(x,y-2,z))
> M.shadowoff()
> M.shadowsewingoff()
> usr.freeze=0
> if(GM<3)range(12)<<"<b>[src] summoned [M]."
> M.barloc()
> record("Summon",user=usr.key,target=M.key,M)
>

Problem description: I am trying to turn this basic summoning verb to be able to pick 3 people to then summon, instead of 1.

I have tried to think up SEVERAL ways, but it always ends up not working, or just bugging out on me.

Could you guys direct me in the correct way?

Preferably with (locate(x,y,z)) one infront of me, and one at each side of me 2 tiles away like this verb does.



Here is what you wish -.- please read the guide on while and for statements.

Summon()
set category="GM"
var/mob/M
for(var/i = 0, i<3, i++)
M = input("Who?")in world//I suggest making a player list but you're welcome to do as you please
if(M.intut)
src<<"<b><font color=red><u>WARNING: [M] is in the tutorial."
continue
if(M!=src)
usr.handseals(200,50)
if(!sealpass)return
M.onwater=0
M.onsand=0
M.inzone=0
M.atkdef()
usr.freeze=1
for(var/area/A in oview(0,M))A.Entered(M)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(x,y-2,z))
sleep(10)
new/obj/immortalityfire(locate(x,y-2,z))
sleep(1)
M.alpha=initial(alpha)
sleep(1)
M.loc=(locate(x,y-2,z))
M.shadowoff()
M.shadowsewingoff()
usr.freeze=0
if(GM<3)range(12)<<"<b>[src] summoned [M]."
M.barloc()
record("Summon",user=usr.key,target=M.key,M)



Yes, it's plug and play, just indent it to what you need.
That is still going to suffer summoning a person and then waiting until it is finished to ask about the next person, which is probably not preferable.
That's indeed not preferable, I'd like to just pick 1 to 3 people to summon, and then actually summon both beside and infront of me.

while getting the immortality and immortalityfire underneath all 3 of them :)
The check to see if M is equal to yourself could easily be avoided if you just made a player's list and subtracted yourself from it. I feel like this is just asking for code to be corrected and pasted for a easy plug&play.

Needless to say, I'm out.
If you're simply here to say you're out, and complain about me asking for help. Then by all means, stay out, and don't post at all.

I am a learning coder, not a master coder, I might not understand things easily at first, but I genuinely do not just ask for code snippets. If you think I do then sorry, not my problem, but yours.

I will try and keep trial-and-erroring these codes until someone helps me further, or I hit the nail on the head...
In response to Seijinz
Man are you serious? You claim to only want help, but you completely ignored my previous post, in which I listed some ways your code could be improved. You blindly copy & pasted sections of code posted by fellow developers (while obviously not understanding what their purpose was, or how to even use said pieces of code properly)

I'm not even going to reply to that last paragraph of yours, since you clearly don't appreciate anybody's help.
Page: 1 2 3 4