Summon Tokens macro broke after upgdating to v1.7.0

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. :)
Post Reply
User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Summon Tokens macro broke after upgdating to v1.7.0

Post by Oryan77 »

I've used this macro for years without issues. Now when I use it I get the message:

Code: Select all

java.lang.NullPointerException error executing expression abort(eval(inputStr)).
Am I forgetting to do something after updating Maptool? Or does this mean I need to update java perhaps?

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Summon Tokens macro broke after upgdating to v1.7.0

Post by Phergus »

Oryan77 wrote:
Sun Jul 12, 2020 1:20 pm
Am I forgetting to do something after updating Maptool? Or does this mean I need to update java perhaps?
None of the above.

You'll need to post the whole macro. At a guess, I'd say your

Code: Select all

inputStr
is null but why that has happened is what needs to be determined.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Summon Tokens macro broke after upgdating to v1.7.0

Post by Oryan77 »

I'm just using the Summon Token macro that has been in the BoT for years. I know Wolph42 did some slight updates to it in his BoT but I am not using that version at the moment. I did test his new version out of curiosity and the macro still does not work for me now. The same macro worked just fine in the past on older version of MT.

Here is the summonToken code:

Code: Select all

[H: '<!-- summonToken -->']
[H: '<!-- based on Orpheus WoD campaign macro -->']
[h:me = getSelected()]
[h:assert(listCount(me) <= 1, "Make sure only one token is selected",0)]
[h, if(listCount(me) == 1), CODE:{
	[switchToken(me)]
	[h: X = getTokenX(0)]
	[h: Y = getTokenY(0)]
	[H: PrimePC	= getName() ]
}; {
	[h: X = 0]
	[h: Y = 0]
	[H: PrimePC	= ""]
}]

[h, if(argCount() > 0): useCurrentMap = arg(0); useCurrentMap = 0]
[h, if(argCount() > 1): conditions = arg(1); conditions = "{}"]

[H: '<!-- no new scope!! -->']
[h: bot_getValidTokens(useCurrentMap, conditions)]

[H: '<!-- User choice of what to use, at which level, on who -->']
[h:inputStr		= "junk|<html><b>Summon Token</b> - More token types can be added from the Settings macro</html>|-|LABEL|SPAN=TRUE"]
[h,if(listCount(fancyPCList)	> 1):	inputStr = listAppend(inputStr, "pcNumber | " 	+ fancyPCList	+ " | PC | LIST | ICON=TRUE  ICONSIZE=30", '@')		; pcNumber		= 0]
[h,if(listCount(fancyNPCList)	> 1):	inputStr = listAppend(inputStr, "npcNumber | " 	+ fancyNPCList	+ " | NPC | LIST | ICON=TRUE  ICONSIZE=30", '@')	; npcNumber		= 0]
[h,if(0 && listCount(fancyCharList)	> 1):	inputStr = listAppend(inputStr, "charNumber | "	+ fancyCharList	+ " | (N)PC | LIST | ICON=TRUE  ICONSIZE=30", '@')	; charNumber	= 0]
[h,if(0 && listCount(fancyAllList)	> 1):	inputStr = listAppend(inputStr, "allNumber | " 	+ fancyAllList	+ " | ALL | LIST | ICON=TRUE  ICONSIZE=30", '@')	; allNumber		= 0]

[h, foreach(propType, propTypesList), CODE:{
	[fancyList	= eval("fancy"+propType+"List")]
	[if(listCount(fancyList)	> 1):	inputStr = listAppend(inputStr, propType + "Number | " + fancyList + " | "+propType+" | LIST | ICON=TRUE  ICONSIZE=30", '@') ; set(propType + "Number", 0)]
}]
[h, if(listCount(fancySpecialList) > 1):inputStr 	= listAppend(inputStr, "specialNumber | " 	+ fancySpecialList	+ " | Special | LIST | ICON=TRUE  ICONSIZE=30", '@')]

[h:'<!-- ask for number -->']
[h:inputStr		= listAppend(inputStr,"junk|<html><b>Number of each selected token to summon:</b></html>|-|LABEL|SPAN=TRUE", '@')]
[h:inputStr 	= listAppend(inputStr, "bot_amount|1|give amount", '@')]
[h:inputStr 	= listAppend(inputStr, "bot_spread|0|Spread summoned tokens|CHECK", '@')]

[h:'<!-- ask for coords -->']
[h:inputStr		= listAppend(inputStr,"junk|<html><b>Summon Token(s) to:</b></html>|-|LABEL|SPAN=TRUE", '@')]
[h:inputStr		= listAppend(inputStr,"junk|<html>If you select a token before you run this macro then its<br>coords will be used here</html>|-|LABEL|SPAN=TRUE", '@')]
[h:inputStr 	= listAppend(inputStr, "X|"+X+"|X-coordinate to place token", '@')]
[h:inputStr 	= listAppend(inputStr, "Y|"+Y+"|Y-coordinate to place token", '@')]

[h:'<!-- show coords of selected token-->']
[h, if(PrimePC != ""):inputStr		= listAppend(inputStr,"junk|"+X+","+Y+"|<html><b>Location of "+PrimePC+"</b>|LABEL", '@')]

[h:'<!-- create the dialog string -->']
[h:inputStr 	= listFormat(inputStr, "input( %list )", " ' %item ' ", ",", "@")]

[h:'<!-- ask for input-->']
[h:abort(eval(inputStr))]

[h: updates = json.set("{}", "useDistance", 0)]
[h: updates = json.set(updates, "x", X+1)]
[h: updates = json.set(updates, "y", Y)]

[h:summonedList = json.append("",me)]

[r,if(pcNumber):		summonedList = json.merge(summonedList, copyToken(listGet(pcList, pcNumber), bot_amount, baseMapName, updates))]
[r,if(npcNumber):		summonedList = json.merge(summonedList, copyToken(listGet(npcList, npcNumber), bot_amount, baseMapName, updates))]
[r,if(charNumber):		summonedList = json.merge(summonedList, copyToken(listGet(charList, charNumber), bot_amount, baseMapName, updates))]
[r,if(allNumber):		summonedList = json.merge(summonedList, copyToken(listGet(allList, allNumber), bot_amount, baseMapName, updates))]
[r, foreach(propType, propTypesList, ""), CODE:{
	[r,if(eval(propType+"Number")):	summonedList = json.merge(summonedList, copyToken(listGet(eval(propType+"List"), eval(propType+"Number")), bot_amount, baseMapName, updates))]
}]

[r,if(specialNumber):	summonedList = json.merge(summonedList, copyToken(listGet(specialList, specialNumber), bot_amount, baseMapName, updates))]

[h, if(bot_spread), CODE:{
	[selectTokens(summonedList, 1, "json")]
	[msg = "This message is needed to spread the tokens"]
	[pause("msg")]
	[bot_formationSquare()]
}; {}]
Here is the getValidTokens code:

Code: Select all

[H: '<!-- -------------------------------- getValidTokens(useCurrentMap) ------------------------------------ -->']
[H: '<!-- based on Orpheus WoD campaign macro -->']

[h,if(argCount() > 0): useCurrentMap	= arg(0); useCurrentMap	= 0]
[h,if(argCount() > 1): conditions		= arg(1); conditions	= "{}"]
[h,if(argCount() > 2): use_None			= arg(2); use_None		= 1]
[h,if(argCount() > 3): startsWithTxt	= lower(arg(3)); startsWithTxt	= ""]

[h:baseMapName		= getLibProperty("baseMapName", "lib:EventMacros")]
[h:oldMap			= getCurrentMapName()]
[h:assert(listContains(getAllMapNames(),baseMapName), "Uknown map: '"+baseMapName+"' Set the correct BASE map value in the settings macro of the Bag of Tricks macro panel",0)]
[h,if(use_None): noneImageId = getImage('image:none')]
[h, if(!useCurrentMap):setCurrentMap(baseMapName)]

[h:pcPropType		= getLibProperty("summonPcPropType","lib:EventMacros")]
[h:npcPropType		= getLibProperty("summonNpcPropType","lib:EventMacros")]
[h:propTypesList	= getLibProperty("summonPropTypesList","lib:EventMacros")]
[h:specialList		= getLibProperty("summonSpecialList","lib:EventMacros")]
[h:tokenList 		= listSort(getTokenNames(",",conditions),"N")]

[h,if(startsWithTxt != ""), CODE:{
	<!-- if startswith string is used, narrow the list to those only -->
	[newTokenList	= ""]
	[foreach(tok, tokenList): newTokenList = if(startsWith(lower(tok), startsWithTxt), listAppend(newTokenList, tok), newTokenList)]
	[tokenList		= newTokenList]
}; {}]

[h:'<!-- remove non existing tokens from specialList -->']
[h:tmpList = ""]
[h, foreach(item, specialList), CODE:{
	[if(findToken(item) != ""), CODE:{
		[if(getLayer(item) == 'TOKEN'): tmpList = listAppend(tmpList, item)]
	}; {}]
}]
[h: specialList 	= tmpList]

[h:pcList			= ""]
[h:npcList			= ""]
[h:charList			= ""]
[h:allList			= ""]
[h,foreach(propType, propTypesList): set(propType+"List","")]

[h:fancyPcList		= ""]
[h:fancyNpcList		= ""]
[h:fancyCharList	= ""]
[h:fancyAllList		= ""]
[h,foreach(propType, propTypesList): set("fancy"+propType+"List","")]
[h:fancySpecialList	= ""]
[h:specialNumber	=0]

[H,FOREACH(tok, tokenList), CODE:{
	[pc 			= if(getPropertyType(tok) == pcPropType && isPC(tok),1 ,0)]
	[npc 			= if(getPropertyType(tok) == npcPropType && isNPC(tok),1 ,0)]
	[foreach(propType, propTypesList):set(propType, if(getPropertyType(tok) == propType, 1, 0))]
	[special		= listContains(specialList,  tok)]

	[if(pc), CODE:{
		[pcList		= listAppend(pcList, tok)]
		[token(tok): fancyPcList = listAppend(fancyPcList, tok + getTokenImage(60))]
		[charList	= listAppend(charList, tok)]
		[token(tok): fancyCharList = listAppend(fancyCharList, tok + getTokenImage(60))]
	}; {}]
	[if(npc), CODE:{
		[npcList	= listAppend(npcList, tok)]
		[token(tok): fancyNpcList = listAppend(fancyNpcList, tok + getTokenImage(60))]
		[charList	= listAppend(charList, tok)]
		[token(tok): fancyCharList = listAppend(fancyCharList, tok + getTokenImage(60))]
	}; {}]
	[foreach(propType, propTypesList), CODE:{
		[tmpEval	= eval(propType)]		
		[if(tmpEval): set(propType+"List", listAppend(eval(propType+"List"), tok))]
		[if(tmpEval), token(tok): set("fancy"+propType+"List", listAppend(eval("fancy"+propType+"List"), tok + getTokenImage(60)))]
	}]
	[if(special), CODE:{
		[token(tok): fancySpecialList = listAppend(fancySpecialList, tok + getTokenImage(60))]
	}; {}]
	
	[allList		= listAppend(allList, tok)]
	[token(tok): fancyAllList = listAppend(fancyAllList, tok + getTokenImage(60))]

}]

[h,if(use_None), CODE:{
	[pcList		= if(pcList 	!= "", listAppend("none", pcList), "none")]
	[npcList	= if(npcList	!= "", listAppend("none", npcList), "none")]
	[charList	= if(charList	!= "", listAppend("none", charList), "none")]
	[allList	= if(allList 	!= "", listAppend("none", allList), "none")]

	[if(fancyPcList == ""):		fancyPcList		= "none" + noneImageId ; fancyPcList	= listAppend("none" + noneImageId, fancyPcList)]
	[if(fancyNpcList == ""):	fancyNpcList	= "none" + noneImageId ; fancyNpcList	= listAppend("none" + noneImageId, fancyNpcList)]
	[if(fancyCharList == ""):	fancyCharList	= "none" + noneImageId ; fancyCharList	= listAppend("none" + noneImageId, fancyCharList)]
	[if(fancyAllList == ""):	fancyAllList	= "none" + noneImageId ; fancyAllList	= listAppend("none" + noneImageId, fancyAllList)]

	[foreach(propType, propTypesList), CODE:{
		[set(propType+"List", listAppend("none", eval(propType+"List")))]
		[set("fancy"+propType+"List", if(eval("fancy"+propType+"List") == "", "none" + noneImageId , listAppend("none" + noneImageId, eval("fancy"+propType+"List"))))]
	}]

	[specialList	= listAppend("none", specialList)]
	[if(fancySpecialList == ""): fancySpecialList	= "none" + noneImageId ; fancySpecialList	= listAppend("none" + noneImageId, fancySpecialList)]
}; {
	[h,foreach(propType, propTypesList), CODE:{
		[set(propType+"List", eval(propType+"List"))]
		[set("fancy"+propType+"List", eval("fancy"+propType+"List")]
	}]
}]

[h, if(!useCurrentMap):setCurrentMap(oldMap)]

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Summon Tokens macro broke after upgdating to v1.7.0

Post by Phergus »

You should check the BOT channel on the MapTool discord server. Pretty sure that there is a version there that works.

Post Reply

Return to “MapTool”