MapTool 1.3 Development Build 38

New build announcements plus site news and changes.

Moderators: dorpond, trevor, Azhrei, Craig

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

Post by Orchard »

Okay, so I still don't know the answer to my last question, and here I am with another....

Code: Select all

Roll {R=1d20}
Hit {RHit=if(R>=EnemyAC,1,0)}
AutoHit {RHit=if(R==20,1,RHit)}


For the above code assume that EnemyAC is either a token property that the GM is setting right before the macro is run OR that the user inputs. Whatever makes you happy.

THis is the error I get:

Could not execute the command: Invalid number of parameters 1, expected exactly 2 parameter(s)


It is directly linked to the last line of code, and, I presume, the inclusion of a variable in the FALSE parameter of the IF statement. I'm not sure why, I'm just passing a value of 1 or 0, trying to make sure that the previous value of RHit doesn't get lost. This was my way to get around the OR statement not working as expected (see my previous post).

So, halp?
0+0=1, for very unstable CPUs.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: What am I doing wrong?

Post by Craig »

Orchard wrote:Okay, in playing around with the new codes, I'm very curious...what have I broken? Both of these throw the same error:

Code: Select all

Roll {R=1d20}
Hit {RHit=if(R>=EnemyAC || R==20 ,1,0)}


Code: Select all

Roll {R=1d20}
Hit {RHit=if((R>=EnemyAC || R==20),1,0)}


This results in:
Could not execute the command: null


The question is: why?
It should be possible to say, logicallly IF R is equal to or greater than EnemyAC OR if R equals 20, then set RHit to 1, otherwise set RHit to 0. That's what I'm saying in the code, I think, but the parser disagrees and I'm not sure why.

Now, before I added the " || R==20" bit, things were moving along quite nicely, and I'm pleased with the new functionality. Muito bem.


It seems that == is not working within the if statement.

User avatar
Micco
Giant
Posts: 148
Joined: Mon Jun 16, 2008 10:21 pm

Post by Micco »

Orchard,

I get the same error when I test with Roll==20. But when I replace it with Roll > 19 it works fine. I think it is "The Bug That Eats Characters".

But, of course, that bug is now my main nemesis, so I naturally assume all evil falls at his feet.

User avatar
Brigand
Read-only User
Posts: 1623
Joined: Thu Feb 14, 2008 8:57 am
Location: Nosy GM's can go frak themselves!

Post by Brigand »

Hrm, not quite the implementation of an if/else statement I wanted. *sighs* I want to be able to do something like the following in the campaign macro editor, that the players can use, but not edit or see.

Code: Select all

miss = 10 + t.Defense
dodge = miss + t.Dodge + t.Agility
block = dodge + t.Block
parry = block + t.Parry
hit = parry + 10
crush = hit + 5
crit = crush + 1
attack = [1d(MeleeAP-t.DV)]

if (attack <= miss) {
 do stuff }
else if (attack > miss && attack <= dodge) {
 do more stuff }


And so on and so forth. All the t.Name variables are from the targeted token. The MeleeAP comes from token making the attack.

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

Post by Orchard »

Aria wrote:Hrm, not quite the implementation of an if/else statement I wanted. *sighs* I want to be able to do something like the following in the campaign macro editor, that the players can use, but not edit or see.

Code: Select all

miss = 10 + t.Defense
dodge = miss + t.Dodge + t.Agility
block = dodge + t.Block
parry = block + t.Parry
hit = parry + 10
crush = hit + 5
crit = crush + 1
attack = [1d(MeleeAP-t.DV)]

if (attack <miss> miss && attack <= dodge) {
 do more stuff }


And so on and so forth. All the t.Name variables are from the targeted token. The MeleeAP comes from token making the attack.


That reminds me of visual basic style (and several other scripting languages). The current implementation is more PHP or JavaScript, but even more limited.

It has it's uses, but what you are imagining is MUCH more complex to program, I'd guess.
0+0=1, for very unstable CPUs.

User avatar
Brigand
Read-only User
Posts: 1623
Joined: Thu Feb 14, 2008 8:57 am
Location: Nosy GM's can go frak themselves!

Post by Brigand »

Actually, I can write that in javascript as well. It's part of how I created my HTML character sheet for 4th edition:
http://www.ariagames.net/characters/aria.html

User avatar
Mathemagician
Dragon
Posts: 666
Joined: Tue May 22, 2007 2:27 pm

Post by Mathemagician »

So you can do "block style ifs":

Let's just say, you have a variable "flag", and you want to swap x and y if flag is true, but you want to do nothing if flag is false:
{temp=0}
{temp = if(flag>0,y,0)}
{y = if(flag >0,x,y)}
{x = if(flag >0,temp,x)}

So you can have a full block of code by repeating the if statement, and similarly you can have a full block for the "else" block. It's messy, but functional.

User avatar
Hawke
Great Wyrm
Posts: 2261
Joined: Sat Apr 21, 2007 12:12 am
Location: Albuquerque, NM
Contact:

Post by Hawke »

Aria wrote:Actually, I can write that in javascript as well. It's part of how I created my HTML character sheet for 4th edition:
http://www.ariagames.net/characters/aria.html


Jeez, now you just needa setup a generator so we can create our own versions and I'll use nothing but your charsheet! ;)

User avatar
Brigand
Read-only User
Posts: 1623
Joined: Thu Feb 14, 2008 8:57 am
Location: Nosy GM's can go frak themselves!

Post by Brigand »

It's more than just flipping x and y. I want to be able to do stuff based on a roll. I want to be able to put more commands inside each if/elseif statement, than just get back a true/false.

Code: Select all

if (attack <= miss) {
  /e You strike at the [t.Name], but fail to hit.
  }
else if (attack > miss && attack <= dodge) {
  /e The [t.Name] dodges out of the way of your attack.
  }
else if (attack > dodge && attack <= Hit) {
  /e You strike the [t.Name] for [DamageRoll].
  /stp t.HP = t.HP - DamageRoll
  }
else if (attack > hit && attack <= crush) {
  /e You strike [t.Name] with a crushing blow!
  /e Your attack deals [DamageRoll*2] crushing damage.
  /stp t.HP = t.HP - DamageRoll
  }

User avatar
giliath
RPTools Founder
Posts: 275
Joined: Tue Jan 31, 2006 11:10 am
Location: Austin, TX
Contact:

Post by giliath »

Aria, the more complex if then else you want will have to come when we do javascript integration. We have been talking about this for some time, but it just hasn't gotten to the top of the list.

My intention is to be very careful with how many things get added to the parser from a language perspective. There is a difference between adding support for a && b and adding support for and(a, b). Adding new functions like if(), etc... are virtually free. Adding support in the parser for operators like &&, ||, ==, etc... is more complex.
~Giliath

User avatar
trevor
Codeum Arcanum (RPTools Founder)
Posts: 11311
Joined: Mon Jan 09, 2006 4:16 pm
Location: Austin, Tx
Contact:

Post by trevor »

Great debugging folks.

We'll get formal scripting in there eventually, there are issues we are still working out (there's lots of discussion about it). This is the interim work.

We'll figure out the first/last char chomping issue and line up a new build for a couple days. Should be able to knock out a couple more issues.
Dreaming of a 1.3 release

User avatar
Micco
Giant
Posts: 148
Joined: Mon Jun 16, 2008 10:21 pm

Post by Micco »

Hey Giliath! I just want to say thank-you for the if() statement. It is making my macros <i>so</i> much easier to read (and to debug!)

It's much appreciated.

User avatar
giliath
RPTools Founder
Posts: 275
Joined: Tue Jan 31, 2006 11:10 am
Location: Austin, TX
Contact:

Post by giliath »

Micco wrote:Hey Giliath! I just want to say thank-you for the if() statement. It is making my macros <i>so</i> much easier to read (and to debug!)

It's much appreciated.


No problem, thanks to everyone for all the great feedback and bug reports. It is pretty cool to see something used this aggressively.
~Giliath

User avatar
UntoldGlory
Great Wyrm
Posts: 1649
Joined: Sun Mar 16, 2008 8:12 pm

Post by UntoldGlory »

giliath wrote:It is pretty cool to see something used this aggressively.


Heh, it's like tossing a cow into the pirranna pool!

User avatar
RPTroll
TheBard
Posts: 3148
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Post by RPTroll »

I don't have access to maptool right now but should the following work where Fighting is a property set to d8e?

Tundar rolls to hit {Att=if(state.shaken>0,0,Fighting)}

Hopefully this reuturns a 0 if the token is shaken


Edit:
Could someone put some examples out there that use token properties and states. Nothing too complex just a little something to get us started.

Post Reply

Return to “Announcements”