Starfinder Playlist
Page 3 of 3 First 123
  1. #21
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Doh! What does that even mean! My head hurts....

    Ok - searching for actioninit reveals - base.xml
    Code:
    <script name="ActionInit" file="scripts/manager_action_init.lua" />
    searching for performroll reveals - template_char.xml
    with 2 results
    Code:
    <!-- Begin Init Roll -->
    	<template name="number_charinit">
    		<number_chartotal>
    			<rollable />
    			<displaysign />
    			<tooltip><text>Initiative. Double Click to Roll. 2d10+Speed. Highest Initiative Acts First.</text></tooltip>
    			<modifiersize>mini</modifiersize>
    			<description textres="initiative" />
    			<modifierfield>initiative.temporary</modifierfield>
    			<source><name>initiative.misc</name><op>+</op></source>
    			<script>
    				function action(draginfo)
    					local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
    					ActionInit.performRoll(draginfo, rActor);
    					
    					return true;
    				end
    				
    				function onDragStart(button, x, y, draginfo)
    					return action(draginfo);
    				end
    					
    				function onDoubleClick(x,y)	
    					return action();
    				end
    			</script>
    			</number_chartotal>
    	</template>
    <!-- End Init Roll -->
    and

    Code:
    	<template name="number_charinit">
    		<number_chartotal>
    			<rollable />
    			<displaysign />
    			<modifiersize>mini</modifiersize>
    			<description textres="initiative" />
    			<modifierfield>initiative.temporary</modifierfield>
    			<source><name>initiative.misc</name><op>+</op></source>
    			<script>
    				function action(draginfo)
    					local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
    					ActionInit.performRoll(draginfo, rActor);
    					
    					return true;
    				end
    				
    				function onDragStart(button, x, y, draginfo)
    					return action(draginfo);
    				end
    					
    				function onDoubleClick(x,y)	
    					return action();
    				end
    			</script>
    		</number_chartotal>
    	</template>
    Which is probably a problem - they look identical bar the description - so now there is one entry...

    but back on track - I believe that that syntax should execute the whole function which includes the lines:

    Code:
    	local sSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0)
    	Debug.console("sSpeed = " .. sSpeed);
    but it doesnt appear to execute them...

    Code:
    function performRoll(draginfo, rActor, bSecretRoll)
    	local rRoll = {};
    	rRoll.sType = "init";
    	
    	rRoll.sDesc = "[INIT 2d10 + Speed - Armour Penalty] result ";
    	
    	rRoll.bSecret = bSecretRoll;
    
    	-- Determine the die to use
    	rRoll.aDice = { "d10","d10" };
    
    	-- Determine the modifier to use for this roll
    	local sSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0)
    	Debug.console("sSpeed = " .. sSpeed);
    	local nSpeed = tonumber("sSpeed");
    	Debug.console("nSpeed = " .. nSpeed);
    	
    	rRoll.nMod = nSpeed;
    
    	local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
    	if nodeActor then
    		if sActorType == "pc" then
    			rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0);
    		else
    			rRoll.nMod = DB.getValue(nodeActor, "init", 0);
    		end
    	end
    	
    	ActionsManager.performAction(draginfo, rActor, rRoll);
    end

  2. #22
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    i lied.
    one of these changes has caused the debug to go off...
    Code:
    Runtime Notice: s'L53: sSpeed = 0'
    Runtime Notice: s'L55: nSpeed = ' | nil
    so obviously the lookup is not working or there is not enough info to get the right record or actor...

  3. #23
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,410
    nodeActor doesn't exist at the point you're trying to use it. You need to code after it is created: local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
    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!

  4. #24
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Wow. So that *did* make sense.
    Why was I running it where I was running it? I wanted to modify nMod and thought that was the best spot.
    After making the change I have gone back and ripped out a bunch of changes in that file and simplified it.

    Code:
    function performRoll(draginfo, rActor, bSecretRoll)
    	local rRoll = {};
    	rRoll.sType = "init";
    	
    	rRoll.sDesc = "[INIT 2d10 + Speed - Armour Penalty] result ";
    	
    	rRoll.bSecret = bSecretRoll;
    
    	-- Determine the die to use
    	rRoll.aDice = { "d10","d10" };
    
    	-- Determine the modifier to use for this roll
    	rRoll.nMod = 0;
    	local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
    
    	-- Determine the modifier to use for this roll
    	local nSpeed = DB.getValue(nodeActor, "abilities.speed.temp", 0);
    	Debug.console("nSpeed = " .. nSpeed);
    
    	if nodeActor then
    		if sActorType == "pc" then
    --			rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0);
    			rRoll.nMod = DB.getValue(nodeActor, "abilities.speed.temp", 0);
    		else
    			rRoll.nMod = DB.getValue(nodeActor, "init", 0);
    		end
    	end
    
    	
    	ActionsManager.performAction(draginfo, rActor, rRoll);
    end

  5. #25
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    but of course... this leads on to at least one more question...

    I need to add a secondary modifier to this - Ive added the current speed value (abilities.speed.temp) but I also need to detract the current armour penalty value (ac.totals.penalty).
    Grabbing that should be straight forward now...

    Code:
    	local nPenalty = DB.getValue(nodeActor, "ac.totals.penalty", 0);
    	Debug.console("nPenalty = " .. nPenalty);
    Works.

    Taking a punt here...

    Code:
    	if nodeActor then
    		if sActorType == "pc" then
    --			rRoll.nMod = DB.getValue(nodeActor, "initiative.total", 0);
    			rRoll.nMod = nSpeed - nPenalty;
    		else
    			rRoll.nMod = DB.getValue(nodeActor, "init", 0);
    		end
    	end
    works! so perhaps I wont ask that question...

    Now to work out how to replicate this to the other new fields in the Combat Tracker... END WNDS AR...

    Attachment 8186

  6. #26
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,410
    Quote Originally Posted by damned View Post
    Now to work out how to replicate this to the other new fields in the Combat Tracker... END WNDS AR...

    Attachment 8186
    As mentioned in post#10 above, the best way to do this is to use the the linkPCFields() function tied with <number_ct_crosslink> controls - see the C&C files ct\scripts\ct_entry.lua and ct\ct_host.xml, respectively.

    One line from the linkPCFields() function is:

    hp.setLink(nodeChar.createChild("hp.total", "number"));

    This is of the form: <control name>.setLink(nodeChar.createChild("<charsheet DB field>", "number"));

    <charsheet DB field> is the database field in the <charsheet><id-XXXXX> character sheet entry in the campaign database.


    The control has to be of type <number_ct_crosslink> and this has been defined in ct_host.xml as:

    Code:
    			<number_ct_crosslink name="hp">
    				<anchored to="rightanchor" width="30" height="20">
    					<top />
    					<right anchor="left" relation="relative" offset="-10" />
    				</anchored>
    				<tabtarget prev="initresult" next="hptemp" />
    				<script>
    					function update()
    						window.onHealthChanged();
    					end
    				</script>
    			</number_ct_crosslink>
    So, hp.setLink(nodeChar.createChild("hp.total", "number")); links the hp <number_ct_crosslink> control with the character sheet hp.total database entry.

    Follow the syntax used in the C&C ruleset for similar fields in the combat tracker.

    Note: Use the above <number_ct_crosslink> controls only in the ct_host.xml file, for the PC side, use <number_ct_static>, for example from the C&C ct_client.xml:

    Code:
    			<number_ct_static name="hp">
    				<anchored to="rightanchor" width="30" height="20">
    					<top />
    					<right anchor="left" relation="relative" offset="-10" />
    				</anchored>
    				<script>
    					function onValueChanged()
    						window.onHealthChanged();
    					end
    				</script>
    			</number_ct_static>
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in