[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  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] Refresh page


Posted by Ekaterina   (4 posts)  [Biography] 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
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

Posted by Ekaterina   (4 posts)  [Biography] bio
Date Reply #2 on Wed 22 Sep 2010 01:50 AM (UTC)
Message
So simple. >.< Thank you.
[Go to top] 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.


10,234 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]