scripting?

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. :)
User avatar
Orchard
Great Wyrm
Posts: 1852
Joined: Fri May 09, 2008 10:45 am
Location: Doylestown PA
Contact:

Post by Orchard »

ltwally wrote:Current Quest: is there a round() function? (So that when I do a LEVEL/2, I can chop off the .5 at the end of odd levels.)

Nevermind - I found it. ;)
there is also a floor() function, which you may prefer...it always rounds down, which is more appropriate for D&D style stuff...since it follows the rules of rounding for D&D.
0+0=1, for very unstable CPUs.

User avatar
syntruth
Giant
Posts: 241
Joined: Mon Aug 18, 2008 7:15 pm
Location: Michigan, USA

Post by syntruth »

Sorta off-topic, but maybe something the devs could some day look into us using LuaJava to include an actual scripting language. Maybe for the some day 1.4 branch. :) An actual language (and Lua is easy to learn/use) could open up so many possibilities.

User avatar
Orchard
Great Wyrm
Posts: 1852
Joined: Fri May 09, 2008 10:45 am
Location: Doylestown PA
Contact:

Post by Orchard »

syntruth wrote:Sorta off-topic, but maybe something the devs could some day look into us using LuaJava to include an actual scripting language. Maybe for the some day 1.4 branch. :) An actual language (and Lua is easy to learn/use) could open up so many possibilities.
There's been talk of a number of scripting languages, but I think the default choice will probably be javascript.

I keep hounding on multisupport, with python, javascript and others making the regular mention. But lua sounds good to me.

Essentially anything that has a free java plugin has a pretty good chance of making it.

It will happen someday, but 1.4 is a good timeline.
0+0=1, for very unstable CPUs.

User avatar
ltwally
Cave Troll
Posts: 88
Joined: Tue Nov 14, 2006 12:16 pm
Location: Phoenix, AZ, USA
Contact:

Post by ltwally »

Yeah, I've been using FLOOR().

Having a hard time with EVAL(), though.

Here is some sample code for a healing spell. I think it's pretty obvious:

Code: Select all


Myself or one ally can spend a healing surge plus [eval(floor(LEVEL/5), "d6")] hp.

It doesn't work though. Not at all. Not when LEVEL is 5, or 6, or 200.

I've tried replacing the comma in EVAL with a +. That did nothing to fix it.

Any ideas?

User avatar
Mr. Pokeylope
Giant
Posts: 118
Joined: Mon Aug 11, 2008 9:24 pm

Post by Mr. Pokeylope »

ltwally wrote:Yeah, I've been using FLOOR().

Having a hard time with EVAL(), though.

Here is some sample code for a healing spell. I think it's pretty obvious:

Code: Select all

Myself or one ally can spend a healing surge plus [eval(floor(LEVEL/5), "d6")] hp.
It doesn't work though. Not at all. Not when LEVEL is 5, or 6, or 200.

I've tried replacing the comma in EVAL with a +. That did nothing to fix it.

Any ideas?
Try [eval("" + floor(LEVEL/5) + "d6")]. By starting with a string, you force it to interpret + as concatenation instead of addition. (Of course, I'm at work at the moment and can't test it, but I think that should work.)

You don't actually need eval in this case, though; you can use [roll(floor(LEVEL/5), 6)].

User avatar
ltwally
Cave Troll
Posts: 88
Joined: Tue Nov 14, 2006 12:16 pm
Location: Phoenix, AZ, USA
Contact:

Post by ltwally »

I ended up giving up on EVAL(). Turns out it wasn't really necessary.

Code: Select all

<br>Myself or one ally can spend a healing surge plus <b>{roll(min(floor((LEVEL-1)/5),5)+1,6)}</b> hp.
It's not super-pretty... but it works.

User avatar
BigO
Dragon
Posts: 558
Joined: Mon Jul 28, 2008 12:23 pm
Location: Oshkosh, WI
Contact:

Post by BigO »

ltwally wrote:I ended up giving up on EVAL(). Turns out it wasn't really necessary.

Code: Select all

<br>Myself or one ally can spend a healing surge plus <b>{roll(min(floor((LEVEL-1)/5),5)+1,6)}</b> hp.
It's not super-pretty... but it works.
Yeah, that's what I was going to suggest. eval is mostly used when storing dice rolls in properties. If you have a propterty called FOO with a value of d6 and you have this macro:

Code: Select all

You did {FOO} damage
You will get:

Code: Select all

You did d6 damage
So you have to use eval:

Code: Select all

You did {eval(FOO)} damage
Which might get you:

Code: Select all

You did 4 damage
Of course some people don't like using eval, so your other option is to store the brackets in the property like {d6} then it will parse it when run and you don't have to use eval.
--O

I am a small and fragile flower.
http://maptool.rocks.andyousuck.com

User avatar
loogie
Dragon
Posts: 267
Joined: Wed Sep 05, 2007 4:53 pm
Contact:

Post by loogie »

as for more scripting logic don't expect must for 1.3... build 1.3 is in its polishing stages, so no new updates will be made... trevor will be starting 1.4 in the near future (near as in whenever people stop finding bugs for 1.3) and with 1.4 there are a lot of new additions trevor plans... from what i've heard, he wants to allow much more then just scripting, but building of modules and such to create addons... of course everything is subject to when he actually starts working on it... but with the extra help he's been getting recently... we can expect great things from rptools... a hazzah to the new devs, and the head dev trevor!

User avatar
ltwally
Cave Troll
Posts: 88
Joined: Tue Nov 14, 2006 12:16 pm
Location: Phoenix, AZ, USA
Contact:

Post by ltwally »

Another scripting question:

Does anyone know of a way to do some math and have the results stored in a variable without it being displayed in the chat window??

In some of my macros, I have really long damage rolls. I store them in variables so I can display the result in multiple places, and show things like half-damage on a miss and such. But that huge ugly roll at the top... undesirable.

If you have any ideas: Thanks!!

User avatar
BigO
Dragon
Posts: 558
Joined: Mon Jul 28, 2008 12:23 pm
Location: Oshkosh, WI
Contact:

Post by BigO »

ltwally wrote:Another scripting question:

Does anyone know of a way to do some math and have the results stored in a variable without it being displayed in the chat window??

In some of my macros, I have really long damage rolls. I store them in variables so I can display the result in multiple places, and show things like half-damage on a miss and such. But that huge ugly roll at the top... undesirable.

If you have any ideas: Thanks!!
Before build b41 I liked to use html comments:

Code: Select all

<!-- [MyRoll=d20] -->You do {MyRoll} damage!
But after b41 (actually I think this was in b40 as well) you can do this:

Code: Select all

[H:MyRoll=d20]You do {MyRoll} damage!
The H: option hides the output.
--O

I am a small and fragile flower.
http://maptool.rocks.andyousuck.com

User avatar
ltwally
Cave Troll
Posts: 88
Joined: Tue Nov 14, 2006 12:16 pm
Location: Phoenix, AZ, USA
Contact:

Post by ltwally »

That does the trick. And it even leaves the output in the history logs (and if everyone knows that up front, no one will be tempted to be naughty boys or girls).

Thanks!

Post Reply

Return to “MapTool”