Possible to dynamically generate setPopup() commands?

Gauroth
Posts: 22
Joined: Tue Sep 07, 2010 2:44 pm

Re: Possible to dynamically generate setPopup() commands?

Post by Gauroth »

Hmm, I see... I guess the issue then is what exactly I'm trying to create my setPopup() function with - namely the ability to handle an unknown number of options in the popup menu. Drawing from my earlier examples for instance I don't know if the variable "testVar" might have one element or ten (though for usability's sake the number should be kept on the low side to avoid a humongous popup) whereas in your example you're able to manually generate the skeleton of the setPopup() function and put your "_target" and "_target_group" variables in the appropriate places since you know you just want to be able to do a set number of things to a particular target (attack, consider, look, etc.)

In any event you've most certainly given me a lot of great information to go on. Thank you again.

Edit: Rather unsurprisingly that was much simpler than I was making it. The following seems to be working exactly as I'd like it to. Many thanks for setting me straight.
Code: [show] | [select all] lua
testingVar = {
	"send(\"bye\")",
	"send(\"hi\")"
}
testVar = {
	"left-click or right-click and do first item to send bye",
	"click to send hi"
}
selectString("Hello", 1)
setPopup("main", testingVar, testVar)

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Possible to dynamically generate setPopup() commands?

Post by tsuujin »

Heiko wrote:
tsuujin wrote:It should probably be noted that the community in general has indicated several speed issues and garbage collection issues resulting from rapid loadstring commands, though.
This is interesting news to me. Do you have anything to back up this claim. If it's a confirmed bug in Lua any idea when is it going to be fixed?
It's not so much a bug as it is an issue with the JIT system used for compiling code during runtime, and is essentially the same issue you find with rapidly using the concatenation operator. Normal usage isn't a problem, but on something you may be triggering multiple times a second (if you have lots of systems that all use loadstring) it can become an issue.

Much the same as I use string.format far more often than "..", I also limit my usage of loadstring. Not to say I don't use it at all.

Post Reply