Generating unique one shot variable names

Posted by Ekaterina on Wed 22 Sep 2010 01:40 AM — 3 posts, 14,638 views.

#0
In lua you can't delete tables, so is there a way to generate a unique one-shot variable name for the table? This code works, it just concenates the next map onto the previous map, which isn't what is supposed to happen. I suppose I could modify the code to write directly to the miniwindow, which is what its going to do, but I want to actually have the table to be able to manipulate it, and I feel it makes to understand if you split up the data entry, and the formatting.

AddTriggerEx ("map_begin",
				"^-* (v\d*) -*$",
				"table.insert\(map_buffer,\"%1\"\) EnableTrigger\(\"line_capture\", true\)",
				49,
				custom_colour.Custom15,	
				0,
				"",
				"",
				12,
				99)
AddTriggerEx ("map_terminate", 
				"(^--- .* -.*$)",
				"table.insert\(map_buffer,\"%1\"\) EnableTrigger\(\"line_capture\", false\) write_map\(map_buffer\)",
				49,
				custom_colour.Custom15,	
				0,
				"",
				"",
				12,
				99)
AddTriggerEx ("line_capture", 
				"(^.*$)",
				"table.insert\(map_buffer,\"%1\"\)",
				49,
				custom_colour.Custom15,	
				0,
				"",
				"",
				12,
				100)
function write_map (x)
	for i,v in ipairs(x) do
		print (v)
	end
end
Amended on Wed 22 Sep 2010 01:42 AM by Ekaterina
USA #1
You can't "delete" tables, but you can use the variable for a new value. Variables in Lua aren't values, they _refer_ to values. What you really want is to set "map_buffer = {};" before you do anything else in your map_begin trigger, which will create a new table and have map_buffer refer to it.
#2
So simple. >.< Thank you.