Data Realms Fan Forums
http://45.55.195.193/

Error: Attempt to index field 'parentgun' <Mystery Solved>
http://45.55.195.193/viewtopic.php?f=73&t=18056
Page 1 of 1

Author:  Gotcha! [ Sun Mar 07, 2010 8:05 pm ]
Post subject:  Error: Attempt to index field 'parentgun' <Mystery Solved>

Helloes,

A question,
I've used CaveCricket's awesome dual weapon mode templates to have my FN F2000 switch between normal bullets and grenades. It works like a charm, except...
The console prints an error over and over again that goes like this:
Attachment:
ScreenDump003.jpg

ERROR: UniTec.rte/Scripts/SwitcherMain.lua:65: attempt to index field 'parentgun' (a nil value)

I've stared at the SwitcherMain.lua file for hours and my eyes have turned into something mushy and leaked out of my sockets.
Does anyone know what is happening here?

The file:
Attachment:
SwitcherMain.txt


Any assistance would be greatly appreciated. :)

Author:  CaveCricket48 [ Sun Mar 07, 2010 8:08 pm ]
Post subject:  Re: Error: Attempt to index field 'parentgun' *head explodes*

Try replacing all "self.parentgun.PresetName" with "self.mainweaponname".

Author:  Gotcha! [ Sun Mar 07, 2010 8:16 pm ]
Post subject:  Re: Error: Attempt to index field 'parentgun' *head explodes*

Done, for the SwitcherAlt.lua file as well. The error is now:
ERROR: UniTec.rte/Scripts/SwitcherMain.lua:77: attempt to index field 'parentgun' (a nil value)
(77 instead of 65 :-? )

Author:  CaveCricket48 [ Sun Mar 07, 2010 8:21 pm ]
Post subject:  Re: Error: Attempt to index field 'parentgun' *head explodes*

Change that line to
Code:
   if MovableMan:IsActor(self.parentactor) and self.parentgun ~= nil and self.parentgun.ID ~= 255 and UInputMan:KeyPressed(26) and self.canswitch == true then

Author:  Gotcha! [ Sun Mar 07, 2010 8:52 pm ]
Post subject:  Re: Error: Attempt to index field 'parentgun' <Mystery Solved>

That did the trick! I owe you one. Or two. Thanks! :grin:

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/