mob/proc/create_mob()
var/list/mobs=flist("./mobs/") // List of mob file names.
for(var/v in mobs)
world << v
v=copytext(v,1,length(v)-3) // Make mobs a list of ckeyed mob names.
world << v
//Name mob.
var/mob_name
do
mob_name=input(src,"") as text
while(ckey(mob_name) in mobs)
if(!mob_name) return
var/mob/enemy/E=new
E.name=mob_name
//Apply icon
E.icon_state=input(src,"") as null|anything in icon_states(E.icon)
if(!E.icon_state) return
//Edit variables
for(var/v in E.editable_vars)
E.vars[v]=max(1,input(src,"",,E.vars[v]) as num)
//Save mob template.
var/savefile/F=new()
F << E
F.ExportText("./", file("mobs/[ckey(E.name)].txt"))
world << "Mob saved."
//For testing.
mob/verb/Make_A_Mob()
create_mob()
mob/enemy
var/list/editable_vars=list("Attack")
var/Attack=1
I snipped the input text for the forum, I'm sure they'll miss you as much as you miss them. =P
Problem description:
The while() loop always returns false. If I create two mobs with the same name ("Ant" for my example) it should make me name it again. I have debug messages in there, the first one displays "ant.txt" and "ant" is the second. ckey("Ant") is obviously "ant" and we know it's in the list, so there must be something I'm missing. Any guesses?
*Edit
Added some stuff to make it easier to test.
You will want to do something more like the following.