PDA

View Full Version : ct_effect and FGC vs FGU



Stv
March 17th, 2021, 19:28
I've modified the ct_effect.lua file in both FGC and FGU as follows (basically added the Debug.chat("Test")


function onMenuSelection(selection, subselection)
if selection == 3 and subselection == 3 then
windowlist.deleteChild(self, true);
Debug.chat("Test")
end
end


This works fine in FGC, but in FGU it throws the following error when you use the radial menu to delete an effect from a character in the CT


[3/17/2021 6:21:32 PM] [ERROR] Script execution error: [string "ct/scripts/ct_effect.lua"]:49: attempt to index global 'Debug' (a nil value)

Is this an error in the way FGU handles the delete compated to FGC?

If so I'l need to come up with a different angle of attack for my new extension :)

Any insight would be appreciated.

Cheers, Steve.

superteddy57
March 17th, 2021, 19:31
I've modified the ct_effect.lua file in both FGC and FGU as follows (basically added the Debug.chat("Test")


function onMenuSelection(selection, subselection)
if selection == 3 and subselection == 3 then
windowlist.deleteChild(self, true);
Debug.chat("Test")
end
end


This works fine in FGC, but in FGU it throws the following error when you use the radial menu to delete an effect from a character in the CT


[3/17/2021 6:21:32 PM] [ERROR] Script execution error: [string "ct/scripts/ct_effect.lua"]:49: attempt to index global 'Debug' (a nil value)

Is this an error in the way FGU handles the delete compated to FGC?

If so I'l need to come up with a different angle of attack for my new extension :)

Any insight would be appreciated.

Cheers, Steve.

I haven't seen this issue with the Debug.chat with just a string print. Have you tried to see if it still throws an error with a return variable? Ex: Debug.chat("Test", self)

Stv
March 17th, 2021, 19:48
Hi Superteddy,
I've just tried that, same error.


Also, a little more info :
I reinstalled FGU, unpacked the coreRPG ruleset and edit the ct_effect.lua file direct, to make sure I've not tweaked anything I shouldn't have.

It's also not just Debug.chat that throws the error, it's any code following the windowlist.delete that throws an error
Cheers, Steve.

Trenloe
March 17th, 2021, 20:03
It's also not just Debug.chat that throws the error, it's any code following the windowlist.delete that throws an error
That code is running within the scope of the window within the windowlist. When "self" is deleted from the window then there is no longer any scope for the script to run in. Run your code before the windowlist.deleteChild command.

Stv
March 17th, 2021, 20:04
That code is running within the scope of the window within the windowlist. When "self" is deleted from the window then there is no longer any scope for the script to run in. Run your code before the windowlist.deleteChild command.

Hi Trenloe,
That's what I was thinking I might have to do. It's just odd in FGC it works no problem.

Cheers, Steve.

Trenloe
March 17th, 2021, 20:05
If may delete things in a different order, be a bit more strict on not letting code in a deleting scope have access to other areas of FG, etc..

Stv
March 17th, 2021, 20:07
Meh :)I think I can still do what I need, just means a little more logic has to be applied to my new stuff.Thanks for the input :)Cheers, Steve.

Moon Wizard
March 18th, 2021, 00:53
FGU is stricter about this by design. If you delete something, you should no longer run code in the same context.

Regards,
JPG

Stv
March 18th, 2021, 08:09
Thanks for the reply MW, I thought that may be the case but had to jump on the forums to make sure :)

Once again, thank you to all that replied. I better go rethink how I'm going to do what I need :D

Cheers, Steve.