Starfinder Playlist
Page 2 of 2 First 12
  1. #11
    Hi Folks,

    Been working away on this, got a question.

    First a screen shot. Shows the button_stringcycler in action.

    Attachment 12362

    Now I have it stepping through the various attributes, just one thing left that I can't figure out (too many trees I think).

    How do I get the onSourceUpdate() to tell me WHAT the value is?

    Here's my code:

    Code:
    	<template name="number_charskillDMfield">
    		<number_linked>
    			<frame name="fieldlight" offset="5,5,5,5" />
    			<disabled />
    			<hideonvalue>0</hideonvalue>
    			<nodrag />
    			<source><name>attribute</name><op>+</op></source>
    			<script>
    				function onSourceUpdate()	
    			
    
    								
    					setValue(math.random(5));
    				end				
    			</script>
    		</number_linked>>
    	</template>
    So I suppose I'm looking for 2 things.

    1. How do I get the source value?
    2. Once I have this, how do I query the field value that I want, for example 'strength' will get returned from the cycler, and so I want to query 'attribute.strength.mod'.

    Been on this for a good few hours and just can't get it, need help please.

    Cheers
    Colin

  2. #12
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,710
    Blog Entries
    1
    hmmmm.... i was hoping someone else might chime in as im not a programmer!

    from memory onSourceUpdate needs you to define what fields it should monitor? maybe?
    to me your code above looks like when the source is updated you want to replace it with a random number? if so what does it matter what the source is?
    generally the best place to get the values is from the db directly - work out the db mode and grab that info.
    when you change a value via the cycler it updates the db straight away you dont have to save or close the window to write it - so grab the value from the db always.

    i hope some of that helps and not too much of it misleads!

  3. #13
    Afternoon chap,

    The math.random() was to simply tell me that this *could* work. If I can update the DM box with the correct DM, ie Dex -1, Int +2 etc then that already will update the skill Total DM. Not looked yet at working out the stat DM, I simply am trying to figure out what the String value of the cycler was.....

  4. #14
    Well I restarted it, switched to using onValueChanged on the StringCycler.

    Code:
    function onValueChanged()
    					local sValue = getStringValue();	
    					local nodeWin = window.getDatabaseNode();
    					if nodeWin then
    						local nDBtoapply = DB.getValue(nodeWin, "attributes." .. sValue, -2);
    						window.characteristicDM.setValue(nDBtoapply);
    					end			
    				end
    So I know which modifier to read which is ace (ie dex_mod, int_mod) what I need now is to figure out how to read that value from the DB. They're stored as 'attributes.dex_mod' etc.

    Once I can read that, everything else works.

  5. #15
    And got it all working!

    Here's the code for the String Cycler that does exactly what I need, it updates the DM field for that skill, and that in turn fires off onSourceUpdate event which then updates the Total.

    Code:
    <template name="cycler_skillcharacteristic">
    		<button_stringcycler>
    			<parameters>
    				<defaultlabel> - </defaultlabel>
    				<labels>Str|Dex|End|Int|Edu|Soc</labels>
    				<values>str_mod|dex_mod|end_mod|int_mod|edu_mod|soc_mod</values>
    			</parameters>
    			<script>
    				function onValueChanged()
    					local sValue = getStringValue();	
    					local nodeWin = window.getDatabaseNode();
    					if nodeWin then
    						nDBtoapply = DB.getValue(nodeWin, "...attributes." ..sValue, 0);
    						window.characteristicDM.setValue(nDBtoapply);
    					end			
    				end
    			</script>
    		</button_stringcycler>
    	</template>
    Attachment 12366

    It's a bit clunky to use a StringCycler (I'd prefer a drop down) but as it 'stores' the attribute you last chose, it keeps that until you change it, I can live with cycling around.

    Cheers for all the help here. I'm still going to drop Advantages/Disadvantages on the desktop (for things like weapon ranges, cover, difficulty) but that's the character sheet done. Phew.
    Last edited by MadBeardMan; December 29th, 2015 at 15:52. Reason: Adding a screen shot

  6. #16

  7. #17
    Yep chap, sure are.

    The original books as well, I have some of them somewhere.

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
  •  
FG Spreadshirt Swag

Log in

Log in