-
December 28th, 2015, 19:30 #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>
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
-
December 29th, 2015, 12:28 #12
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!
-
December 29th, 2015, 13:07 #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.....
-
December 29th, 2015, 14:30 #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
Once I can read that, everything else works.
-
December 29th, 2015, 15:41 #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>
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
-
January 3rd, 2016, 11:43 #16
Traveller on bundle of holding
https://bundleofholding.com/presents/LBB-1
and
https://bundleofholding.com/presents/LBB-2
-
January 3rd, 2016, 18:52 #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