ID:2078787
 
(See the best response by Nadrew.)
Code:
obj
MagicMissle
icon = 'MagicMissle.dmi'
Bolt
icon = 'Bolt.dmi'
Fireball
icon = 'Fireball.dmi'
turf/Click()
missile(/obj/Fireball.dmi, usr, usr.Click())
..()

loading Wiz game.dme
Wiz game.dm:45:error: missile: undefined proc
Wiz game.dmb - 1 error, 0 warnings (5/2/16 5:01 pm)

Problem description:
I am getting told that "missile" is an undefined proc. I don't understand what i am being told, may i get some help?


Best response
Your syntax is entirely wrong. You're trying to define turf/Click() outside of a valid code block, and calling missile() outside of a valid code block. From the looks of it, you're trying to make it so a missle() fires to the turf you click on.

mob/var/tmp/projectile_type

obj
projectile
Click()
usr.projectile_type = src.type

MagicMissile
icon = 'MagicMissile.dmi'

Bolt
icon = 'Bolt.dmi'

Fireball
icon = 'Fireball.dmi'

turf/Click()
if(usr.projectile_type)
missile(usr.projectile_type,usr.loc,src)


In this example if you click one of the projectile types (perhaps located within your inventory or some similar list?), it will set your projectile_type variable to the type of that object, and clicking on a turf will generate a missile() call based on that variable.

There's many better methods of handling stuff like this, but you probably need go gain a bit of a better grasp on the language before delving in too deep just yet.
There are two problems with your code:
  • The indentation is wrong.
    obj
    Fireball
    icon = 'Fireball.dmi'
    // ...

    turf/Click()
    // ...
  • The first argument in missile() is wrong. You must use an object type, i.e. /obj/Fireball, or an icon file, i.e. 'Fireball.dmi'.
In response to Nadrew
Your code doesn't seem to work for me.
Wiz game.dm:55:error: projectile_type: undefined var
Wiz game.dm:56:error: projectile_type: undefined var
Wiz game.dmb - 2 errors, 0 warnings (5/2/16 5:25 pm)

I would study the language more before going deeper, but just reading the dm guide does nothing for me personally. If there were some tests or challenges using the DM language, i would do them, but that doesn't seem to be possible. So for now, i write all the code i can as well as i can to learn.
I've edited my post to fix the errors in question, however I don't recommend copy/pasting code from the forums.
So i took your code and built a little bit on it
    verb
Fireball()
usr.projectile_type = src.type
usr << "[usr] Readys their hands"

mob/var/tmp/projectile_type

obj
projectile
MagicMissle
icon = 'MagicMissle.dmi'

Bolt
icon = 'Bolt.dmi'

Fireball
icon = 'Fireball.dmi'

turf/Click()
if(usr.projectile_type)
missile(/obj/projectile/Fireball, usr, Click())

It works better now, but instead of creating a missile from the usr to the Click(), i get a runtime error telling me that the maximum recursion level was reached, and the proc name is turf/Click, though setting Click() to usr in the missle proc just makes the missile spawn at usr and end at usr, but doesn't create the runtime error. Nothing i do fixes the infinite recursion, what is wrong?

Oh, and don't worry about the Missile mis-spelling, it was a mistake i wont fix yet.
Correct usage of missile() would look like:

missile(obj, start, end)


You are passing Click() as the end location. This is wrong; Click() does not return anything. You want to replace that with your target destination. So if that is supposed to be the turf you are clicking, then you would use src.
In response to FKI
Well that makes sense as to why there was an infinite loop. Thank you very much. You are appreciated.