Thread: Calling windowclass
-
November 1st, 2019, 02:31 #1
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
Calling windowclass
Here is an interesting question, at least I think. Can I reference a windowclass of one file in the lua code of another?
An example.
I have this template:
Code:<template name="dice_counter"> <genericcontrol> <stateicons> <on>button_checkon</on> <off>button_checkoff</off> </stateicons> <script file="desktop/scripts/dice_counter.lua" /> </genericcontrol> </template>
Code:<dice_counter name="diegroup"> <anchored position="insidetopleft" offset="4,50" width="60"/> <allowsinglespacing /> <stateicons> <on>button_checkon2</on> <off>button_checkoff2</off> </stateicons> <values> <maximum>5</maximum> </values> <sourcefields> <current>curr</current> </sourcefields> <maxslotperrow>5</maxslotperrow> </dice_counter>
Code:function onInit() if values then if values[1].maximum then nLocalMax = tonumber(values[1].maximum[1]) or 0; end if values[1].current then nLocalCurrent = tonumber(values[1].current[1]) or 0; end end if maxslotperrow then nMaxSlotRow = tonumber(maxslotperrow[1]) or 10; end if spacing then nSpacing = tonumber(spacing[1]) or nDefaultSpacing; end if allowsinglespacing then setAnchoredHeight(nSpacing); else setAnchoredHeight(nSpacing*2); end setAnchoredWidth(nSpacing); bInit = true; updateSlots(); registerMenuItem(Interface.getString("counter_menu_clear"), "erase", 4); if User.isHost() then hostStart(); end end function hostStart() DB.setValue("curdie.curr", "number", 2); local sLoadMaxNodeName = ""; local sLoadCurrNodeName = ""; -- Synch to the data nodes local nodeWin = DB.findNode("curdie"); if nodeWin then if sourcefields then if sourcefields[1].maximum then sLoadMaxNodeName = sourcefields[1].maximum[1]; end if sourcefields[1].current then sLoadCurrNodeName = sourcefields[1].current[1]; end end if sLoadMaxNodeName ~= "" then if not DB.getValue(nodeWin, sLoadMaxNodeName) then DB.setValue(nodeWin, sLoadMaxNodeName, "number", 1); end setMaxNode(DB.getPath(nodeWin, sLoadMaxNodeName)); end if sLoadCurrNodeName ~= "" then setCurrNode(DB.getPath(nodeWin, sLoadCurrNodeName)); end end end
Can I add something to the client side that says if file1.xml windowclass sourcefields and sourcefields[1]?
I could probably create an invisible windowclass that calls the template and I put in a new sourcefield, but that seems like a crap way to do it. Unless it's the only way, then I guess I can try that.
-
November 1st, 2019, 22:22 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
I’m not sure what you are asking exactly. Off the top of my head, my suggestion is to just add an else statement to end of onInit so that clientStart gets called if not on host.
JPG
-
November 1st, 2019, 23:13 #3
- Join Date
- Dec 2015
- Location
- Boston, MA
- Posts
- 167
This is called when the host first connects.
local nodeWin = DB.findNode("curdie");
if nodeWin then
if sourcefields then
if sourcefields[1].maximum then
sLoadMaxNodeName = sourcefields[1].maximum[1];
end
if sourcefields[1].current then
sLoadCurrNodeName = sourcefields[1].current[1];
end
end
if sourcefields then
So I want to know if, when I open the character sheet, which triggers the onInit() in say record_char.xml. Can I tell it to open file1.xml, go to "diegroup" and if there is a sourcefield to then process this code with that value from sourcefields?
-
November 1st, 2019, 23:22 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
There's nothing in there that is going to trigger that from the PC sheet.
I would maybe register a callback on User.onIdentityActivation which gets called whenever a player makes a PC active. You'll need your window to correctly change when PCs are changed; because a user can have more than one PC logged in at a time, but only one active at a time.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks