Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Generating unique one shot variable names

Generating unique one shot variable names

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ekaterina   (4 posts)  Bio
Date Wed 22 Sep 2010 01:40 AM (UTC)

Amended on Wed 22 Sep 2010 01:42 AM (UTC) by Ekaterina

Message
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
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Wed 22 Sep 2010 01:46 AM (UTC)
Message
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.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Ekaterina   (4 posts)  Bio
Date Reply #2 on Wed 22 Sep 2010 01:50 AM (UTC)
Message
So simple. >.< Thank you.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,439 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.