diff options
author | Tim <t4im@users.noreply.github.com> | 2015-01-31 16:48:03 +0100 |
---|---|---|
committer | Tim <t4im@users.noreply.github.com> | 2015-01-31 16:48:03 +0100 |
commit | 70f38104a00f20709a46a22413bc98115d486186 (patch) | |
tree | 86eb239d33b89050c61b8aa10e883881d77b0388 | |
parent | e60f86a5886f41636f6f189ce09a5097a9baabee (diff) | |
download | pipeworks-70f38104a00f20709a46a22413bc98115d486186.tar pipeworks-70f38104a00f20709a46a22413bc98115d486186.tar.gz pipeworks-70f38104a00f20709a46a22413bc98115d486186.tar.bz2 pipeworks-70f38104a00f20709a46a22413bc98115d486186.tar.xz pipeworks-70f38104a00f20709a46a22413bc98115d486186.zip |
reduce table lookups and string concat
-rw-r--r-- | tube_registration.lua | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/tube_registration.lua b/tube_registration.lua index ffa9576..d37bf7d 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -1,6 +1,7 @@ -- This file supplies the various kinds of pneumatic tubes -pipeworks.tubenodes = {} +local tubenodes = {} +pipeworks.tubenodes = tubenodes minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000") @@ -10,13 +11,9 @@ local REGISTER_COMPATIBILITY = true local vti = {4, 3, 2, 1, 6, 5} -local default_textures = { - noctrs = { "pipeworks_tube_noctr.png" }, - plain = { "pipeworks_tube_plain.png" }, - ends = { "pipeworks_tube_end.png" }, - short = "pipeworks_tube_short.png", - inv = "pipeworks_tube_inv.png", -} +local default_noctrs = { "pipeworks_tube_noctr.png" } +local default_plain = { "pipeworks_tube_plain.png" } +local default_ends = { "pipeworks_tube_end.png" } local texture_mt = { __index = function(table, key) @@ -29,14 +26,14 @@ local texture_mt = { } local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style) - noctrs = noctrs or default_textures.noctrs + noctrs = noctrs or default_noctrs setmetatable(noctrs, texture_mt) - plain = plain or default_textures.plain + plain = plain or default_plain setmetatable(plain, texture_mt) - ends = ends or default_textures.ends + ends = ends or default_ends setmetatable(ends, texture_mt) - short = short or default_textures.short - inv = inv or default_textures.inv + short = short or "pipeworks_tube_short.png" + inv = inv or "pipeworks_tube_inv.png" local outboxes = {} local outsel = {} @@ -59,7 +56,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e end local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1} - local tubedesc = desc.." "..dump(connects).."... You hacker, you." + local tubedesc = string.format("%s %s... You hacker, you.", desc, dump(connects)) local iimg = plain[1] local wscale = {x = 1, y = 1, z = 1} @@ -77,8 +74,8 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e wscale = {x = 1, y = 1, z = 0.01} end - local rname = name.."_"..tname - table.insert(pipeworks.tubenodes, rname) + local rname = string.format("%s_%s", name, tname) + table.insert(tubenodes, rname) local nodedef = { description = tubedesc, @@ -103,7 +100,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e stack_max = 99, basename = name, style = style, - drop = name.."_"..dropname, + drop = string.format("%s_%s", name, dropname), tubelike = 1, tube = { connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}, @@ -209,7 +206,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}}, drop = name.."_1", }) - table.insert(pipeworks.tubenodes, cname) + table.insert(tubenodes, cname) for xm = 0, 1 do for xp = 0, 1 do for ym = 0, 1 do |