Thread: LUA Help
-
August 30th, 2019, 13:29 #21
-
September 6th, 2019, 19:31 #22
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
I have another question. I am trying to set up certain windows on my items screen to lock when I hit the lock icon. This is the code I have so far:
Code:function onInit() update(); end function VisDataCleared() update(); end function InvisDataAdded() update(); end function updateControl(sControl, bReadOnly) if not self[sControl] then return false; end return self[sControl].update(bReadOnly); end function update() local nodeRecord = getDatabaseNode(); local bReadOnly = WindowManager.getReadOnlyState(nodeRecord); local bWeapon = ItemManager2.isWeapon(nodeRecord); local bArmor = ItemManager2.isArmor(nodeRecord); local bSection1 = false; if updateControl("type", bReadOnly) then bSection1 = true; end if updateControl("range", bReadOnly) then bSection1 = true; end local bSection2 = false; -- if updateControl("damagerating", bReadOnly) then bSection2 = true; end -- if updateControl("resistance", bReadOnly) then bSection2 = true; end if updateControl("effect", bReadOnly) then bSection2 = true; end local bSection3 = false; if updateControl("size", bReadOnly) then bSection3 = true; end if updateControl("qualities", bReadOnly) then bSection3 = true; end if updateControl("cost", bReadOnly) then bSection3 = true; end local bSection4 = true notes.setReadOnly(bReadOnly); divider.setVisible(bSection1 and bSection2); divider2.setVisible((bSection1 or bSection2) and bSection3); divider3.setVisible((bSection1 or bSection2 or bSection3) and bSection4); end
attempt to call field 'update' (a nil value)
-
September 6th, 2019, 20:34 #23
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
What template are you using to implement those fields?
The scripts associated with those templates must have an update function, which is the error reporting when you uncomment.
There are some templates in CoreRPG that implement those functions for strings and numbers already that you can reuse. If you’re making a custom field, you’ll need to implement your own script for those fields.
Make sure to use a multi-file text search with a good text editor to track back the templates to see what is being inherited.
Regards,
JPG
-
September 6th, 2019, 20:53 #24
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
I was able to fix it. Upon looking back at the code I borrowed from, I realized I was using the wrong template for the number fields. I was off by one letter. Once I fixed that, it was all set.
-
September 16th, 2019, 16:45 #25
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
You all have been so helpful.
Code:function rankchange(draginfo, winFrame) local nodeWin = winFrame.getDatabaseNode(); local curRank = DB.getValue(nodeWin, "rank"); DB.setValue(nodeWin, "reputation.rank", "string", curRank); DB.setValue(nodeWin, "reputation.reputation", "number", 10); if DB.getValue(nodeWin, "reputation.rank") == "Ensign" then nodeWin.getChild("reputation.privilege").setValue(1); nodeWin.getChild("reputation.responsibility").setValue(20); elseif DB.getValue(nodeWin, "reputation.rank") == "Lieutenant JG" then nodeWin.getChild("reputation.privilege").setValue(1); nodeWin.getChild("reputation.responsibility").setValue(20); elseif DB.getValue(nodeWin, "reputation.rank") == "Lieutenant" then nodeWin.getChild("reputation.privilege").setValue(2); nodeWin.getChild("reputation.responsibility").setValue(19); elseif DB.getValue(nodeWin, "reputation.rank") == "Lieutenant Commander" then nodeWin.getChild("reputation.privilege").setValue(2); nodeWin.getChild("reputation.responsibility").setValue(19); elseif DB.getValue(nodeWin, "reputation.rank") == "Commander" then nodeWin.getChild("reputation.privilege").setValue(3); nodeWin.getChild("reputation.responsibility").setValue(18); elseif DB.getValue(nodeWin, "reputation.rank") == "Captain" then nodeWin.getChild("reputation.privilege").setValue(4); nodeWin.getChild("reputation.responsibility").setValue(17); else nodeWin.getChild("reputation.privilege").setValue(1); nodeWin.getChild("reputation.responsibility").setValue(20); end end
-
September 16th, 2019, 17:09 #26
Use <dbnode>.createChild - https://www.fantasygrounds.com/refdo...cp#createChild
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