Thread: Retrieving and Using Options
-
February 24th, 2015, 21:07 #11
1) Is MC4C an option registered using OptionsManager.registerOption2 like you showed on past #5? If so, just use the OptionsManager.getOption("MC4C") like I said in post #7 - use the OptionsManager public functions that are available to you. This makes it easier for you now and more supportable going forwards.
And, you should be calling the code from within the window onInit code - not the onInit code of anchor_ctbox_host_header, this is just an anchor control.
2) attempt to index global 'field' (a nil value) means that it can't find field. Look in your code, where is "field" being used? As I've mentioned before, if you are getting these error messages start putting debug code in the script to report exactly what you can access. Debug code to show window.getClass() is a good one to start with and then work from there. For example, window.getClass() might report combattracker_host - if so, look for <windowclass name="combattracker_host"> in your ruleset and work out how you'd get from there to the control/s you want to hide/show. Then use window.<path to the control> to get to the control.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 25th, 2015, 01:47 #12
Ok - switched to OptionsManager.getOption("MC4C") and that works nicely - thanks.
Ok - I was running my script in the wrong WindowClass to get access to field_three.
Moved the script to the correct WindowClass but there is an existing script there and it seems to be only executing the first script there - is that correct?
Assuming that it is correct I started taking code from ct_columns.lua and putting into ct_entry.lua and OptonsManager works but again it cant find window...
Code:local sWhereAmI = window.getClass(); Debug.console("sWhereAmI:"); Debug.console(sWhereAmI);
Runtime Notice: Reloading ruleset
Runtime Notice: s'sColumnCount:'
Runtime Notice: s'1'
Script Error: [string "ct/scripts/ct_entry.lua"]:30: attempt to index global 'window' (a nil value)
Code:if sColumnCount == "1" then Debug.console("One 1."); label_three.setVisible(false); field.three.setVisible(false); label_two.setVisible(false); field.two.setVisible(false); label_one.setVisible(true); field.one.setVisible(true); end;
Code:if sColumnCount == "1" then Debug.console("One 1."); ct_entry.label_three.setVisible(false); ct_entry.field.three.setVisible(false); ct_entry.label_two.setVisible(false); ct_entry.field.two.setVisible(false); ct_entry.label_one.setVisible(true); ct_entry.field.one.setVisible(true); end;
-
February 25th, 2015, 01:49 #13
edit:
When I run this in a different windowclass it works so I believe the syntax is correct:
Code:local sWhereAmI = window.getClass(); Debug.console("sWhereAmI:"); Debug.console(sWhereAmI);
-
February 25th, 2015, 02:27 #14
ct_entry is the code that runs in the ct_entry class - this is each entry within the windowlist within the combat tracker, i.e. a PC or NPC. Don't run the code there as it will run for each entry in the CT, run it once in the combattracker_host windowclass.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 25th, 2015, 02:40 #15
grnack!
What am I doing wrong?
I moved my script back up to combattracker_host but it still errors on window.
I took that code out and put it in ct_host.xml in <script> tags and it runs.
But I need to be able to refer to the value from OptionsManager.getOption("MC4C") and the window values in the same place so I moved the OptionsManager.getOption("MC4C") in between the <script> tags and it doesnt work there.
I cant see to get access to OptionsManager from within XML executing LUA and I cant access Window from within script executed LUA.
-
February 25th, 2015, 03:14 #16
urk.
Its not even that.
Ive done something and I cant work out what.
No matter where i run
local sWhereAmI = window.getClass();
I get attempt to inex global 'window' (a nil value) and I have tried in a LUA file called from combattracker_host and ct_entry and also between script tags in both combattracker_host and ct_entry.
Something is amiss in paradise...
-
February 25th, 2015, 03:15 #17
OptionsManager global package calls should work in XML.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 25th, 2015, 03:16 #18
It was never paradise...
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 25th, 2015, 03:44 #19
I hear you - but when I enclose it in script tags in the XML file I get errors - not just with my code - if I copy and paste a similar call from elsewhere in CoreRPG it does the same.
Sure - but no need to rub it in...
Im already feeling great!
-
February 25th, 2015, 03:47 #20
Are you putting it in an onInit() function within the XML <script> section?
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks