FGU Twitter Sweepstakes
  1. #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>
    something like i'm thinking how it should work, but doesn't?:

    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>
    This almost works, where if i as a GM start up a character, it has the appropriate points, but changing that will not change that on active characters i have opened since loading the campaign, and in the end, i won't want this to be bound to the GM by accident, so that the character sheet displays the "GM's story points". What do suggest guys? what am i missing and doing wrong here? is it more simple than i realize? or what steps am i all missing?
    Last edited by pr6i6e6st; April 26th, 2020 at 02:07.

  2. #2
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Joshua Stream Pre

Log in

Log in