Tool for building Input strings - Ready to eat

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Tool for building Input strings - Ready to eat

Post by bubblobill »

I got sick of always forgetting which bit goes where when making an input string.
So I made this. I just wish I had made it years ago.


Brought to you by Macros - Ready to Eat
*now with extra Robustitude!



Input String Builder
Screenshot
Screenshot
buildinput.png (30.12 KiB) Viewed 2680 times
It is recursive. Each time you press the button for an input type the string grows and an input box is presented to show you what you have done.

Here is the macro.
Build Input String.mtmacro
Version 4
(3.83 KiB) Downloaded 151 times
For those who are keen on code
Spoiler

Code: Select all

<!--This macro helps to build input strings by putting the right bits in the right places.-->
<!--bubblobill original created 30.06.2014-->
<!--last updated 05.07.2014-->

<!-- set up initial default variables-->
[h,code:{
[inData=macro.args][inType=''][inputDisplay=''][newString=''][prevStrings=json.fromList("")][runFrom=getMacroLocation()]
[TEXT="Text"]
	[txtvarName="myTextVar"][txtprompt="TextLabel"][txtspan=""][txtspanchk=""][txtvalue="DefaultText"][txtwidth="16"]
[LIST="Listbox"]
	[lstvarName="myListVar"][lstlabel="ListboxName"][lstspan=""][lstspanchk=""][lstvalue="String, List, Example"][lstindex="0"][lststring=""]
[CHECK="Checkbox"]
	[chkvarName="myCheckVar"][chkprompt="CheckboxName"][chkspan=""][chkspanchk=""][chkvalue="0"]
[RADIO="Radio button"]
	[radvarName="myRadioVar"][radprompt="RadioGroupName"][radspan=""][radspanchk=""][radvalues="String, List, Example"][radvalue="0"][radstring=""][radorient=""]
[LABEL="Label"]
	[lblprompt="LabelName"][lblvalue="<b>LabelContent</b>"][lblspan=""][lblspanchk=""]
[PROPS="Props"]
	[propvarName="myPropVar"][propprompt="PropListGroupName"][propspan=""][propspanchk=""][propvalue=encode("String=Prop; List=example")][propvar=""][propvar_=""]
[TAB="Tab"]
	[tabvarName="myTabVar"][tabvalue="TabName"][tabstart=""]
[SHOW="Show"]
}]

<!--test for first run, ie. have arguments been passed for processing-->
[h,if(!json.isEmpty(macro.args)==1),code:{

	<!--First run=FALSE, process form-->

	<!--set switch value to the input type button that was pressed-->
	[types="TEXT,LIST,CHECK,RADIO,LABEL,PROPS,TAB,SHOW"]
	[foreach(type,types):inType=add(inType,json.get(inData,type))]

	<!--set variables from arguments-->
	[varList=json.fields(inData)]
	[foreach(var,varList),CODE:{
		[value = json.get(inData,var)]
		[set(var,value)]
		}]
	[propvalue=decode(propvalue)]
	[prevStrings=decode(prevStrings)]

	<!--build input string from fields for appropriate type-->
	[switch(inType),code:
	case "Text":	{[newString=strformat("'%{newString}%{txtvarName}|%{txtvalue}|<html>%{txtprompt}</html>|TEXT|WIDTH=%{txtwidth} %{txtspan}'")]};
	case "Text":	{[newString=strformat("'%{newString}%{txtvarName}|%{txtvalue}|<html>%{txtprompt}</html>|TEXT|WIDTH=%{txtwidth} %{txtspan}'")] };
	case "Listbox":	{[newString=strformat("'%{newString}%{lstvarName}|%{lstvalue}|<html>%{lstlabel}</html>|LIST|%{lstspan} %{lststring} SELECT=%{lstindex}'")]};
	case "Checkbox":{[newString=strformat("'%{newString}%{chkvarName}|%{chkvalue}|<html>%{chkprompt}</html>|CHECK|%{chkspan}'")]};
	case "Radio button":	{[newString=strformat("'%{newString}%{radvarName}|%{radvalues}|%{radprompt}|RADIO|SELECT=%{radvalue} %{radspan} %{radstring} %{radorient}'")]};
	case "Label":	{[newString=strformat("'%{newString}junkvar|<html>%{lblvalue}</html>|%{lblprompt}|LABEL|%{lblspan}'")]};
	case "Props":	{[newString=strformat("'%{newString}%{propvarName}|%{propvalue}|%{propprompt}|PROPS|%{propspan} %{propvar} %{propvar_}'")]};
	case "Tab":		{[newString=strformat("'%{newString}%{tabvarName}|%{tabvalue}||TAB|%{tabstart} '")]};
	case "Show":	{[newString=" ")]}
	]
	
	
	<!-- append strings together into a display string and clean-->
	[if(prevStrings==""): inputDisplay=newString; inputDisplay = strformat ("'%{prevStrings}'%{newString}")]
	[inputDisplay=replace(inputDisplay,"&#"+59,";")]
	[inputDisplay=replace(inputDisplay,"<(.*?)>","<\$1>")]
	[inputDisplay=replace(inputDisplay,"''"," ## ")]
	};{

	<!--First run=TRUE-->
	[h, if (runFrom == "token"):setSpeech("input","");""]

}]


<!--declare strings for putting together form-->
[h, switch(runFrom):
	case "campaign":formLink = macroLinkText("Build Input String@campaign","","","");
	case "global":	formLink = macroLinkText("Build Input String@global","","","");
	default:		formLink = macroLinkText("Build Input String@token","self","","selected")
	]

[h:CHECKED=string('CHECKED="CHECKED"')][h:SPAN=string('SPAN=TRUE')][h:STRINGVALUE=string('VALUE=STRING')]

<!--set form checkboxes checked value from previous run-->
[h,code:{
[txtspanchk=if(txtspan==SPAN,CHECKED,"")]
[lstspanchk=if(lstspan==SPAN,CHECKED,"")]
[chkspanchk=if(chkspan==SPAN,CHECKED,"")]
[radspanchk=if(radspan==SPAN,CHECKED,"")]
[lblspanchk=if(lblspan==SPAN,CHECKED,"")]
[propspanchk=if(propspan==SPAN,CHECKED,"")]
[chkvaluechk=if(chkvalue==1,CHECKED,"")]
[lststringchk=if(lststring==STRINGVALUE,CHECKED,"")]
[radstringchk=if(radstring==STRINGVALUE,CHECKED,"")]
[radorientchk=if(radorient=="ORIENT=H",CHECKED,"")]
[propvarchk=if(propvar=="SETVARS=UNSUFFIXED", CHECKED,"")]
[propvar_chk=if(propvar_=="SETVARS=SUFFIXED",CHECKED,"")]
}]

[h:css='<style>
table.mytable 		{ color:black }
table.mytable th 	{ background-color: #660066; font-weight:bold; color:white }
table.mytable tr	{ background-color: #C0C0C0 }
table.mytable .alt 	{ background-color: #FFFFFF }
table.table2 tr td 	{ background-color: #FFFFEE; color: black }
table.table2 .note 	{ background-color: #FFFFFF; color: blue }
</style>']

<!--create form HTML string for display-->
[h:displayString='<html>
<head>
<title>Build input string</title>
'+css+'
</head>
<form action="'+formLink+'" method=json >

<table width=100% class="mytable">
	<tr>
		<th></th>
		<th>Variable name							</th>
		<th>Label / Prompt / Tooltip				</th>
		<th>Hide<br>label							</th>
		<th colspan=2>Prefill / value				</th>
		<th colspan=2 align=right width=80>Options	</th>
		<th colspan=5>								</th>
		</tr>
	<tr>
		<td align=right bgcolor=#A0A0A0><input type="submit" name="TAB" value="Tab">											</td>
		<td align=right>				<input type="text" name="tabvarName" size="18" maxlength="" value="'+tabvarname+'">		</td>
		<td align=right>				<input type="text" name="tabvalue" size="18" maxlength="" value="'+tabvalue+'">	</td>
		<td>																													</td>
		<td>																													</td>
		<td>																													</td>
		<td>																													</td>
		<td align=right>				Starting tab		</td><td><input type="checkbox" name="tabstart" value="SELECT=TRUE"></td>
		</tr>
	<tr class="alt">
		<td align=right bgcolor=#A0A0A0><input type="submit" name="TEXT" value="Text">													</td>
		<td align=right>				<input type="text" name="txtvarName" size="18" maxlength="" value="'+txtvarName+'">				</td>
		<td align=right>				<input type="text" name="txtprompt" size="18" maxlength="" value="'+txtprompt+'">				</td>
		<td align=center>				<input type="checkbox" name="txtspan" value="SPAN=TRUE" '+txtspanchk+'>						</td>
		<td align=right colspan=2>		<input type="text" name="txtvalue" size="18" maxlength="" value="'+txtvalue+'">					</td>
		<td align=right colspan=2>		Field width																						</td>
		<td>							<input type="text" name="txtwidth" size="3" maxlength="" value="'+txtwidth+'">					</td>
		</tr>

	<tr>
		<td align=right bgcolor=#A0A0A0><input type="submit" name="LIST" value="Listbox">															</td>
		<td align=right>				<input type="text" name="lstvarName" size="18" maxlength="" value="'+lstvarName+'">							</td>
		<td align=right>				<input type="text" name="lstlabel" size="18" maxlength="" value="'+lstlabel+'">								</td>
		<td align=center>				<input type="checkbox" name="lstspan" value="SPAN=TRUE" '+lstspanchk+'>										</td>
		<td align=right colspan=2>		<input type="text" name="lstvalue" size="18" maxlength="" value="'+lstvalue+'">								</td>
		<td align=right colspan=2>		Preselect index		</td><td><input type="text" name="lstindex" size="3" maxlength="" value="'+lstindex+'">	</td>
		<td align=right>				Set string not no.	</td><td><input type="checkbox" name="lststring" value="VALUE=STRING" '+lststringchk+'>	</td>
		</tr>

	<tr class="alt">
		<td align=right bgcolor=#A0A0A0><input type="submit" name="CHECK" value="Checkbox">												</td>
		<td align=right>				<input type="text" name="chkvarName" size="18" maxlength="" value="'+chkvarName+'">				</td>
		<td align=right>				<input type="text" name="chkprompt" size="18" maxlength="" value="'+chkprompt+'">				</td>
		<td align=center>				<input type="checkbox" name="chkspan" value="SPAN=TRUE" '+chkspanchk+'>							</td>
		<td align=right>				Checked				</td><td><input type="checkbox" name="chkvalue"value="1" '+chkvaluechk+'>	</td>
		</tr>

	<tr>
		<td align=right bgcolor=#A0A0A0><input type="submit" name="RADIO" value="Radio button">														</td>
		<td align=right>				<input type="text" name="radvarName" size="18" maxlength="" value="'+radvarName+'">							</td>
		<td align=right>				<input type="text" name="radprompt" size="18" maxlength="" value="'+radprompt+'">							</td>
		<td align=center>				<input type="checkbox" name="radspan" value="SPAN=TRUE" '+radspanchk+'>										</td>
		<td align=right colspan=2>		<input type="text" name="radvalues" size="18" maxlength="" value="'+radvalues+'">							</td>
		<td align=right colspan=2>		Preselect index		</td><td><input type="text" name="radvalue" size="3" maxlength="" value="'+radvalue+'">	</td>
		<td align=right>				Set string not no.	</td><td><input type="checkbox" name="radstring" value="VALUE=STRING", '+radstringchk+'></td>
		<td align=right>				Horizontal			</td><td><input type="checkbox" name="radorient" value="ORIENT=H" '+radorientchk+'>		</td>
		</tr>

	<tr class="alt">
		<td align=right bgcolor=#A0A0A0><input type="submit" name="LABEL" value="Label">									</td>
		<td>																												</td>
		<td align=right>				<input type="text" name="lblprompt" size="18" maxlength="" value="'+lblprompt+'">	</td>
		<td align=center>				<input type="checkbox" name="lblspan" value="SPAN=TRUE" '+lblspanchk+'>				</td>
		<td align=right colspan=2>		<input type="text" name="lblvalue" size="18" maxlength="" value="'+lblvalue+'">		</td>
		<td>																												</td>
		<td>																												</td>
		<td>																												</td>
		</tr>

	<tr>
		<td align=right bgcolor=#A0A0A0><input type="submit" name="PROPS" value="Props">																</td>
		<td align=right>				<input type="text" name="propvarName" size="18" maxlength="" value="'+propvarName+'">							</td>
		<td align=right>				<input type="text" name="propprompt" size="18" maxlength="" value="'+propprompt+'">								</td>
		<td align=center>				<input type="checkbox" name="propspan" value="SPAN=TRUE" '+propspanchk+'>										</td>
		<td align=right colspan=2>		<input type="text" name="propvalue" size="18" maxlength="" value="'+decode(propvalue)+'">						</td>
		<td align=right colspan=2>		Set variables (var)	</td><td><input type="checkbox" name="propvar" value="SETVARS=UNSUFFIXED" '+propvarchk+'>	</td>
		<td align=right>				Set variables (var_)</td><td><input type="checkbox" name="propvar_" value="SETVARS=SUFFIXED" '+propvar_chk+'>	</td>
		</tr>
		
	<tr class="alt">
		<td align=right bgcolor=#A0A0A0><input type="submit" name="SHOW" value="Show">																</td>
			<td colspan=12>
			<!--display complete string-->
				<table width=100% border=1>
					<table border=0 width=100% class="table2">
					<td></td><td align=center><b>Input String</b></style></td><td></td>
						<tr>
							<td width=4%></td>
							<td width=92% border=1 height=90 class="note" align=center><textarea name="prevStrings" cols="104" rows="7">'+decode(inputDisplay)+'</textarea>
							<td width=4%></td>
							</tr>
						<tr>
							<td></td><td></td><td></td>
							</tr>
					</table>
				</table>
			</td>
		</tr>
</table>
</form>
</html>']

<!--output to chat with ## separator and html -->
[r:inputDisplay]
[h:inString=replace(inputDisplay,"<(.*?)>","<\$1>")]
[h:input(inString)]
[h, if (runFrom == "token"):setSpeech("input",inString);""]
<br>

<!--display completed dialog form-->
[r,dialog('Input String Builder','width=1050; height=480; temporary=0;'):
{
[r:displayString]
}]
Enjoy and share the love
:mrgreen:

Updated 03/07/2014 with new code and new improved macro.
Updated 04/07/2014 with new screenshot, macro, code, and added dessert flavour menu.
Updated 05/07/2014 with new macro and code that support running from Campaign frame without storing string in "speech"
Last edited by bubblobill on Fri Jul 04, 2014 11:21 pm, edited 3 times in total.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Tool for building Input strings - Ready to eat

Post by wolph42 »

That is pretty cool!

A few suggestions:

- it appears that the tab needs to be fixed, right?
- A neater label is the following "junk|<html><b>A label that spans accross the entire box</b></html>|and here you can put a tooltip text|LABEL|SPAN=TRUE"
- it would also nice if you could edit the output string, not sure how much hassle that would be?
- and for that matter, it would also be nice to have the output string formatted with linebreaks for each line.
- finally a 'delete last line' although, if you can edit the output string, then thats would make this redundant!

As this is a pretty cewl tool, I would like to add it to the bag of tricks (when finished). Is that something you could find yourself agreeing with (with the proper reference to you obviously).

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Tool for building Input strings - Ready to eat

Post by Full Bleed »

Nifty tool!

I always have to look at code examples when building and tweaking input strings.

I will be giving this a test drive soon.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Improved Tool for building Input strings - Ready to eat

Post by bubblobill »

Now new and updated with spicier flavour!

I have updated the original post with the new code and macro file.

Apparently there was nothing wrong with Tab, I had just forgotten how to use it. If you don't start with Tab, you don't get Tab.


The new version now has HTML tags encoded into the fields for Text, List box, Check box, and Label input types. This means you can just enter any formatting you desire in the appropriate fields, check the Hide Label box (ie. set SPAN=TRUE) and you get your fancy Tooltips.


Dear Mr Lupus 42, I originally spent a day and a half trying to get the resulting string editable until I gave up in disgust. Text areas and forms do some really weird things in Maptool. Because you asked, I just spent another six hours on it, and now it works. I hope you feel appreciated and loved.


It can now be said to be fully functional. If people could give it a workout; crash-test it; and generally determine its worthiness, that would be cool.

Feel free to stick it in the bag'o'tricks if it performs well enough. Then I will be famous too. :D

Bubblo
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Improved Tool for building Input strings - Ready to eat

Post by wolph42 »

bubblobill wrote:Dear Mr Lupus 42, I originally spent a day and a half trying to get the resulting string editable until I gave up in disgust. Text areas and forms do some really weird things in Maptool. Because you asked, I just spent another six hours on it, and now it works. I hope you feel appreciated and loved.



Feel free to stick it in the bag'o'tricks if it performs well enough. Then I will be famous too. :D

Bubblo
I suddenly feel very much loved! I also feel your pain as I'm far too familiar with this. Especially when regex rears it head.

And yes my bag of tricks will certainly make you famous :twisted:

User avatar
Altrunchen
Giant
Posts: 135
Joined: Sun Dec 02, 2012 3:01 pm

Re: Tool for building Input strings - Ready to eat

Post by Altrunchen »

So I tried importing this into my campaign but every time I try running it I get this error:

Code: Select all

Macro not found: "Build Input String@token".
What exactly is going on?
Image

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: Tool for building Input strings - Ready to eat

Post by bubblobill »

Altrunchen wrote:So I tried importing this into my campaign but every time I try running it I get this error:

Code: Select all

Macro not found: "Build Input String@token".
What exactly is going on?

This is a good question.

I hardly ever use macros from anywhere other than a token so this was not written to be run from the Campaign frame. Running from anywhere other than a token caused it to have conniptions.
Thanks to you though, this is now fixed. It will now run from the Campaign window/frame.

Grab the new version from the original post and you should be running sweetly.

Bubblobill
Who's got your nose?
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework


User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: Tool for building Input strings - Ready to eat

Post by bubblobill »

Woot! Famousness here I come.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Post Reply

Return to “User Creations”