Can a countdown marco be coded in Maptool?

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. :)
Post Reply
User avatar
barinax
Giant
Posts: 244
Joined: Thu Jun 19, 2008 2:50 pm
Contact:

Can a countdown marco be coded in Maptool?

Post by barinax »

Hey everyone,

Due to some extremely slow players, I am enforcing a time limit on their turns. Is there a way that a countdown timer can be encoded in Maptool? Something that just countdowns from X to 0 and then makes a sound when complete?

I did a search and there seems to be a stopwatch, but not a countdown timer.

Thanks!

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

Re: Can a countdown marco be coded in Maptool?

Post by CoveredInFish »

It can be done (you cannot play a sound but send a chat message or alike). I doubt it is worth it.

You can measure time (see the stopwatch code but its all about Wiki: getInfo()). So run a little loop, check if the timed time is over and if not DEFER (see execLink) to the same macro again. If time IS over send a chat message.

IIRC the client this macro runs on is not blocked but slowed down a little (since the macro execution is deferred - this is key). Maybe I'm forgetting details here ... you might want to search for animation macros by wolph42 or aliasmask, they used the very same technique.

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Can a countdown marco be coded in Maptool?

Post by mfrizzell »

How about an egg timer and an open mic?

Depending on how much time you are giving them it may not be practical. I'm not sure of the details but it would have to be done with loops and I believe the problem lays in that there is a limit to how many iterations a loop can run and the time to run through that limit is very small.

Sorry
Hopefully one of the great ones has a more constructive idea.

Edit: Ninja'ed
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Can a countdown marco be coded in Maptool?

Post by aliasmask »

I have some tools in lib:players that can help. I use a timer, default 30 seconds when loading. The server is set to first player logging on, but if everyone is logged on and the campaign is loaded, it's difficult to know who the server is. The best guess is sent to the player asking them if they are the server and the others have to wait for the player before continuing. Basically, you sent the condition to exit the timer and when met it runs a specified macro. It also has a built in time limit when the condition is not met by that time and exits the process (which could be changed to another macro).

Code: Select all

@@ @deferCondition
[H: "<!-- deferCondition(macroName,args,deferConditions[,token]) -->"]
[H: deferArgs = macro.args]
[H: macro = arg(0)]
[H: args = arg(1)]
[H: condition = arg(2)]
[H, if(argCount() >= 4): token = arg(3); token = ""]
[H: startTime = json.get(condition,"startTime")]
[H: timeLimit = json.get(condition,"timeLimit")]
[H: time = json.get(getInfo("client"),"timeInMs")]
[H: hasExpired = 0]
[H, (! json.isEmpty(startTime) && ! json.isEmpty(timeLimit)), code: {
   [H, if(abs(time - startTime) >= timeLimit): hasExpired = 1]
};{}]
[H: result = json.get(json.evaluate(condition),"result")]
[H, if(result), code: {
   [H: am.play.output(strformat('<i>Player "%s" is continuing execution...</i>',getPlayerName()))]
   [H: link = macroLinkText(macro,"none",args,token)]
}; {
   [H: noUpdate = 0]
   [H, if(json.isEmpty(startTime)): condition = json.set(condition,"startTime",json.get(getInfo("client"),"timeInMs")); noUpdate = noUpdate + 1]
   [H, if(json.isEmpty(timeLimit)): condition = json.set(condition,"timeLimit",30000); noUpdate = noUpdate + 1]
   [H, if(noUpdate < 2), code: {
      [H: deferArgs = json.set(deferArgs,2,condition)]
      [H: startTime = json.get(condition,"startTime")]
      [H: timeLimit = json.get(condition,"timeLimit")]
   }; {}]
   [H, if(hasExpired): assert(0,strformat('<i>Time Expired for macro "%{macro}".</i>'),0)]
   [H: link = macroLinkText("deferCondition@"+getMacroLocation(),"none",deferArgs,getMacroLocation())]
}]
[H: execLink(link,1)]

!!  

Post Reply

Return to “MapTool”