RPTools.net

Discussion and Support

Skip to content

It is currently Sun Jun 25, 2017 2:10 am 




Forum rules


Posting now open to all registered forum users.



Reply to topic  [ 6 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7731
Location: Bay Area
 Post subject: [FREQ 1.4] Move a token in Initiative
PostPosted: Thu Dec 22, 2016 8:54 pm 
I was trying to think of an easy way to move a token to a different position in the initiative panel and I don't see a method other than rewriting the entire initiative. I don't want to use sort because the move may not reflect the values. Can we get a function or two for that?

Let's say that there are 10 tokens in initiative (0-9) and the current token is 3. I want to take another token at a different position and insert them before the current token.

Code:
getInitiativePosition(token): position
// Returns the position of the token in the initiative, "" if not there
   token - id of token in initiative
   position 
- value of the position of the token (starts at 0)

moveInInitiative(old position, new position): complete
// removes token from old position and inserts at new position
   old position - this is the current position of the token to be moved (see getInitiativePosition)
   new position - this is the new position of token. All tokens with the same or greater position are moved 
      up in position up to the old position
. 
   complete 
- 0 if move could not be done due to invalid position values, 1 if move takes place. 


This is simulating essentially what can only be done manually in MapTool, dragging one token to another position in the panel.

As a side note, putting a position greater than the max position puts it after the last position. So, a move from 3 to 10 (in a 0-9 array) will put new position at 9 and decrement 4-9 to 3-8.

I also think the sort function should include an ascending/descending option.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7731
Location: Bay Area
 Post subject: Re: [FREQ 1.4] Move a token in Initiative
PostPosted: Fri Dec 23, 2016 12:29 am 
Very minor gripe.

Another thing I noticed about Wiki: getInitiativeList() is that the holding value returns false or true. It shows them not in quotes, but as boolean values. But if I try to use the raw value in an if statement, it doesn't recognize it as such. I can compare them as strings but that's an extra step. Can you just put 0 or 1.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Mon May 10, 2010 11:59 am
Posts: 1579
Location: Chicagoland
 Post subject: Re: [FREQ 1.4] Move a token in Initiative
PostPosted: Fri Dec 23, 2016 3:53 pm 
I also believe there isn't an easy way to get a tokens init, I believe it either gets it's position IIRC? Anyhoo, the Initiative tool needs a lot of love but in the mean time a few functions could really help.

Do you want to make a wish list of function names with parameters to fill those gaps? Also, if I change the return value, it could also break existing campaigns couldn't it?

_________________
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
More information here: MapTool Nerps! Fork | TokenTool Nerps! Fork
Custom TokenTool (version 1.0b33): TokenTool.exe


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7731
Location: Bay Area
 Post subject: Re: [FREQ 1.4] Move a token in Initiative
PostPosted: Fri Dec 23, 2016 5:24 pm 
One way to get positions based on token id is to extract the tokens array and check tokenId in each object in the array position, then note the position. You can also use the existing functions to change the current initiative with setCurrentInitiative(position) and then get tokenId with getInitiativeToken(). getInitiative() returns the init value. But changing initiative like that does other stuff that may not be wanted.

Actually, before I posted the request I was writing up an init panel wish list. I'll see what I can do for a rewrite. It's going to be in pseudo-code because I don't write java. I may take a look at the existing code (I'm better at reading java) to see if I see any simple fixes. I forget, didn't someone write a couple of init panel handlers?

I'm currently working on this for my game/framework using macroscript:

Code:
<!-- moveTokenInInitiative(tokenToMove,targetTokenId,position,updateSort)
   tokenToMove - id of token to move
   targetTokenId - (opt) tokenId of token to move relative to (see position below) - default is current initiative token
   position - (opt) placement of new position - default is before
      first - move to first position
      last - move to last position
      before - insert before the token with current initiative
      after - insert after token with current initiative
   updateSort - (opt) 1 to update the moved tokens initiative value by normalizing the sort order.
      This will speed things up by not rebuilding the initiative panel and use the initiative sort instead
      default is 1 and will use sort, 0 to do rebuild of init panel.

   Move token in initiative panel (REDRAW THE WHOLE darn THING! Maybe.)
-->

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Mon May 10, 2010 11:59 am
Posts: 1579
Location: Chicagoland
 Post subject: Re: [FREQ 1.4] Move a token in Initiative
PostPosted: Sat Dec 24, 2016 1:13 pm 
One thing that I'd like to see as an option myself is, if you drag a token to reorder it, set it's initiative to match. Otherwise you see this "23, 19, 14, 22, 10" after dragging 22 down to just before 10. Normally this is ok but then if you resort for other reasons you loose this position. This happens sometimes if I have to adjust a token because of a delayed action...

I believe we can currently set initiative ok but haven't played with it in a while so ya, if you see little gotcha's note them down.

_________________
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
More information here: MapTool Nerps! Fork | TokenTool Nerps! Fork
Custom TokenTool (version 1.0b33): TokenTool.exe


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3610
Location: MD
 Post subject: Re: [FREQ 1.4] Move a token in Initiative
PostPosted: Sun Dec 25, 2016 3:12 am 
Since you're talking init... I'd love to have some Init events:

onReceiveInit
onEndInit
onChangeInit
onEndOfRound
onStartOfRound

And it would be awesome if there was PC and NPC versions.

Of course, I've built versions of these in my framework but they tend to carry some of the highest overhead in the game-flow (like building in exceptions for PC's and NPC's, determining what point of the init I'm in, having to loop through all tokens, etc.)... so anything that would optimize the process would be sweet.

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 6 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 2 users online :: 0 registered, 0 hidden and 2 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 2 guests





cron

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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman