Problem with permTrigger

Post Reply
Xarikins
Posts: 3
Joined: Thu Sep 13, 2012 3:31 am

Problem with permTrigger

Post by Xarikins »

I'm trying to automate some trigger creation. The syntax I'm using is
Code: [show] | [select all] lua
permBeginOfLineStringTrigger(defenceName .. "On", "autoGenerated", {triggerLine}, [[addDef("]] .. defenceName .. [[")]])
This correctly creates a trigger, but the name of the trigger is set to a random number instead of the value in defenceName. Using a literal string like "alertness" in place of defenceName still causes the trigger to be named a random number. I've tried this with BeginOfLineString and Regex permTrigger types, both have the same behavior.

I'm also getting some weird behavior where I have to close the editor, open it, close it, and open it again before it will let me edit anything if I use the permTrigger variants.

Any ideas? I'd really like to use this functionality, it'll save me hours and hours of system building.

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Problem with permTrigger

Post by kevutian »

You can assign variables to most functions such as this in the following fashion.

Code: Select all

foo = permBeginOfLineStringTrigger(defenceName .. "On", "autoGenerated", {triggerLine}, [[addDef("]] .. defenceName .. [[")]])
Not sure about your second problem though, sorry.

Knute
Posts: 87
Joined: Fri Mar 05, 2010 12:08 am

Re: Problem with permTrigger

Post by Knute »

So was there ever an answer to this question?

I'm running into the same issue.

The REASON that it's an issue, is that I have an exists() check going on to see if the trigger already exists.
Since the triggers being created are (I'm guessing) pid's or something, the names NEVER match, so I end up with many many duplicates.

So, other than assigning a variable, how can this functionality be fixed to work as intented (ie. naming your triggers the way that you want them to be.) ??

Code: Select all

function defDsplyTrigs()
		if exists("Defs", "trigger") == 0 then
				cecho("<white>Trigger Group: <gold>Defs  <white> does not exist.\n")
		else
				for k,v in pairs(defenses) do 
						if exists(v.name, "trigger") == 0 then
								permBeginOfLineStringTrig55ger( v.name, "Defs", { v.line, v.upline }, v.name .. [[:echo("]] .. v.display .. [[", "white", "c");selectString(matches[1]);replace("]] .. v.name .. [[" ,1)]])
--							cecho("<white>" .. v.name .. "  <cyan>" .. v.line .. "\n")
						end
				end
		end 
This is my trigger creation line. I have a defenses table that is in the form of

Code: Select all

 {name ="blah", display="whatever", line = " something", upline="something else"}
The cecho line that I have commented out shows the correct v.name with the correct v.line.
So, am I missing something here?

Assigning variables, as suggested below will do what? It was my understanding that when you assigned a variable to a trigger line (temp triggers if I remember right), that the variable got the idstring of that trigger.

If we go this way, then following the thought through is that I will need to maintain a separate list of the triggers that were created to keep track of what triggers were set up and what weren't. This seems to me, to be a very poor way to apply some of these functions. It makes a mockery of exists(), and now I'm rambling.

What needs to be done so that we can name our triggers from scripts?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Problem with permTrigger

Post by Jor'Mox »

It has yet to be fixed. I include a comment line in my triggers saying what name they should be given so that after they are made, they can have their name set manually to the correct value. Not perfect, but it is all you can really do until the code for trigger creation is fixed.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Problem with permTrigger

Post by Heiko »

fixed

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Problem with permTrigger

Post by chris »

For the time, you can populate a table with the trigger return values and use that to track their existence.

Post Reply