Hi all. I'm in need of a macro (or something else?) that calculates a bunch
of fields together in an expression. I'm trying to do with plugins like
calc and playing around with variables and action widgets but nothing seems
to work. In my last attempt I made a huge button full of actions that
stored fields in a temp tiddler, with vars that recovered those fields to
use in other action setfields... It was monstrous and still it didn't work.
I believe I need a macro - actually, probably a javascript one. But I don't
know where to start; I don't know much about java and making macros in
general. Can anyone point me to the best path I should follow, or help in
any way?
The macro should:
from tiddler-1:
get field-a-1, field-a-2, field-b-1, field-b-2, field-n
from both tiddler-a and tiddler-b (which are stored as values in field-a-1
and field-b-1):
get field-x, so to get field-x-a and field-x-b to keep around for calcs.
these are all fields I manually set up.
then:
multiply field-x-a and field-a-2, and keep the result around (let's say
var-a)
multiply field-x-b and field-b-2, the same (var-b)
add field-a-2 and field-b-2, to store as field-y in tiddler-1
multiply field-n and field-z, and get var-n
add together var-a, var-b and var-n, and store the result as field-z in
tiddler-z
this is my last attempt (embed in a button). There's one more small calc,
but it is just a sum that involves one field, so it's non relevant at the
moment.
<$action-setfield $tiddler=":$/temp/HPCalc" $field="lev1"
$value={{!!levello1}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="lev2"
$value={{!!levello2}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hd1" $value={{{
[title{!!class}get[hd]] }}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hd2" $value={{{
[title{!!class}get[hd]] }}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="conmod" $value={{{
[<currentTiddler>get[modcon]] }}}/>
<$vars lev1={{{ [[$:/temp/HPCalc]get[lev1]] }}} lev2={{{
[[$:/temp/HPCalc]get[lev2]] }}} hd1={{{ [[$:/temp/HPCalc]get[hd1]] }}}
hd2={{{ [[$:/temp/HPCalc]get[hd2]] }}}
conmod={{{ [[$:/temp/HPCalc]get[conmod]] }}}>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hps" $value={{{
[<hd1>multiply[2]subtract[2]] }}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hp1" $value={{{
[<lev1>multiply<hd1>] }}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hp2" $value={{{
[<lev2>multiply<hd2>] }}}/>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="lev" $value={{{
[<lev1>add<lev2>] }}}/>
<$vars hps={{{ [[$:/temp/HPCalc]get[hps]] }}} hp1={{{
[[$:/temp/HPCalc]get[hp1]] }}} hp2={{{ [[$:/temp/HPCalc]get[hp2]] }}}
lev={{{ [[$:/temp/HPCalc]get[lev]] }}}>
<$action-setfield $tiddler=":$/temp/HPCalc" $field="hpcon" $value={{{
[<conmod>multiply<lev>] }}}/>
<$vars hpcon={{{ [title[$:/temp/HPCalc]get[hpcon]] }}}>
<$action-setfield $tiddler=<<currentTiddler>> $field="hitpoints" $value={{{
[<hps>add<hp1>add<h2>add<hpcon>] }}}/>
<$action-setfield $tiddler=<<currentTiddler>> $field="level" $value={{{
[<lev>] }}}/>
</$vars>
</$vars>
</$vars>
if you played you know what, you know what this is about :P
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/dfe1fa36-3c89-43fc-80e6-002fd47250d2n%40googlegroups.com.