Code:
mob
proc
Fire(var/N as num, var/obj as text)
var/F
var/I
if(N == 0) F = new /obj/Attack/Missile/FireBall(usr.loc)
else
for(I = 0, I< N, I++)
if(usr.dir == SOUTH)
F = new text2path("/obj/Attack/Missile/[obj]") (locate(usr.x+ N, usr.y, usr.z))
walk(F,usr.dir,1)
Problem description:
~I know your not supposed to use usr in procs. I'm just using it until I get it mainly working, so chill all you usr abuser bashers.~
When calling Fire(), its intiated like so : Fire(#, name) Number of objects to be fired and name of object to be fired, so I can use it for every kind of misile launching verb.
Putting text2path() after new gives me an error:
text2path: undefined var
How can I fix this?
No. Never abuse usr for any reason, especially until you get something working. How can you tell it's working if you're harboring a bug? Do it right the first time. Optimization is what you do after you get something working, not fixing basic mistakes.
You can't use an expression directly in new() for the type path like that; hence the error. DM thinks you're trying to create a new object whose type path is stored in a var called text2path, and its location should be "/obj/Attack/Missile/[obj]"). It'll also freak out on the locate() folowing that.
You need to fill a var with the result of text2path(), and use that in new(). Or, you can just put the string in a var and not use text2path() at all, since new() understands strings as well.
I also highly recommend you do not name the second argument obj. Call it O or something. obj is a special keyword in DM; you should not use it for a var name.
Also, you should be using get_step() instead of an if/else block with the different directions.
And above all: No put usr in proc! Ungh!
Lummox JR