[FREQ 1.4] Move a token in Initiative
Posted: 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.
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.
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: Select all
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.
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.