-
April 26th, 2020, 01:38 #1
[Programming] Linking points to player instead of character
Hey guys! New question.
Premise: in the Alien RPG ruleset, players get story points, not specific characters. I would like to set a database number for the number of "story points" a player has, and display that on their owned character sheets.
How it exists in the charactersheet XML script currently, without said function (this isn't tied to anything, each character just has a set of 3 boxes to tick off.):
Code:<buttongroup_counter name="storypoints"> <anchored to="storypointsframe" position="insidetopleft" offset="20,13" /> <sourcefields> <current>hp.story</current> </sourcefields> <values> <maximum>3</maximum> </values> </buttongroup_counter>
Code:<buttongroup_counter name="storypoints" source ="hp.story"> <anchored to="storypointsframe" position="insidetopleft" offset="20,13" /> <sourcefields> <current>hp.story</current> </sourcefields> <values> <maximum>3</maximum> </values> </buttongroup_counter> <number_ct_crosslink name="invisiblestorypoints" source="hp.story"> <anchored to="storypointsframe" position="insidetopright" offset="0,0" width="20" height="20" /> <min>0</min> <max>3</max> <invisible /> <script> function onInit() local rActor = ActorManager.resolveActor(window.getDatabaseNode()); local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); local PlayerName = ActorManager.getDisplayName(rActor); local PlayerVal = DB.getValue("" .. PlayerName .. ".hp.story", 0); DB.addHandler("" .. PlayerName .. ".hp.story", "onUpdate", update); setValue(PlayerVal); Debug.console("" .. PlayerName .. " Story Points = ", DB.getValue("" .. PlayerName .. ".hp.story", 0)); end function onValueChanged() local rActor = ActorManager.resolveActor(window.getDatabaseNode()); local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); local PlayerName = ActorManager.getDisplayName(rActor); DB.setValue("" .. PlayerName .. ".hp.story", "number", DB.getValue(nodeActor, "hp.story", 0)); local PlayerVal = DB.getValue("" .. PlayerName .. ".hp.story", 0); setValue(PlayerVal); end function update() local rActor = ActorManager.resolveActor(window.getDatabaseNode()); local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); local PlayerName = ActorManager.getDisplayName(rActor); local PlayerVal = DB.getValue("" .. PlayerName .. ".hp.story", 0); setValue(PlayerVal); end </script> </number_ct_crosslink>
Last edited by pr6i6e6st; April 26th, 2020 at 02:07.
-
April 26th, 2020, 02:30 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,588
It depends.
If the players can only have one character and you are hard coding that into the ruleset, then just place on the character sheet without any special linking, etc.
If the players control more than one character, my first approach would be not to store on the character sheet, but provide as part of a desktop panel. Also, these panels will need to be set correctly to read the right data based on the user name, so probably would need to create the data controls dynamically.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks