RPTools.net

Discussion and Support

Skip to content

It is currently Mon May 20, 2013 2:00 am 






Reply to topic  [ 6 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Sun Mar 18, 2012 7:56 pm
Posts: 9
 Post subject: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Sun Mar 25, 2012 12:41 pm 
I'm trying to figure out a way to set up my tokens so that if a token gets added to the screen, I can roll the hit points automatically, provided that I've set up the HD beforehand.

Is there an event for the token being added to the map? Essentially, if the token's HP are blank then roll, otherwise keep the current value.


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 2683
Location: Germany
 Post subject: Re: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Sun Mar 25, 2012 1:21 pm 
There is no real event for newTokenDropped.

You can do a trick. The default property values can include macro code. You can place a roll-and-overwrite macro there. It happens not on drop - but when statsheet is shown.

So, if your token has a set value the property (lets call it HP) contains that value. The default is a macro like [r: HP = 1d10]

If it is shown it rolls hitpoints and overwrites the default value, so next time the stat sheet is shown nothing happens.

Whew ... is that understandable? :?:
Search the forum for "stat sheet trick" or something like that .. there are several postings about that. I dont know the exact format how to include macro in the property set out of my head, but try-and-error or forum search should bring it.

_________________
"Cif's html works" (confirmed by independent studies)

most complete list of my maptool stuff


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Jul 30, 2009 6:53 pm
Posts: 22
 Post subject: Re: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Mon Mar 26, 2012 3:56 pm 
This is why I love browsing the macros section: people asking questions I thought I already knew the answer to and finding out I'm wrong. Swapping all my tokens to this!


Top
 Profile  
 
 Offline
Kobold
 
Joined: Fri Mar 23, 2012 3:45 am
Posts: 13
 Post subject: Re: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Tue Mar 27, 2012 2:06 am 
Neat trick

So is there a way to get this to run more complex code? At the moment I can figure out how to assign properties values, but not much else.

Ultimately I'm thinking of having the code set properties based on user input. Can this be done?

_________________
Fighting Fantasy Framework


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 2683
Location: Germany
 Post subject: Re: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Tue Mar 27, 2012 2:25 am 
You can only include one line of code. But since you can call other macros - at least as user defined function (see Wiki: defineFunction()), but IIRC with [macro:] as well - you can call as complex code as you want. Be sure to test it well, you dont want the statsheet to call a buggy macro!

_________________
"Cif's html works" (confirmed by independent studies)

most complete list of my maptool stuff


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 5488
Location: Netherlands
 Post subject: Re: Auto Roll Hit Points for token being dropped on a map.
PostPosted: Tue Mar 27, 2012 5:22 am 
I initially came up with this trick, its actually one of the first code tricks I introduced into the community a loooong time ago.... and I also abandoned it again for another trick, with the same results, but 'safer'
Fitst of I created a small drop in which can help you use this onMouseOver event, you can find the link on how to use it in my signature and a small wiki article I wrote: onMouseOverEvent

Second: the trick for which I swapped this one is the (actually existing) onChangeSelection. To use this you will need a form active, this can be an info box, a character sheet, or in my case: token related macros. The trick then is simple:
1. first you need a token property (preset in the settings) e.g. 'initialize:1'
2. in the form you need one line
Code:
<link rel='onChangeSelection' type='macro' href='macroLink'> 
where 'macroLink' is an actual macro link to a macro.
3. the macro is run EVERY time you select on a token (thus also when you just click on it). In my case I check the token property set of the token e.g. 'vehicle' and then redirect the macro to another macro that builds the form with macro buttons specifically for vehicles. To start the 'token initializer' you simply need a couple of lines of code:
Code:
<!-- make sure only one token is selected -->
[
me = getSelected()]
[
abort(listCount(me) != 1)]
<!--
 make that token currentToken -->
[
switchToken(me)]
<!--
 if the token has not been initialized, do so now -->
[if(
initilize): initializeToken()] 

In the 'initializeToken' you obviously need to set 'initialize = 0' or the macro will be invoked every time you select the token.

This boils roughly down to the method using the onMouseOverEvent, but this is more stable.

_________________
My stuff
Excel Tools: Table editor and Illumination Generator
MT Tools: Dungeon Builder Tool, Bag of Tricks: Teleport pads, Pits, Traps and Warded Areas and onMouseOverEvent
Framework: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade and Only War
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow

My dropbox referral. If you use this then both you and me get 500Mb extra space. 2.5Gb total.


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 0 users online :: 0 registered, 0 hidden and 0 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 0 guests





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman