token Move function

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. :)

Is this useful enough given the limitations to include for possible build into Maptool main source?

Poll ended at Sun Aug 22, 2010 4:32 pm

Yes, I tried it and am 100% even with the limitations there are and should definitely be included in Maptool as is.
3
60%
Yes, I tried it and am not sure if it should be included n Maptool due to the limitations.
1
20%
No. I tried it and was totally dissatisfied with how it works.
0
No votes
No. I did not even try it, I just don't want any more changes in Maptool until 1.4
1
20%
 
Total votes: 5

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

Re: token Move function

Post by wolph42 »

First of, did you download the latest ones, that is a couple of posts up?
jfrazier still needs to update the OP with the latest versions (@Jfrazier: r u reading this)

Second if you did, it IS working, check the HP of the elf when you walk over it. Note that this was created BEFORE anything could be send to the chatbox.

As for non coder making it usefull for non-coders... I think the short answer is: no. not possible. I've been thinking of making the teleporters such that you don't need to code and concluded that its possible but a LOT of work.

Traps however... unless they 'spring' ALWAYS, so no tests then yes it would be possible, but I don't think anybody is waiting for that. Which means some test has to be made, which means a system lies beneath it, which means it it has to be custom made. And as no code can be created (practically) to fit ALL systems, it can't be done.
In short delve into it and learn.

Note that this:

Code: Select all

[h:'<!--Routine for a Trap, note that no area is used here, the trap is only triggered when the test subject is moved over the traptoken-->']
[h: targetName = "Trap"] <!--name of token that is the trap-->
[h: trapTriggered = movedOverToken(targetName,lastPath)]
[r, if(!json.isEmpty(trapTriggered)), CODE:{
   [h: attackRoll = d20]
   [h:roll=1d6]
   [h, if(attackRoll > Dexterity):HP=HP-roll]
   You have triggered a trap and sustained [r:roll] hits.<br>
};{}] 
is it.
And this part:

Code: Select all

   [h: attackRoll = d20]
   [h:roll=1d6]
   [h, if(attackRoll > Dexterity):HP=HP-roll]
   You have triggered a trap and sustained [r:roll] hits.<br> 
is the system dependent part. Which is the part you need to code. The rest you can leave as is. Though if you install multiple traps they need to be called Trap1, Trap2 etc and copy paste the above code in the onTokenmove for every trap.....(hmm I'm wondering what would happen if you would call all the Trap Tokens 'Trap' and use the above code...?-->just tested it, if you use step on the original 'Trap' and then on a new 'Trap' they're both triggered, after that the new 'Trap isn't triggered until you move over the original one again. In short: all traps have to have a unique name)

Edit:See att. The T-trap will now also 'talk' to you when triggered.

Edit: attachement deleted, for the latest version go here: You can find it here: Wolph42's 'Drop-in' Auto Teleport Pads Traps, Pits and Wards
Last edited by wolph42 on Tue May 17, 2011 6:20 am, edited 2 times in total.

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

Re: token Move function

Post by jfrazierjr »

wolph42 wrote:First of, did you download the latest ones, that is a couple of posts up?
jfrazier still needs to update the OP with the latest versions (@Jfrazier: r u reading this)
Yea yea.. I'll get to it... it's not like i have not been busy trying to make the MapTool code do more cool things. :roll:
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
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: token Move function

Post by wolph42 »

jfrazierjr wrote:
wolph42 wrote:First of, did you download the latest ones, that is a couple of posts up?
jfrazier still needs to update the OP with the latest versions (@Jfrazier: r u reading this)
Yea yea.. I'll get to it... it's not like i have not been busy trying to make the MapTool code do more cool things. :roll:
True enough. Still, keep in mind the small stuff!

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: token Move function

Post by Doc_Waldo »

Perfect, you gave me really what I was looking for- I explained incorrectly, I was just looking for a little more explanation of where in the code to go, I would agree that one has to get in and learn and I enjoy doing so especially with some great direction as you shared. If I run into a problem, I will post a follow up question, but from what you gave I should be able to make the progress I need.
--DOC

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

Re: token Move function

Post by wolph42 »

Doc_Waldo wrote:Perfect, you gave me really what I was looking for- I explained incorrectly, I was just looking for a little more explanation of where in the code to go, I would agree that one has to get in and learn and I enjoy doing so especially with some great direction as you shared. If I run into a problem, I will post a follow up question, but from what you gave I should be able to make the progress I need.
Good to hear ! And indeed if somethings up: post!

User avatar
Doc_Waldo
Giant
Posts: 108
Joined: Wed Sep 08, 2010 11:41 pm
Location: Boise, ID

Re: token Move function

Post by Doc_Waldo »

I know I am missing something because I can't get the map to map teleport to work (I am using the Wolph42 - Example TokenMoveFunctions (Simple) v7a.cmpgn).

Here is what I am doing:
1- I open the example campaign.
2- Save the lib:Test token, move to new map token, and teleport back token, along with creature token.
3- Open up a new campaign in maptools.
4- Import all the tokens and confirm they are named correctly.
5- I try to run onCompaignLoad macro fro the lib:Test token, but I get chat feedback telling me I don't have permission, so I move the macro to the campaign and run, it say's it defines the pause function.
5- Move the teleport back token to the object layer of a new map called Test.
6- Attempt to drop Creature (imported in from Wolph42 example campaign) and nothing.

I also copied the campaign properties over but I didn't see that that the properties are used in the lib:Test, or any of the move between map teleports.

Any suggestions would be appreciated.
--DOC

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

Re: token Move function

Post by wolph42 »

1. Upload The campaign so I can have a look
2. turn 'allow players to edit function' off in the macro in the options tab. This willl allow you to run oncampaigload and possibly other functions

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: token Move function

Post by CoveredInFish »

Just fumbled around with all the related functions and discovered that

movesOverToken(token)

does not accept a tokenId - only token names. This may be already known to you guys but I expected it othwerwise (since this differs from standard behaviour).

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: token Move function

Post by CoveredInFish »

Oh .. btw .. i just started a kind of how-to guide for al this onmove-stuff. Some help would be appreciated...
http://lmwcs.com/rptools/wiki/Guide_to_onTokenMove

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

Re: token Move function

Post by jfrazierjr »

CoveredInFish wrote:Oh .. btw .. i just started a kind of how-to guide for al this onmove-stuff. Some help would be appreciated...
http://lmwcs.com/rptools/wiki/Guide_to_onTokenMove
GREAT!!! Thanks. I would suggest making a big distinction between onTokenMove and onMultipleTokensMove. the former is fired for each token(as long as it passes the filter which is visible and on the token layer) EVEN if you move multiple. The later is fired ONLY if there are multiple tokens that pass the filter. If using both, it is suggested that you use the moveCount variable in onTokenMove and abort if >1 and let onMultipleTokensMove handle it.
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
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: token Move function

Post by jfrazierjr »

CoveredInFish wrote:Just fumbled around with all the related functions and discovered that

movesOverToken(token)

does not accept a tokenId - only token names. This may be already known to you guys but I expected it othwerwise (since this differs from standard behaviour).

I sent Azhrei a patch.. not sure if he will commit it or not, but if so, it will take either id or name


EDIT: patch applied...
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
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: token Move function

Post by CoveredInFish »

jfrazierjr wrote: patch applied
Great, thanks!

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: token Move function

Post by CoveredInFish »

I have a question to Wiki: movedOverPoints():

the way the docs are written so far it sound that the specified points would be a group of coordinates and if one of them is hit its returned. My testing and a quote in the forums (i cant find it right now) seem to indicate that the points form a shape and any cell in that shape will be returned.

Clarification would be great - so i could work on guide and wiki.

If it would be the latter i think i have written a small tool that might come handy. Its a lib token that lets you create path objects. You can move the token, press "add point" move again press "add" again ... so on .. and when you are finished you can get the json array or even code that generates that array.
Attachments
lib_shapebuilder.rptok
(6.12 KiB) Downloaded 106 times

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

Re: token Move function

Post by jfrazierjr »

Well.... the intention is that you would pass in enough points to create a shape. Then, if the token moves over the shape, the cell points which it crosses as part of the path are what is returned.
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..

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

[SOLVED] token Move function

Post by neofax »

wolph42 wrote:First of, did you download the latest ones, that is a couple of posts up?
jfrazier still needs to update the OP with the latest versions (@Jfrazier: r u reading this)

Second if you did, it IS working, check the HP of the elf when you walk over it. Note that this was created BEFORE anything could be send to the chatbox.

As for non coder making it usefull for non-coders... I think the short answer is: no. not possible. I've been thinking of making the teleporters such that you don't need to code and concluded that its possible but a LOT of work.

Traps however... unless they 'spring' ALWAYS, so no tests then yes it would be possible, but I don't think anybody is waiting for that. Which means some test has to be made, which means a system lies beneath it, which means it it has to be custom made. And as no code can be created (practically) to fit ALL systems, it can't be done.
In short delve into it and learn.

Note that this:

Code: Select all

[h:'<!--Routine for a Trap, note that no area is used here, the trap is only triggered when the test subject is moved over the traptoken-->']
[h: targetName = "Trap"] <!--name of token that is the trap-->
[h: trapTriggered = movedOverToken(targetName,lastPath)]
[r, if(!json.isEmpty(trapTriggered)), CODE:{
   [h: attackRoll = d20]
   [h:roll=1d6]
   [h, if(attackRoll > Dexterity):HP=HP-roll]
   You have triggered a trap and sustained [r:roll] hits.<br>
};{}] 
is it.
And this part:

Code: Select all

   [h: attackRoll = d20]
   [h:roll=1d6]
   [h, if(attackRoll > Dexterity):HP=HP-roll]
   You have triggered a trap and sustained [r:roll] hits.<br> 
is the system dependent part. Which is the part you need to code. The rest you can leave as is. Though if you install multiple traps they need to be called Trap1, Trap2 etc and copy paste the above code in the onTokenmove for every trap.....(hmm I'm wondering what would happen if you would call all the Trap Tokens 'Trap' and use the above code...?-->just tested it, if you use step on the original 'Trap' and then on a new 'Trap' they're both triggered, after that the new 'Trap isn't triggered until you move over the original one again. In short: all traps have to have a unique name)

Edit:See att. The T-trap will now also 'talk' to you when triggered.
OK, I have tried getting this to work to no avail. The onTokenMove is not being kicked off when I move my token over the "Trap" token. I have tested this using the pause debugger and no coordinates are being passed to trapTriggered variable no matter what I try. The campaign file with the trap is located here: Test campaign


EDIT: Solved my problem by removing all of the other code out but the Trap stuff. I will add back in the other stuff as I need it. I also changed the output to work better for the FW I am using. Now to add code to have the tokens that have Trap Sense Rogue Talent to automatically roll the perception check before the Rogue arrives near the trap and stop the token if the perception beats the trap.

Post Reply

Return to “MapTool”