RPTools.net

Discussion and Support

Skip to content

It is currently Thu Aug 24, 2017 3:47 am 






Reply to topic  [ 8 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Dragon
 
Joined: Tue Apr 20, 2010 7:22 pm
Posts: 583
 Post subject: Party Journal Concept
PostPosted: Fri May 19, 2017 1:04 pm 
I'm kicking around the idea about adding a Party Journal concept into my framework. Players would be able to add pieces of information that had the following fields.

Owner : Who wrote the entry
Title : Entry Title
Entry : Whatever they want to write
EnteredOn : DateTime from getInfo() call
Private : bool flag on whether the entry is just for THAT player to see or if everyone can see it.

I was figuring I would store each entry in a property that's a json collection of this "JournalEntry" type.

My first thought was that each token would have its own property, for storing their own entries. Then when someone called the "Look at Party Journal" macro, it would get all the entries, from all the player tokens, remove any that were marked Private, and then sort them all by the "EnteredOn" before displaying them back.

This could work, but then I started to worry about adding a potentially huge property field to the player tokens. Would this impact performance when the tokens are moved around? Other issues?

So then I thought about just having one property, on the library token, that ALL the players wrote to. Again, when you wanted to look at the Party Journal, it would grab that property and remove any private entries from it (except for the ones you wrote, of course). The downside to this is if multiple players write entries at the same time, I could get concurrency issues on writing to that property on the library token.

Any thoughts from the experts on what the better way to approach this would be?


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9329
Location: Netherlands
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 3:24 pm 
give each player its own lib:token

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7810
Location: Bay Area
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 3:31 pm 
I have a chat that our group uses and logs everyone chat. It saves it to a personal lib token and then at the end of the night it consolidates all the chats in to one chat log. It uses the server time with getInfo so it is a universal in time.

If I were to do it now, with the latest dev I would probably write it to a table instead of a custom lib token. You would need to generate the id number for each entry which could be based on time. Perhaps when the campaign load it creates the seed value which would be subtracted from the time code of each entry. It will essentially organize it by milliseconds which in a 4hr game would be over 14 million for an id value. I'm not sure if that's a problem. You could always divide by 10 or 100 and shouldn't run in to too many problems. In chat dividing by 100 would be more of a problem, but with journal entries not so much.

_________________
Downloads:


Top
 Profile  
 
 Offline
Dragon
 
Joined: Tue Apr 20, 2010 7:22 pm
Posts: 583
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 6:07 pm 
Hmmm...hadn't thought about a table. Food for thought.


Top
 Profile  
 
 Offline
Dragon
 
Joined: Tue Apr 20, 2010 7:22 pm
Posts: 583
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 6:14 pm 
So given that the Ids in the table would be very big numbers and non-sequential (if they're based off of the datetime of the entry), how would you pull ALL the records from the table, in order?

Also, is there a way to return the MAX value of a table?


Top
 Profile  
 
 Offline
Giant
 
Joined: Mon Aug 03, 2015 5:30 pm
Posts: 180
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 6:32 pm 
If you want date/time based IDs that sort chronologically, you start with the year, then the month, day, hour and minute:

4:32 PM, May 19, 2107
201705191632

I wouldn't want to bet the rent, though, that it will always been completely unique even if you time it to the second. You'd probably want to add a unique identifier for each player.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7810
Location: Bay Area
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 7:54 pm 
The code is sequential and is the unix based time stamp. So, for example the timeInMs of 1495240970033 would be GMT: Sat, 20 May 2017 00:42:50.033 GMT and is accurate to 1 1000'th of a second.

I just checked and the highest integer tables accept is 2147483647 which is why I suggested saving a seed value which will represent the start. So, for example if 1495240970033 was my seed value, then all my id entries would start at that number and above, but you only store the difference (currentTime - Seed). Max value would be around 600 hours above the seed.

_________________
Downloads:


Top
 Profile  
 
 Offline
Dragon
 
Joined: Tue Apr 20, 2010 7:22 pm
Posts: 583
 Post subject: Re: Party Journal Concept
PostPosted: Fri May 19, 2017 8:00 pm 
So, changed up the methodology a little bit, still using a table. Just storing the entries sequentially in the table, not using milliseconds any more. Let me know what you think.

This brings up the Dialog, with all of the player entries. Private entries are not shown unless you're the person who entered it or the DM.
Code:
[h : entryLink = macroLink("Click to add a Journal entry","JournalAdd@Lib:PC_CombatMacros","none","") ]

[h : maxJournal = getTableRoll("Journal")]

[h : entries = ""]
[h, for(x, maxJournal,0,-1), code : {
   [h : tableVal = table("Journal", x)]
   [h : isPrivate = json.get(tableVal, "Private")]
   [h : linkIs = x]
   [h : displayEntry = 1]
   [h, if(isPrivate && getPlayerName() != json.get(tableVal, "Owner") && getPlayerName() != "DM"), code : {
      [h : displayEntry = 0]
   }]   
   [h, if(getPlayerName() == json.get(tableVal, "Owner")), code : {
      [h : linkIs = macroLink(x, "JournalEdit@Lib:PC_CombatMacros", "none", x)]
   }]
   [h, if(displayEntry == 1) : entries = entries + strformat('<tr><td>' + linkIs + '</td><td style="width:130">' + json.get(tableVal, "EnteredOn") + '</td><td style="width:70">' + json.get(tableVal, "Owner") + '</td><td style="width:450">' + json.get(tableVal, "Entry") + '</td></tr>')]
}]

[dialog("Party Journal", "width=700; height=400"): {
<html>
<head>
<title>Party Journal</title>
</head>
<body>
[entryLink]
<table border="1">
<tr><th></th><th>Logged</th><th>Author</th><th>Entry</th></tr>
[entries]
</table>
</body>
</html>
}]


Journal Add macro
Code:
[h:status=input(
"private|0|Private Entry?|CHECK",
"entry| |Journal Entry|TEXT|WIDTH=150"
)]

[h : abort(status)]

[h : clientData = getInfo("client")]
[h : timeStamp = json.get(clientData, "timeDate")]
[h : entry = json.set("", "Owner", getPlayerName(), "EnteredOn", timeStamp, "Entry", entry, "Private", private)]

[h : maxRoll = getTableRoll("Journal")]
[h : maxRoll = maxRoll+1]
[h : setTableRoll("Journal", maxRoll)]
[h : addTableEntry("Journal", maxRoll, maxRoll, entry)]

[h: closeDialog("Party Journal")]
[MACRO("Journal@Lib:PC_CombatMacros"):""]


Journal Edit macro
Code:
[h: x = arg(0)]

[h : tableEntry = table("Journal", x)]

[h : isPrivate = json.get(tableEntry, "Private")]
[h : theEntry = json.get(tableEntry, "Entry")]

[h:status=input(
"private|" + isPrivate + "|Private Entry?|CHECK",
"entry|" + theEntry + "|Journal Entry|TEXT|WIDTH=150"
)]

[h : abort(status)]

[h : entry = json.set("", "Owner", getPlayerName(), "EnteredOn", json.get(tableEntry, "EnteredOn"), "Entry", entry, "Private", private)]

[h : setTableEntry("Journal", x, entry)]

[h: closeDialog("Party Journal")]
[MACRO("Journal@Lib:PC_CombatMacros"):""]


Seems to be working but I have to run this through quite a few more tests to be sure.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 8 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 3 guests





cron

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman