ID:146588
 
Clone
mob
verb
Kill_Bunshins()
set category = "Commands"
for(var/mob/clone)
if(src.bunshinclone >= 1)
del(clone)



I get a invalid or missing expression error

Next time comment the line. But you are missing the ) on the for() statement.

-Ryan
In response to Ryne Rekab
Ryne Rekab wrote:
Next time comment the line. But you are missing the ) on the for() statement.

-Ryan

umm I don't see that,anyway I want it to delete the bunshin clones that the player has made.

mob/proc
Createclones()//creates bunshin clone
var/mob/clone=new(usr.loc)
clone.icon=src.icon

src.bunshinclone++// adds bunshin clone to its counter
clone.ninjutsu=src.ninjutsu/2
clone.genjutsu=src.genjutsu/2
clone.Taijutsu=src.Taijutsu/2
walk_towards(clone,src,3)//Follows src
mob
verb
Kill_Bunshins()
set category = "Commands"
for(var/mob/clone)
if(src.bunshinclone >= 1)
del(clone)


Heres the full code.
In response to Broly103
Kill_Bunshins() has an indentation issue.

You're abusing usr in your proc. Read the usr lecture.

The following line:

var/mob/clone=new(usr.loc)


Even if the usr abuse is fixed here:

var/mob/clone=new(src.loc)


A mob's loc variable is going to be a turf: not a mob! What you're doing, telling the program to think of a turf as a mob, is pretty dangerous: you're just asking for trouble.

Also, your for list should look something like this:

for(var/mob/clone in world)
In response to Wizkidd0123
Wizkidd0123 wrote:
Kill_Bunshins() has an indentation issue.

You're abusing usr in your proc. Read the usr lecture.

The following line:

var/mob/clone=new(usr.loc)

Even if the usr abuse is fixed here:

var/mob/clone=new(src.loc)

A mob's loc variable is going to be a turf: not a mob! What you're doing, telling the program to think of a turf as a mob, is pretty dangerous: you're just asking for trouble.

Also, your for list should look something like this:
The indentation was an error while I was typing,I still don't get why it won't kill my clones.
for(var/mob/clone in world)
In response to Broly103
Broly103 wrote:
The indentation was an error while I was typing,I still don't get why it won't kill my clones.

Fix everything that I told you to fix before telling me that it doesn't work. If it still doesn't work then, then please post the updated, fixed code.
In response to Wizkidd0123
Wizkidd0123 wrote:
Broly103 wrote:
The indentation was an error while I was typing,I still don't get why it won't kill my clones.

Fix everything that I told you to fix before telling me that it doesn't work. If it still doesn't work then, then please post the updated, fixed code.

oh XD, I do not know how to fix the new=(src.loc).But Putting clone in world, that will kill every clone in the world o_O. I just want it to kill in the src clones.The clone problem that I get is it says missing expression.
In response to Broly103
Broly103 wrote:
oh XD, I do not know how to fix the new=(src.loc).

Depends what you want the clone to represent. If you just want a completely new mob, then you're looking for:

var/mob/clone = new()


But Putting clone in world, that will kill every clone in the world o_O. I just want it to kill in the src clones.The clone problem that I get is it says missing expression.

In that case, you need to give the clone an owner variable:

clone.owner = src.ckey


Then, you can search for a specific player's clones like this:

for(var/mob/clone in world)
if(clone.owner == src.ckey)
//...
In response to Wizkidd0123
Wouldn't it be better to add the clones to a list on creation?
mob/var/list/Clones=new
mob/verb/MakeDude()
var/mob/clone/C = new(src.loc)
src.Clones.Add(C)

mob/verb/DeleteClones()
src.Clones = list()


-Ryan
In response to Ryne Rekab
Ryne Rekab wrote:
Wouldn't it be better to add the clones to a list on creation?

Perhaps, but as to your code:
  • There's no such thing as a /mob/clone type path that was shown in his snippet.
  • Re-initializing a list isn't really a good way to delete it.
  • MakeDude() is a pretty bad, undescriptive name.
In response to Wizkidd0123
Wizkidd0123 wrote:
The following line:
var/mob/clone=new(src.loc)

A mob's loc variable is going to be a turf: not a mob! What you're doing, telling the program to think of a turf as a mob, is pretty dangerous: you're just asking for trouble.


Sorry! I was totally and completely wrong there!

The line should be

//Create a new mob on the same turf as the player
var/mob/clone = new(src.loc)


Sorry if I've caused you any confusion! (I was thinking of a different language when I wrote that =P)
In response to Wizkidd0123
Wizkidd0123 wrote:
Wizkidd0123 wrote:
The following line:
var/mob/clone=new(src.loc)

A mob's loc variable is going to be a turf: not a mob! What you're doing, telling the program to think of a turf as a mob, is pretty dangerous: you're just asking for trouble.


Sorry! I was totally and completely wrong there!

The line should be

> //Create a new mob on the same turf as the player
> var/mob/clone = new(src.loc)
>

Sorry if I've caused you any confusion! (I was thinking of a different language when I wrote that =P)
Its okay XD, I tried all I could still can not kill bunshins.