X-ing out of an input window
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
X-ing out of an input window
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!
[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
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: X-ing out of an input window
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:
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: Select all
[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)]
}]
Re: X-ing out of an input window
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...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: Select all
[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)] }]
ah here it is (its more different):
the following:
Code: Select all
[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'Cancel:
« input("x") = input("x") = 0 »
Ok:
« input("x") = input("x") = 1 »
X:
« input("x") = Invalid expression: input("x"). »
In other words: a shorter version that will also work:
Code: Select all
[status = 0]
[status = input("x")]
[h:abort(status)]
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
Re: X-ing out of an input window
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.
Re: X-ing out of an input window
confirmed. still gives an error.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: X-ing out of an input window
Yup. Ive fully switched to b87.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
Re: X-ing out of an input window
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
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: X-ing out of an input window
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.
Re: X-ing out of an input window
I think what you are looking for is a minor adjustment on rumbles suggestion:
This will repop the input if someone hits cancel. The only way to exit is by pressing ok.
Code: Select all
[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)]
}]
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
Re: X-ing out of an input window
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
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: X-ing out of an input window
I've added this to my hitlist for b88.