RPTools.net

Discussion and Support

Skip to content

It is currently Sat Nov 18, 2017 10:07 pm 






Reply to topic  [ 2 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Cave Troll
 
Joined: Sun Feb 13, 2011 10:51 pm
Posts: 28
 Post subject: Macro Cookbook confusion
PostPosted: Tue Jan 17, 2012 1:30 am 
I found the following in the Macro Cookbook:

--begin paste--
Checks the value of an attack result against a target's defense. If the attack is greater than or equal to the defense, it outputs "Hit!" or "Miss."

function HitCheck(attackResult,targetName,TargetDefense)

Code:
[h: attackResult = arg(0)]
[h: targetName = arg(1)]
[h: targetDefense = arg(2)]

[h: defenseValue = getProperty(targetDefense,targetName)]

[r,if(attackResult >= defenseValue): "Hit!"; "Miss."]
Thanks to Rumble for help with this macro.
-- End paste--

I can follow the code and I see how it is supposed to work, but how can I get a PLAYER token to obtain the rawProperty of a NPC token without also making that NPC token owned by all?

I admit that I am also recreating the wheel by trying to use these macros in a system that is not amazingly widespread, but I've done fairly well in reproducing the d10 and d100 system in the MapTool macros, but I don't follow how the arg(X) is assigned here, what rawProperties is it using, how it is obtaining them. Does anyone have a functioning example of this macro? Or have I simply done something wrong with the CODE section?

_________________
When all else fails, move a pawn.


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 3108
Location: Germany
 Post subject: Re: Macro Cookbook confusion
PostPosted: Tue Jan 17, 2012 4:10 am 
What you see there (the Wiki: arg() stuff) is an example for a user defined function (short UDF). So set up correctly (see Wiki: defineFunction()) you would use the macro you posted in any other macro by writing. (lets say we called the UDF HitCheck)
Code:
 HitCheck(1d20, "myToken", "Parry")

(This would assume that an attack with 1d20 is made agains myToken and his defense attribute would be called Parry.)

Why a UDF?

To access properties from an unowned token you need a macro to be "trusted". The most common way to create trusted macros is to have a Library token and have macros on it that are not player-editable.

You can call those macros using [macro:] but more convenient are UDFs (imho).

HTH

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

most complete list of my maptool stuff


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 2 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