ID:261758
 
I have this bit of coding that can custimize your attack. For some reason, I can't make the object call the click proc. Here is it:

mob
verb
Numpad9()
set hidden = 1
src.Numpad9tech()
Numpad7()
set hidden = 1
src.Numpad7tech()
Numpad1()
set hidden = 1
src.Numpad1tech()
Numpad3()
set hidden = 1
src.Numpad3tech()


Set_Numpad_9()
src.num9 = input("What would you like your HotKey to be?","HotKey") in src.skills
Set_Numpad_7()
src.num7 = input("What would you like your HotKey to be?","HotKey") in src.skills
Set_Numpad_1()
src.num1 = input("What would you like your HotKey to be?","HotKey") in src.skills
Set_Numpad_3()
src.num3 = input("What would you like your HotKey to be?","HotKey") in src.skills


proc
Numpad9tech()
var/obj/A = src.num9
A.Click()
Numpad7tech()
var/obj/A = src.num7
A.Click()
Numpad1tech()
var/obj/A = src.num1
A.Click()
Numpad3tech()
var/obj/A = src.num3
A.Click()

It gives me this runtime error...

runtime error: Cannot execute null.Click().
proc name: Numpad9tech (/mob/proc/Numpad9tech)
usr: Dragon Lord (/mob)
src: Dragon Lord (/mob)
call stack:
Dragon Lord (/mob): Numpad9tech()
Dragon Lord (/mob): Numpad9()

If anyone can help me, Thanks in advanced :D
Unknown Person wrote:
proc
Numpad9tech()
var/obj/A = src.num9
A.Click()
Numpad7tech()
var/obj/A = src.num7
A.Click()
Numpad1tech()
var/obj/A = src.num1
A.Click()
Numpad3tech()
var/obj/A = src.num3
A.Click()

It gives me this runtime error...

runtime error: Cannot execute null.Click().
proc name: Numpad9tech (/mob/proc/Numpad9tech)
usr: Dragon Lord (/mob)
src: Dragon Lord (/mob)
call stack:
Dragon Lord (/mob): Numpad9tech()
Dragon Lord (/mob): Numpad9()

This is quite obvious: A is null. "Cannot read null.var" or "null.proc()" is the easiest error to diagnose. Just look for what comes before that var or proc, and where it happened. Here you have A.Click(), so A is the null in null.Click().

What's happening is that although your hotkeys can be set up by verbs, you have no default for any of them. Since there's no obj to start out, A is assigned a null value, and A.Click() summarily fails. There are two fixes. The first is optional, the second mandatory. First, you can provide default objs for those hotkeys in mob/New(). Second, you can do this in all the procs using Click():
if(A) A.Click()
If you put in defaults, the if(A) isn't strictly necessary but it's still a lot safer. So you should put in the if(A) no matter what.

Lummox JR