4e interactive sheet & utilities

Framework(s) for D&D 4e, including Veggiesama's.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: 4e interactive sheet & utilities

Post by DeviantNull »

Merkuri wrote:
Rumble wrote:However, if you have only 1 selection variable, then you have issues with multiple players - you basically need one selection variable for each player, and...that gets messy.


You could probably do it with one variable that's a JSON array with the keys being the player names. Reading from a JSON isn't super speedy, but it might be faster than drawing an entire panel.

I might play around with this later, if I have time.


Good luck, I just spend a few hours futzing with it and came up with a dead end.

Storing & retrieving the last token selected is a non-issue. I just used get/setLibProperty to temporarily store a "User"+PlayerName() prop that held the tokenID. FWIW, I'm probably going to switch all the user info onto the token over to raw Props stored on the token itself and nix the JSON to speed things up.

The real problem comes in with what to do if the token IS the same token. I tried telling it to do nothing inside the frame but that blanks it out since it now has a frame with nothing in it. If I try sticking the frame inside the branch then it won't reload the macro to know to redraw on a new token selection and the whole thing stops.

I did do some testing and as far as MY sheet goes, it appears to only invokes 1 per token selection. But the problem comes in that it's each click. So if you click on the token once to select it it draws then if you click again to move it it draws again, and so on.

User avatar
PinkRose
Dragon
Posts: 732
Joined: Sat Nov 15, 2008 2:28 pm
Location: The City of Roses, Oregon

Re: 4e interactive sheet & utilities

Post by PinkRose »

Rumble, does the stuff you posted on the pdf to token carry over here regarding the sorting of powers?
I am a special snowflake!

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: 4e interactive sheet & utilities

Post by DeviantNull »

This reload issue is just nuts. I experimented with "onChangeImpersonated" thinking I could maybe help players out by not forcing theirs to redraw whenever they selected their token, and make it an optional thing for GM's... THAT even triggers a redraw when the same token is reselected even if the impersonation was never changed or stopped.

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

Re: 4e interactive sheet & utilities

Post by neofax »

Before ripping out all of the JSON, could I suggest instead of keeping the info on the token, you keep the info in tables? This way the token only contains a link to the actual info in the tables? Also, the community would only have to write the macros once and update on any errata change?

User avatar
Merkuri
Giant
Posts: 194
Joined: Sat Feb 28, 2009 3:20 pm
Location: Massachusetts, USA

Re: 4e interactive sheet & utilities

Post by Merkuri »

neofax wrote:Also, the community would only have to write the macros once and update on any errata change?


As convenient and awesome as this sounds, it is a bad idea. You do not want to include large chunks of data from the books in a framework like this. Right now the framework is relatively obscure, but if WotC found out about a MapTool framework that contained a huge database of macros they could get MapTool (or at the very least, the framework builder) in trouble.
Adventure is not outside; it is within.
--Found in a fortune cookie on game night

MapTool Framework for Sufficiently Advanced

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: 4e interactive sheet & utilities

Post by DeviantNull »

I wouldn't really be ripping the info out of the tokens. It'd still be there, just in the form it was before I consolidated it all into a JSON. And this is just idle musing, I'm not actually sure which is faster or if the difference would even be noticeable. I'm working my way around to it as I poke bits of the framework and find out what works and what doesn't. I'll know more in a week or so.

For example, right now a power consists of a JSON object that holds all the relevant power info for that power. That power is then held in a JSON object Power Group (the different groups on the sheet). Then those groups are held in a JSON object that holds all the powers groups and is the actual token property. That whole thing has to be accessed when a power is used or the power lists are built. This can be slow depending on how it's done.

Alternatively, I store each power as a single JSON on a property on the token. Then I can make index lists of those powers and simply manipulate the indexes as far as lists go. When the power is accessed I'm directly accessing a token property and I think vastly speeding up the process.

I went to the JSON structure because I didn't understand setProperty and getProperty which allow for creation and access of properties that do not exist on the campaign property list. However, they provide unlimited access directly to token storage and that is by far the fastest method from my understanding.

I'll still keep a method of copying powers/items/whatever from one token to another, regardless of the storage method. However, I will not bundle, supply, or maintain a list of powers or monsters or anything else. I feel like I"m pushing it as it is with the stuff in the example campaign as the skill descriptions with the automated formulas. I doubt WotC is going to roll up and tell me to stop, but I don't want to poke their beehive either.

That said, if someone else wanted to stat 'em up or pass them out or whatever I'm not, nor could I, stop them. Everything is effectively laying out in the open and it's free for everyone to use or mutilate or whatever to their hearts content. :)

LordAelfric
Kobold
Posts: 19
Joined: Mon Jun 29, 2009 3:21 pm

Re: 4e interactive sheet & utilities

Post by LordAelfric »

I thought I'd post an update to the new tables. With the help of DeviantNull, he updated the ability and skills panels to be a bit more efficient. So with that I've also updated my code and built the images (most of them; I still need to finish/tweak some) into tables. Here's the current result with me touching up some of the other panels as well. With the way things are written, it'd be pretty easy to change some of the panels to have a few different looks so people can choose their preferred style too.
Attachments
TableExample3.jpg
TableExample3.jpg (104.91 KiB) Viewed 1103 times

User avatar
Merkuri
Giant
Posts: 194
Joined: Sat Feb 28, 2009 3:20 pm
Location: Massachusetts, USA

Re: 4e interactive sheet & utilities

Post by Merkuri »

DeviantNull wrote:However, I will not bundle, supply, or maintain a list of powers or monsters or anything else. I feel like I"m pushing it as it is with the stuff in the example campaign as the skill descriptions with the automated formulas. I doubt WotC is going to roll up and tell me to stop, but I don't want to poke their beehive either.


Historically I recall that WotC has gone after websites that contain large power libraries, so I think as long as you keep that out of the bundled stuff for the framework you'll be fine.
Adventure is not outside; it is within.
--Found in a fortune cookie on game night

MapTool Framework for Sufficiently Advanced

User avatar
jstgtpaid
Giant
Posts: 142
Joined: Sun Jun 22, 2008 1:23 am
Location: Tampa, FL

Re: 4e interactive sheet & utilities

Post by jstgtpaid »

LordAelfric wrote:I thought I'd post an update to the new tables. With the help of DeviantNull, he updated the ability and skills panels to be a bit more efficient. So with that I've also updated my code and built the images (most of them; I still need to finish/tweak some) into tables. Here's the current result with me touching up some of the other panels as well. With the way things are written, it'd be pretty easy to change some of the panels to have a few different looks so people can choose their preferred style too.



Wow that is gorgeous! I can't wait to get my hands on it. Since you are working with DN on it will he be including that in the next update of the framework?
When the boogeyman goes to bed everynight, he checks his closet for Chuck Norris.

LordAelfric
Kobold
Posts: 19
Joined: Mon Jun 29, 2009 3:21 pm

Re: 4e interactive sheet & utilities

Post by LordAelfric »

jstgtpaid wrote:Since you are working with DN on it will he be including that in the next update of the framework?


I'm hoping so. I have a lot of panels to adjust and tweak, so its a lot of things to work on, but I'm hoping to have something soon for DeviantNull to bring into the framework.

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: 4e interactive sheet & utilities

Post by DeviantNull »

jstgtpaid wrote:Wow that is gorgeous! I can't wait to get my hands on it. Since you are working with DN on it will he be including that in the next update of the framework?


That's the plan. :D

Right now, I'm concentrating on trying different things to optimize the sheet, doing a bit of bug hunting as I go. Once I got that more or less settled, I'll try adding some new features.

I'm pretty much letting LordAelfric handle the overall sheet layout and will merge it together down the line.

User avatar
travist627
Giant
Posts: 140
Joined: Sat Nov 22, 2008 3:53 pm

Re: 4e interactive sheet & utilities

Post by travist627 »

DeviantNull wrote:This reload issue is just nuts. I experimented with "onChangeImpersonated" thinking I could maybe help players out by not forcing theirs to redraw whenever they selected their token, and make it an optional thing for GM's... THAT even triggers a redraw when the same token is reselected even if the impersonation was never changed or stopped.


OK, I worked today, head spinning, trying to figure out something to help on this one, as it drives my players nuts. Finally, I thought, "Why not put the last token information on the sheet itself instead of storing it on a token?" So, what I did was to rewrite the Sheet macro and put a modified form of the sheet macro in a new macro called ShowSheet (in the same group).

Replace the code in Sheet on Lib:Sheet with this:

Code: Select all

<!--Sheet-->
<!--Sees if multiple tokens selected and whether token is the last token selected.-->
[h: selectedCount=listCount(getSelected())]
[h: lastToken=if(macro.args=="","None",macro.args)]
<!--If more than one selected, pull up sheet, which will give message for multiples.-->
[h, if (selectedCount>1), code:{[macro("[email protected]:Sheet"):"Multiple"]}; {

[h: current=getSelected()]
<!--If token is not the last selected token, call up the sheet and attach the current token name. If not, do nothing-->
[if (lastToken!=current), code:{[macro("[email protected]:Sheet"):current]}]
}]


Then create a new macro on Lib:Sheet called ShowSheet (put it in the SheetLoad group for easy reference later) and paste in this code:

Code: Select all

<!-- Main Character sheet page-->
<!--Checks to see if the token has the state Character and if it does, calls SheetType. Prevents non-character tokens that lack property values from causing errors and prompting for values.

SelectedCount checks to see if more than 1 token is selected to prevent multiple redraws of the Character sheet.

Uses onChangeSelection to reload the sheet when a different token is selected-->

[h: selectedCount=listCount(getSelected())]


[frame("Sheet"):{
<html>
<link rel="onChangeSelection" type="macro" href="[r: macroLinkText('[email protected]:Sheet', 'none',macro.args,'selected')]"></link>
<head>
<link rel="stylesheet" type="text/css" href="[email protected][r: getMacroLocation()]">
<title>Character Sheet</title></head>

   [r, if(state.Character == 1 && selectedCount <= 1), code:
      {
         [r, macro("[email protected]:Sheet"): macro.args]
      };
      {
         <table width="100%">
            <tr>
               <td align="center">
                  <b>[r, if(SelectedCount <= 1): "This is not a character token."; "Multiple tokens selected."]</b>
               </td>
            </tr>
         </table>
      }
   ]

</html>
}]


If you look at the code, you'll notice that I have the last token selected's name as an argument that gets passed between the two macros and which stays in the onChange section of the page so that it doesn't have to be stored to a token.

Remember to always do a backup first before you try. It seems to speed things up for me, though, so give it a whirl.

Edit:
I had to revert to the original because I started getting json errors when I tried to switch to powers, feats, etc. Any ideas?
Trade Magic: the Gathering cards online!
https://pucatrade.com/invite/gift/59942

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: 4e interactive sheet & utilities

Post by Rumble »

travist627 wrote:
Edit:
I had to revert to the original because I started getting json errors when I tried to switch to powers, feats, etc. Any ideas?



Without knowing DN's code, did you happen (in your changes) to accidentally use a transient variable that has the same name as a property? Like, if there's a property called "Powers", you didn't happen to inadvertently use powers as a variable name, too?

I find that inexplicable JSON errors for me often come from some sort of whoops! like that (or, just as often, I extract something I think is a JSON but turns out not to be).

DeviantNull
Dragon
Posts: 685
Joined: Wed Sep 03, 2008 12:34 pm
Location: The Junkyard

Re: 4e interactive sheet & utilities

Post by DeviantNull »

travist627 wrote:Edit:
I had to revert to the original because I started getting json errors when I tried to switch to powers, feats, etc. Any ideas?


That would be because the sheet is already passing around stuff to itself in macro.args, basically which page or subpage to load. It's passed in a JSON, so by changing the macro.args to JSON.set and json.get I think I can make it work...

EDITED

Got it. Was just a matter of slapping those macro.args into a JSON. I further refined it to remove the duplicate IF checks on multiple tokens. I'm workin' on that whole "Keep it lean" thing. :D

This is the new Sheet Macro

Code: Select all

<!--Sheet-->
<!--Sees if multiple tokens selected and whether token is the last token selected.-->
[H: currentToken=getSelected()]
[H: selectedCount=listCount(currentToken)]

<!--if macro.args is empty, sets the LastToken none, otherwise it reads out the value of LastToken from macro.args-->
[H, if(json.isEmpty(macro.args) == 1), code:
   {
      [H: LastToken = "None"]
   };{
      [H: LastToken = json.get(macro.args, "LastToken")]
   }
]

<!--If more than one token is selected, creates a character sheet frame with the multiple token error message-->
[H, if (selectedCount>1), code:
   {
      [R, frame("Sheet"):
         {
            <html><link rel="onChangeSelection" type="macro" href="[r: macroLinkText('[email protected]:Sheet', 'none', macro.args, 'selected')]"></link>
            <head><title>Character Sheet</title></head>
            <table width="100%">
               <tr>
                  <td align="center">
                     <b>Multiple tokens selected.</b>
                  </td>
               </tr>
            </table>   
            </html>
         }
      ]   
   };{
<!--If token is not the last selected token, call up the sheet and set the LastToken key in macro.args to the value of the current token. If not, do nothing-->
      [R, if (lastToken!=currentToken), code:
         {
            [R, macro("[email protected]:Sheet"):json.set(macro.args, "LastToken", currentToken)]
         };{
            [H: ""]
         }
      ]
   }
]


And the new ShowSheet

Code: Select all

<!-- Show Sheet
Draws the character sheet frame. Checks the token to see if it has the state called Character. This prevents the character from trying to load on non-character tokens that may lack proper properties

Uses onChangeSelection to reload the sheet when a different token is selected-->
[frame("Sheet"):{
<html>
<link rel="onChangeSelection" type="macro" href="[r: macroLinkText('[email protected]:Sheet', 'none', macro.args, 'selected')]"></link>
<head>
<link rel="stylesheet" type="text/css" href="[email protected][r: getMacroLocation()]">
<title>Character Sheet</title></head>
   [r, if(state.Character == 1), code:
      {
         [r, macro("[email protected]:Sheet"): macro.args]
      };
      {
         <table width="100%">
            <tr>
               <td align="center">
                 <b>This is not a character token.</b>
               </td>
            </tr>
         </table>
      }
   ]
</html>
}]


This works. This works AMAZINGLY well. I have a tester version that loops the sheet so I can run speed tests on new optimization versus old style and it totally prevents reloads if the token is already selected. I can set a count loop to 10 or something and after waiting the 20-30 seconds for it to load, as long as I do not select a different token, I can immediately move it around the map even if I unselect it and reselect it.

I'm still going to optimize the rest of things since certain actions force reloads to make sure the sheet is current, but this alone is a MASSIVE boost. All in all, brilliant work travist627!

Folks can use this IMMEDIATELY as is as far as I can tell.
Last edited by DeviantNull on Sat Mar 20, 2010 1:13 am, edited 1 time in total.

User avatar
travist627
Giant
Posts: 140
Joined: Sat Nov 22, 2008 3:53 pm

Re: 4e interactive sheet & utilities

Post by travist627 »

DeviantNull wrote:Folks can use this IMMEDIATELY as is as far as I can tell.


Excellent! I had just wrapped up a gaming session and thought that, as Rumble mentioned, the sheet probably used json values. I was just getting to poking around in it when I read your post. It works perfectly on my tokens as well. Collaboration at its finest.
Trade Magic: the Gathering cards online!
https://pucatrade.com/invite/gift/59942

Post Reply

Return to “D&D 4e Frameworks”