RPTools.net

Discussion and Support

Skip to content

It is currently Tue Jan 16, 2018 10:50 am 






Reply to topic  [ 11 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Dragon
 
Joined: Wed Oct 19, 2011 1:07 am
Posts: 958
 Post subject: X-ing out of an input window
PostPosted: Wed Oct 19, 2011 1:31 am 
Hi, everyone. First and foremost, I'd like to say that MapTool is awesome. I've been getting by learning how to use through the excellent resource material found here and in the tutorials. As the title of this post suggests, I've come across behavior that I couldn't find an answer to. When I use the "X" to close out an input window, it returns a nullpointer exception instead of returning a 0 that I was hoping for. Obviously, I want to catch this exception to avoid players inadvertently flooding the chat window with programmatic errors. Here's the code snippet:

[h: status = 0]
[while(status == 0), code: {
[status = input("radioStance| Full Attack, Attack, Defense, Full Defense, Center |Stance| RADIO | orient=h", "radioFacing| North, NE, East, SE, South, SW, West, NW |Facing| RADIO | orient=h")]
}]

I'm looping this to force player input as it is a combat function. I guess I won't need help on this if there was some way to control the modal to only have the "Ok" button sans the "Cancel" and "X" controls.

Thanks!

_________________
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: X-ing out of an input window
PostPosted: Wed Oct 19, 2011 7:21 am 
Couple things:

1) Program errors usually only show up in the window for the person who they affect, if I recall correctly.

2) Just put [h:abort(status)] inside the while loop, after the input call. If status is 0, which happens if they hit X or cancel, it will abort rather than throw errors. Like so:

Code:
[h: status = 0]
[while(status == 0), code: {
[status = input("radioStance| Full Attack, Attack, Defense, Full Defense, Center |Stance| RADIO | orient=h", "radioFacing| North, NE, East, SE, South, SW, West, NW |Facing| RADIO | orient=h")]
[h:abort(status)]
}]

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9439
Location: Netherlands
 Post subject: Re: X-ing out of an input window
PostPosted: Wed Oct 19, 2011 7:46 am 
Rumble wrote:
Couple things:

1) Program errors usually only show up in the window for the person who they affect, if I recall correctly.

2) Just put [h:abort(status)] inside the while loop, after the input call. If status is 0, which happens if they hit X or cancel, it will abort rather than throw errors. Like so:

Code:
[h: status = 0]
[while(status == 0), code: {
[status = input("radioStance| Full Attack, Attack, Defense, Full Defense, Center |Stance| RADIO | orient=h", "radioFacing| North, NE, East, SE, South, SW, West, NW |Facing| RADIO | orient=h")]
[h:abort(status)]
}]


I don't think that is correct (not sure though) IIRC if you 'cancel' then result = 0 if you 'x' then result = "". I remember running into this problem. Although what I did then was abort(status=input()) and although I would expect that not to work, it did...

ah here it is (its more different):
the following:
Code:
[input("x")]

results in
Quote:
Cancel:
« input("x") = input("x") = 0 »
Ok:
« input("x") = input("x") = 1 »
X:
« input("x") = Invalid expression: input("x"). »

so my abort() method won't work. Yours (rumble) will because you initialize 'status' and the macro continues after the 'invalid expression' ignoring that line'
In other words: a shorter version that will also work:
Code:
[status = 0]
[
status = input("x")]
[
h:abort(status)] 

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

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12107
Location: Tampa, FL
 Post subject: Re: X-ing out of an input window
PostPosted: Wed Oct 19, 2011 5:49 pm 
Wolph, is this current for b87? I thought this was one of the things I fixed for the b87 release. If it's still broken this way, please confirm and I'll look at it again and figure out what went wrong. Thanks.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7981
Location: Bay Area
 Post subject: Re: X-ing out of an input window
PostPosted: Wed Oct 19, 2011 7:55 pm 
confirmed. still gives an error.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9439
Location: Netherlands
 Post subject: Re: X-ing out of an input window
PostPosted: Thu Oct 20, 2011 12:15 am 
Yup. Ive fully switched to b87.

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

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Dragon
 
Joined: Wed Oct 19, 2011 1:07 am
Posts: 958
 Post subject: Re: X-ing out of an input window
PostPosted: Thu Oct 20, 2011 4:33 am 
Thanks Wolph and Rumble for the information and insights. Unfortunately, it still throws the exception even though I've tried both of your suggestions. Also, I don't really want to abort the loop on Cancel as it will break the chain of dependencies that follow after :) I've been programming a framework for about a month now and while the initial run was steep, it gets more rewarding everyday. I've gone through a lot of your materials and everyone's contributions are astounding I must say. Thanks for everything and I'll be glad to wait for any developments on this particular matter :)

_________________
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: X-ing out of an input window
PostPosted: Thu Oct 20, 2011 7:17 am 
Lee wrote:
Thanks Wolph and Rumble for the information and insights. Unfortunately, it still throws the exception even though I've tried both of your suggestions. Also, I don't really want to abort the loop on Cancel as it will break the chain of dependencies that follow after :) I've been programming a framework for about a month now and while the initial run was steep, it gets more rewarding everyday. I've gone through a lot of your materials and everyone's contributions are astounding I must say. Thanks for everything and I'll be glad to wait for any developments on this particular matter :)



Note: if you abort on a cancel, everything stops dead. It will not throw errors or break any dependencies; all macro processing is halted. Now, if you change something on a token before you do that and then abort, that change happens, but once abort is called, everything halts.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9439
Location: Netherlands
 Post subject: Re: X-ing out of an input window
PostPosted: Thu Oct 20, 2011 12:56 pm 
I think what you are looking for is a minor adjustment on rumbles suggestion:
Code:
[h: status = 0]
[while(status != 1), code: {
[status = input("radioStance| Full Attack, Attack, Defense, Full Defense, Center |Stance| RADIO | orient=h", "radioFacing| North, NE, East, SE, South, SW, West, NW |Facing| RADIO | orient=h")]
[h:abort(status)]
}]


This will repop the input if someone hits cancel. The only way to exit is by pressing ok.

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

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Dragon
 
Joined: Wed Oct 19, 2011 1:07 am
Posts: 958
 Post subject: Re: X-ing out of an input window
PostPosted: Thu Oct 20, 2011 9:33 pm 
Thanks guys, appreciate the time you took to help me with this. While these do work great in handling Cancel status, my real problem is when a user just clicks on the 'X' to close the window and not use Esc or the Cancel button. The window simply does not return anything, throwing a nullpointerexception. I'm not sure what triggers that without digging through the code for input() but even a simple [input("x")] will throw an NPE when closed through the 'X'

_________________
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12107
Location: Tampa, FL
 Post subject: Re: X-ing out of an input window
PostPosted: Fri Oct 21, 2011 12:41 am 
I've added this to my hitlist for b88.


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





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman