Basic Properties question(s)

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
CharlieTVS
Kobold
Posts: 4
Joined: Thu Jun 30, 2011 4:41 am

Basic Properties question(s)

Post by CharlieTVS »

Is there a way to display the result of calculations done in properties when someone views their token's properties sheet, instead of only when hovering the mouse over their token? As in, if someone wants to check their accuracy, and I had put Accuracy:{Dex * 3} in the sheet, can I make sure they'll see 21 (Assuming dex is 7) instead of just the math being used?

Also, can HP/MaxHP be done with a dual number line, or is that more an issue of formatting? I'd much rather have it say HP: 20/32 than have it show two separate fields on mouseover

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: Basic Properties question(s)

Post by neofax »

Try this:
*@Accuracy: [R: DEX*3]
HP: 0
HPMax: 0
*@HealthPoints/Max: [R: HP]+"/"+[R: HPMax]

I am not positive on whether it requires plus signs or ampersands between the HP and HPMax, but you get the idea.

CharlieTVS
Kobold
Posts: 4
Joined: Thu Jun 30, 2011 4:41 am

Re: Basic Properties question(s)

Post by CharlieTVS »

neofax wrote:Try this:
*@Accuracy: [R: DEX*3]
HP: 0
HPMax: 0
*@HealthPoints/Max: [R: HP]+"/"+[R: HPMax]

I am not positive on whether it requires plus signs or ampersands between the HP and HPMax, but you get the idea.
The former still just shows Accuracy: [R: DEX*3] when the token is double clicked and the Properties are viewed; it works fine when moused over, but I only want HP to be displayed there

I'm probably going to make it calculated in macros and then displayed there, have it be a local variable during attacks since it's completely reliant on Dex

The latter completely broke MapTools with both pluses and ampersands, as a dialog box (with a blank body, like it was literally empty) that said "Input Value for (token)" when I hovered over one, and wouldn't go away when I X'd it out, even multiple times.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Basic Properties question(s)

Post by wolph42 »

CharlieTVS wrote:
neofax wrote:Try this:
*@Accuracy: [R: DEX*3]
HP: 0
HPMax: 0
*@HealthPoints/Max: [R: HP]+"/"+[R: HPMax]

I am not positive on whether it requires plus signs or ampersands between the HP and HPMax, but you get the idea.
The former still just shows Accuracy: [R: DEX*3] when the token is double clicked and the Properties are viewed; it works fine when moused over, but I only want HP to be displayed there

I'm probably going to make it calculated in macros and then displayed there, have it be a local variable during attacks since it's completely reliant on Dex

The latter completely broke MapTools with both pluses and ampersands, as a dialog box (with a blank body, like it was literally empty) that said "Input Value for (token)" when I hovered over one, and wouldn't go away when I X'd it out, even multiple times.
you mean you wan this: *@Accuracy: [R: Accuracy = DEX*3]

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Basic Properties question(s)

Post by jfrazierjr »

wolph42 wrote:
CharlieTVS wrote:
neofax wrote:Try this:
*@Accuracy: [R: DEX*3]
HP: 0
HPMax: 0
*@HealthPoints/Max: [R: HP]+"/"+[R: HPMax]

I am not positive on whether it requires plus signs or ampersands between the HP and HPMax, but you get the idea.
The former still just shows Accuracy: [R: DEX*3] when the token is double clicked and the Properties are viewed; it works fine when moused over, but I only want HP to be displayed there

I'm probably going to make it calculated in macros and then displayed there, have it be a local variable during attacks since it's completely reliant on Dex

The latter completely broke MapTools with both pluses and ampersands, as a dialog box (with a blank body, like it was literally empty) that said "Input Value for (token)" when I hovered over one, and wouldn't go away when I X'd it out, even multiple times.
you mean you wan this: *@Accuracy: [R: Accuracy = DEX*3]
CharlieTVS, what wolph notes will work, however, there is a very subtle issue with the above that may arise depending on how your game system works. If DEX is ever increased in some way, Accuracy will not change because it is now just a number, which defeats the purpose of auto calculations. If you want the auto calculations, but don't want it showing on mouse over, your best bet is to create a character sheet frame yourself and having your players click on a macro to show it as needed OR since it is a frame, they can set it to dock and/or hide with any other open frames they have(won't work in full screen mode though!!!) This approach gives you the best of both worlds at a small price of having to do a bit of coding. However, the wiki has extremely detailed examples of how to create frames which range from fairly simple to more detailed character sheets.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Basic Properties question(s)

Post by aliasmask »

I do something like this:

Code: Select all

*@stat.accuracy(Accuracy):[r: stat.accuracy = DEX * 3] 
This will set the value once and then you can control when it needs to be updated when you make changes by doing this:

Code: Select all

[H: resetProperty("stat.accuracy")] 
All the stat.___ are only used for output purposes where my actual stats are stored using another method (one json prop with all my stats).

Here's an example of my token props:
||| Basic Props |||

Code: Select all

*@sheet.life (Life):[r: sheet.life = strformat("%{life.lifepoints} / %{damage.awareness} - %{life.status}")]]
*@sheet.damage (Damage):[r: sheet.damage = strformat("Wounds/Burn (%{damage.wounds}/%{damage.burn}); Stun/Shock (%{damage.stun}/%{damage.shock})")]
*@sheet.armor (Armor):[r: sheet.armor = strformat("Armor (%{armor.armor}/%{armor.padding}/%{armor.plating}); Helmet (%{armor.helmet}/%{armor.lining}/%{armor.hardening})")]
*@sheet.resistance (Resists):[r: sheet.resistance = if(resistance.chemical,"Chemical "+resistance.chemical+"; ","")+if(resistance.energy,"Energy "+resistance.energy+"; ","")+if(resistance.fire,"Fire "+resistance.fire+"; ","")+if(resistance.psi,"Psi "+resistance.psi+"; ","")]
*@sheet.radiation (Radiation):[r: sheet.radiation = "Exposure "+floor(damage.exposure * 100)+"%"]
*@sheet.body (Body):[r: sheet.body = strformat("Strength %{stat.strength}, Agility %{stat.agility}, Vitality %{stat.vitality}")]
*@sheet.mind (Mind):[r: sheet.mind = strformat("Alertness {stat.alertness}, Intelligence {stat.intelligence}, Willpower {stat.willpower}")]
*@sheet.initiative (Initiative)
*sheet.fof:[H, if(isNPC()): setState("Foe",!state.Friend); setState("Friend",1) + setState("Foe",0)][r: sheet.fof = ""]
*@sheet.plot (Plot Points):[r: sheet.plot = points.plotpoints]
points.plotpoints:0
stat.strength (Strength):0
stat.agility (Agility):0
stat.vitality (Vitality):0
stat.intelligence (Intelligence):0
stat.alertness (Alertness):0
stat.willpower (Willpower):0
life.lifepoints:0
life.status:"Awake"
damage.awareness:0
damage.wounds:0
damage.burn:0
damage.stun:0
damage.shock:0
damage.exposure:0
damage.radiation:0
armor.armor:0
armor.padding:0
armor.plating:0
armor.helmet:0
armor.lining:0
armor.hardening:0
resistance.chemical:0
resistance.energy:0
resistance.fire:0
resistance.psi:0
resistance.radiation:0
||| Example Output |||
Image1.jpg
Image1.jpg (22.9 KiB) Viewed 2040 times
||| Reset Stat Sheet |||

Code: Select all

[H: statsheetProps = "sheet.life,sheet.damage,sheet.armor,sheet.resistance,sheet.radiation,sheet.body,sheet.mind,sheet.initiative,sheet.fof,sheet.plot"]
[H, foreach(sheet,statsheetProps): resetProperty(sheet)] 
Here's some random code I use as an example of what I'm talking about. The following is code I use to enter/update stats and other stuff:
||| Edit Core |||

Code: Select all

<!-- Define and declare local variables to be used -->
[H: mods.token = am.stalker.defaultObj.local("stalker.mods")]
[H: stats.token = am.stalker.defaultObj.local("stalker.stats")]
[H: life.token = am.stalker.defaultObj.local("stalker.life")]
[H: am.stalker.namesObj.local("stalker.stats")]
[H: armor.token = am.stalker.defaultObj.local("stalker.armor")]
[H: am.stalker.namesObj.local("stalker.armor")]
[H: resistance.token = am.stalker.defaultObj.local("stalker.resistance")]
[H: am.stalker.namesObj.local("stalker.resistance")]
[H: points.token = am.stalker.defaultObj.local("stalker.points")]
[H: am.stalker.namesObj.local("stalker.points")]

<!-- format the input form -->
[H: inputStr = json.append("","tab.stats|<html><b><font color=blue>STATS</font></b></html>|| TAB",am.stalker.getHeaderText("Edit Stats"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><b>%{points.startingstatpoints}</b></html>|<html><b><font color=blue>Max Stat Points</font></b></html>|LABEL"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><b>%{points.statpoints}</b></html>|<html><b><font color=blue>Stat Points Used</font></b></html>|LABEL"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><font size=+1><b>STATS</b></font></html>||LABEL|SPAN=TRUE"))]
[H, foreach(stat,stats.token): inputStr = json.append(inputStr,strformat("%{stat}|{%{stat}}|<html><b><font color=blue>{%{stat}.name}</b></font></html>|TEXT|WIDTH=6"))]
[H: inputStr = json.append(inputStr,"tab.armor|<html><b><font color=blue>ARMOR</font></b></html>|| TAB",am.stalker.getHeaderText("Edit Armor"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><font size=+1><b>ARMOR</b></font></html>||LABEL|SPAN=TRUE"))]
[H, foreach(armor,armor.token): inputStr = json.append(inputStr,strformat("%{armor}|{%{armor}}|<html><b><font>{%{armor}.name}</b></font></html>|TEXT|WIDTH=6"))]
[H: inputStr = json.append(inputStr,"tab.resistances|<html><b><font color=blue>RESISTANCES</font></b></html>|| TAB",am.stalker.getHeaderText("Edit Resistances"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><font size=+1><b>RESISTANCES</b></font></html>||LABEL|SPAN=TRUE"))]
[H, foreach(resistance,resistance.token): inputStr = json.append(inputStr,strformat("%{resistance}|{%{resistance}}|<html><b><font color=red>{%{resistance}.name}</b></font></html>|TEXT|WIDTH=6"))]
[H: inputStr = json.append(inputStr,"tab.points|<html><b><font color=blue>POINTS</font></b></html>|| TAB",am.stalker.getHeaderText("Edit Points"))]
[H: inputStr = json.append(inputStr,strformat("tip|<html><font size=+1><b>POINTS</b></font></html>||LABEL|SPAN=TRUE"))]
[H, if(isGM()), code: {
   [H, foreach(points,points.token): inputStr = json.append(inputStr,strformat("%{points}|{%{points}}|<html><b><font color=red>{%{points}.name}</b></font></html>|TEXT|WIDTH=6"))]
};{
   [H, foreach(points,points.token): inputStr = json.append(inputStr,strformat("%{points}|{%{points}}|<html><b><font color=red>{%{points}.name}</b></font></html>|LABEL"))]
}]

<!-- plug in the variables to the input form -->
[H: inputStr = json.evaluate(inputStr)]

[H: hasInput = input(json.toList(inputStr,"##"))]

<!-- save changes to stats -->
[H, if(hasInput), code: {
   [H: points.statpoints = 0]
   [H, foreach(stat,stats.token): points.statpoints = points.statpoints+ number("0"+eval(stat))]
   [H: setProperty("stalker.points",am.stalker.calcObj.local("stalker.points"))]
   [H: setProperty("stalker.stats",am.stalker.calcObj.local("stalker.stats"))]
   [H: setProperty("stalker.life",am.stalker.calcObj.local("stalker.life"))]
   [H: setProperty("stalker.armor",am.stalker.calcObj.local("stalker.armor"))]
   [H: setProperty("stalker.resistance",am.stalker.calcObj.local("stalker.resistance"))]
}; {}]

<!-- Update the stat sheet -->
[H: am.stalker.resetStatSheet()] 
||| Output Example |||
Image3.jpg
Image3.jpg (42.45 KiB) Viewed 2040 times
keywords: stalker, statsheet

CharlieTVS
Kobold
Posts: 4
Joined: Thu Jun 30, 2011 4:41 am

Re: Basic Properties question(s)

Post by CharlieTVS »

[quote"aliasmask"]*@sheet.life (Life):[r: sheet.life = strformat("%{life.lifepoints} / %{damage.awareness} - %{life.status}")][/quote]

This is EXACTLY what I was looking for, but I'm curious, what do the percent symbols actually tell the statement to do? I'm so used to horrible Java that I associate it with modulus

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Basic Properties question(s)

Post by aliasmask »

CharlieTVS wrote:
aliasmask wrote:*@sheet.life (Life):[r: sheet.life = strformat("%{life.lifepoints} / %{damage.awareness} - %{life.status}")]
This is EXACTLY what I was looking for, but I'm curious, what do the percent symbols actually tell the statement to do? I'm so used to horrible Java that I associate it with modulus
Take a look at Wiki: strformat(). I usually just use %s for a string substitution or %{varName} to insert a variable's value. When I use {%{varName}} then the varName value is a dynamic variable name I later resolve with Wiki: json.evaluate(), because I put my output in to a json array (see Wiki: json.append()).
Last edited by aliasmask on Fri Jul 01, 2011 9:34 am, edited 1 time in total.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Basic Properties question(s)

Post by jfrazierjr »

BTW AM, that is one neat little trick you are using...kuddo's. I can't wait to see what type of stuff you can come with in javascript with a much more robust macro system in 1.4.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: Basic Properties question(s)

Post by JML »

At last beginning to code my own Framework, I tried to use the initialisation trick on a lib token. It took me a few hours to discover getLibProperty() doesn't evaluate a property's default value (again fully told in the wiki :oops: )

All is working perfectly well since I use getProperty() instead (seeing both getProperty() and getLibProperty() existed I came to the false thought that they were specialised and the former wouldn't work on a lib token… till I tried).

Now this brings to me a question: as Wiki: getRawProperty() and Wiki: getLibProperty() seem to behave in the same way, why is there two of them? Or what is the difference?

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Basic Properties question(s)

Post by jfrazierjr »

My understanding is that getRawProperty will NOT evaluate any contained code.. ie, its just a string...while getLibProperty will evaluate and return the results of any contained code.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
Omen
Cave Troll
Posts: 26
Joined: Wed Jul 20, 2011 4:41 pm
Contact:

Re: Basic Properties question(s)

Post by Omen »

CharlieTVS wrote:...can HP/MaxHP be done with a dual number line, or is that more an issue of formatting? I'd much rather have it say HP: 20/32 than have it show two separate fields on mouseover
I've always treated HP as a custom formatted list, using "/" as the separator. and then use slightly more complex macro code to handle the math aspects of that property. Makes for an easier to read display, but a harder to code macro.
- Dave "The Milk Man" Derry
AKA
- Omen

"Shyt Happens - Learn to flush"
"The best thing to be is unpredictable"

User avatar
JonathanTheBlack
Dragon
Posts: 544
Joined: Mon Jun 28, 2010 12:12 pm
Location: I'm the worm...

Re: Basic Properties question(s)

Post by JonathanTheBlack »

CurrentHP: 10
MaxHP: 20
Hit Points: {CurrentHP} / {MaxHP}

Simple and easy.

User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: Basic Properties question(s)

Post by JML »

jfrazierjr wrote:My understanding is that getRawProperty will NOT evaluate any contained code.. ie, its just a string...while getLibProperty will evaluate and return the results of any contained code.
Wanting to sort out what was to me unexpected results, I did the following tests:

In my Campaign Properties, I changed a property to:

Code: Select all

HeureNaissance (HN):[r: Fatigue = floor((FORCE + AGILITE) / 2)] 
where FORCE and AGILITE have default values and Fatigue is empty and have no default.

Then, creating a lib token with correct Token Type, I ran the following macro on it:

Code: Select all

[e: Test = function("HeureNaissance")]
[r: Test] 
where function was getRawProperty(), then getLibProperty(), then getProperty() and finaly eval().

I ran a second time changing the macro to:

Code: Select all

[e: Test = function(HeureNaissance)]
[r: Test]  
Then, in the Campaign Properties, I erased the HeureNaissance's default value and copied it as its actual value in a new lib token. And I ran the two macro sets again.

Here are the tests results:

Code: Select all

Quoted               Actual value          Default value
                 Evaluated ! Returned  Evaluated ! Returned
getRawProperty   NO          YES       NO          NO
getLibProperty   NO          YES       NO          NO
getProperty      YES         YES       YES         YES
eval             YES         YES       YES         YES

Code: Select all

Unquoted             Actual value          Default value
                 Evaluated ! Returned  Evaluated ! Returned
getRawProperty   YES         NO        YES         NO
getLibProperty   YES         NO        YES         NO
getProperty      YES         NO        YES         NO
eval             YES         YES       YES         YES
  • Evaluated results mean the Fatigue property is updated.
  • Returned unavaluated results mean the Test variable gets the raw code in HeureNaissance.
First, I can see no difference between getRawProperty() and getLibPropery(), except the latter only runs on lib tokens if I get it right.
Second, the Quoted versions seem to behave according to the wiki, but the Unquoted ones,executing the code but returning nothing , look like traps.

Anyone could explain this to me?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Basic Properties question(s)

Post by Azhrei »

JML wrote:Second, the Quoted versions seem to behave according to the wiki, but the Unquoted ones,executing the code but returning nothing , look like traps.
When you use a property name unquoted, MT automatically retrieves the value stored in the property. Since you're calling the functions that access properties, the retrieval process is happening twice. So using getProperty(Fred) becomes getProperty("[r: ...]") which of course returns an empty string.

Post Reply

Return to “MapTool”