-
March 30th, 2024, 05:48 #1
Grabbing Data from another Window Within a Data List
Hey all,
I am continuing my journey to learn FG and I ran into another mystery. I created a simplied example to explain. So I have a window (test_main) with a window list (test_window_list). The list contains objects from testthing. I have a field on the test_main named test_number. Test number has a value of 1221456. example.JPG
I added a button within the window list to grab the value of test_number. I keep on getting the default ZERO. Is there something I do differently within a window list?
function onClickRelease(button, x, y)
-- All the options I tried.
--local CharNode = getDatabaseNode().getParent()-- Got DEFAULT OF ZERO **
local CharNode = getDatabaseNode().getParent().getParent() -- Got DEFAULT OF ZERO
--local CharNode = getDatabaseNode().getParent().getParent().getParen t() -- Got DEFAULT OF ZERO
--local CharNode = getDatabaseNode().getParent().getParent().getParen t().getParent() --NIL VALUE ERROR!!!!!!!!!!!!! I went too deep!
local sTest = DB.getValue (CharNode,"test_number",0)
ChatManager.Message(sTest)
endDaniel A George
-
March 30th, 2024, 06:01 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 21,027
You'd have to have more information on where this object exist in the hierarchy relative to the base record you are trying to access. Unless you specify otherwise, subwindows use the same database node as the parent window.
Have you tried something simple like this?
Code:function onButtonPress() ChatManager.Message(DB.getValue(window.getDatabaseNode(), "test_number", 0); end
Regards,
JPG
-
March 30th, 2024, 14:43 #3
That was my understanding as well. I tried your suggestion and and the chat shows zero still.
I below is a link to the three files that make up the test page. They are VERY short. Still baffled.
https://www.dropbox.com/scl/fo/jx9jg...04655izqy&dl=0
Thanks. Still not drinking yetDaniel A George
-
March 31st, 2024, 01:21 #4
EDIT: sorry, I was looking at the wrong control. You're using the "number" template which, unless it's being changed, is a numberfield control in the CoreRPG ruleset - so it is storing data in the database. Sorry if you've already read my confusing response...
Have you saved the campaign db.xml file (you can use the /save chat command) and checked what value is stored in the database? This will also help indicate the database hierarchy - look for <test_number type="number">123456</test_number> in the campaign db.xml file.Last edited by Trenloe; March 31st, 2024 at 01:39.
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!
-
March 31st, 2024, 01:38 #5
When you open the test_main window, do you give it a datasource?
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!
-
March 31st, 2024, 05:02 #6
Running a test with this, opening the test_main windowclass using the following chat command: /openwindow test_main testing gives this in the database (extra data removed for clarity):
Code:<root> <testing> <test_number type="number">123456</test_number> </testing> <testthing> <id-00001> <name type="string">Test 1</name> <talent_lnk type="windowreference"> <class>weapon</class> <recordname /> </talent_lnk> <weapon_calc type="number">0</weapon_calc> </id-00001> </testthing> <treasureparcels /> <vehicle /> </root>
Changing this, which is the root database reference:
Code:<windowlist name="test_window_list"> <bounds>6,5,441,318</bounds> <class>testthing_list</class> <datasource>testthing</datasource> <allowcreate /> <acceptdrop> <class>testthing</class> <field>*</field> </acceptdrop> <backcolor>#FFFFFFFF</backcolor> </windowlist>
Code:<windowlist name="test_window_list"> <bounds>6,5,441,318</bounds> <class>testthing_list</class> <datasource>.testthing</datasource> <allowcreate /> <acceptdrop> <class>testthing</class> <field>*</field> </acceptdrop> <backcolor>#FFFFFFFF</backcolor> </windowlist>
Code:<testing> <test_number type="number">123456</test_number> <testthing> <id-00001> <talent_lnk type="windowreference"> <class>weapon</class> <recordname /> </talent_lnk> <weapon_calc type="number">0</weapon_calc> </id-00001> </testthing> </testing>
Code:<buttonfield name="weapon_calc"> <bounds>245,9,22,23</bounds> <tooltip textres="testthing_list_weapon_calc_Tooltip" /> <allowdoubleclick /> <icon normal="recalc_button_base" pressed="recalc_button_click" hover="recalc_button_hover" /> <script> function onClickDown(button, x, y) ChatManager.Message(DB.getValue(window.getDatabaseNode(), "...test_number", 0)); end </script> </buttonfield>
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!
-
March 31st, 2024, 06:40 #7
That makes sense. Thanks. Learning how the data is stored is on my list to learn. THANK YOU all for the lesson. I can't wait to give this a try when I get back home. CHEERS!
Daniel A George
-
April 6th, 2024, 20:27 #8
Sorry, was out of town. I cant seem to find where I edit "To this, which is a relative database reference - note the dot (.) before testthing in the <datasource> parameter:". Where is it?
I FOUND IT. It tooks me a bit. I just did a wildcard search for datasource in all the xml files.Last edited by augustgames; April 6th, 2024 at 20:34. Reason: error
Daniel A George
-
April 6th, 2024, 21:31 #9
So now when I bring up the list in Fantasy Grounds it is empty (just a white box).
Capture.JPG
SORRY I EDITED.
So it did work! My exsiting text data was not there because I assume it did not update any exiting data. Once I added new records it worked it worked perfectly. Thanks.
Thanks.Last edited by augustgames; April 6th, 2024 at 21:38.
Daniel A George
-
April 6th, 2024, 23:23 #10
I have been applying what I learned here and have been able to pull values from numbers and text fields. What I am not able to pull is a value from a combo b (See code below). Is there anything else I need to do differntly when pullling from a combo box? If I assign a text field to be equal to the combo box I can pull the data. It's a work around, but still odd. Advice?
Code:<rsw_combobox name="weapon_type"> <frame offset="7,5,7,5" /> <bounds>25,111,112,18</bounds> <font>sheettext</font> <script> function onInit() super.onInit(); add("Axe","Axe"); add("Brawl","Brawl"); add("Bow","Bow"); add("Crossbow","Crossbow"); add("Exotic Melee","Exotic Melee"); add("Exotic Ranged","Exotic Ranged"); add("Hammer","Hammer"); add("Light Blade","Light Blade"); add("Mace","Mace"); add("Shield","Shield"); add("Spear","Spear"); add("Sword","Sword"); add("Thrown","Thrown"); end </script> </rsw_combobox>
Daniel A George
Thread Information
Users Browsing this Thread
There are currently 4 users browsing this thread. (0 members and 4 guests)
Bookmarks