trapglass variants added. settings.txt enhanced.

This commit is contained in:
andersje 2013-08-31 21:31:05 -05:00
parent da48353f86
commit 5dc18596b9
3 changed files with 104 additions and 9 deletions

View File

@ -2,23 +2,23 @@
Changelog Changelog
--------- ---------
ver 1.7
Sat 1 Sep 2013
I like trapglass, so _all_ variants of stained_glass are now available as (identical) trapglass variants. also, ability to ditch trapglass blocks via settings.txt added. In fact, you can now pick and choose which variants of stained_glass you wish to enable.
ver 1.6 ver 1.6
Fri 30 Aug 2013 Fri 30 Aug 2013
added configfile settings.txt to allow disabling of full_light (super_glow_glass-based), med_light (glow_glass-based) and no_light (default:glass) blocks. just set the relevant fields to 'false' and they will not be loaded when you start the game. added configfile settings.txt to allow disabling of full_light (super_glow_glass-based), med_light (glow_glass-based) and no_light (default:glass) blocks. just set the relevant fields to 'false' and they will not be loaded when you start the game.
ver 1.5.1 ver 1.5.1
Mon 26 Aug 2013 Mon 26 Aug 2013
prompted by VanessaE's initial cleanup, MUCH cleanup of the code. No need to have > 1 file anymore. prompted by VanessaE's initial cleanup, MUCH cleanup of the code. No need to have > 1 file anymore.
ver 1.5 ver 1.5
Sun 25 Aug 2013 Sun 25 Aug 2013
added low-glow (brightness 11) and noglow (brightness 0) stained glass blows, using glow_glass and regular glass accordingly. added low-glow (brightness 11) and noglow (brightness 0) stained glass blows, using glow_glass and regular glass accordingly.
ver 1.4 ver 1.4
Thu 22 Aug 2013 Thu 22 Aug 2013
*phew* made aliases for all numeric block names to map to new color-name based scheme *phew* made aliases for all numeric block names to map to new color-name based scheme
updated craft recipes to work with new dyes format updated craft recipes to work with new dyes format

102
init.lua
View File

@ -70,29 +70,101 @@ function makenode(arg)
local name=arg.blockname local name=arg.blockname
local myglow=arg.glow local myglow=arg.glow
local myprefix=arg.prefix local myprefix=arg.prefix
local imagename=arg.imagename
local safe=arg.walkflag
local Description
local function tchelper(first, rest)
return first:upper()..rest:lower()
end -- from lua-users.org/wiki/StringRecipes
-- above function is used to turn red_violet_s50 to 'Red Violet S50'
--register item attributes --register item attributes
Description=string.gsub("Stained Glass - " ..myprefix..name, "_", " ")
Description=Description:gsub("(%a)([%w_']*)", tchelper)
minetest.register_node("stained_glass:"..myprefix..name, { minetest.register_node("stained_glass:"..myprefix..name, {
description = "Stained Glass - "..myprefix..name, description = Description,
drawtype = "glasslike", drawtype = "glasslike",
tiles = {"stained_glass_" .. name .. ".png"}, tiles = {"stained_glass_" .. imagename .. ".png"},
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = true, use_texture_alpha = true,
light_source = myglow, light_source = myglow,
is_ground_content = true, is_ground_content = true,
walkable=safe, -- if not safe, this is trapglass
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, not_in_creative_inventory=1}, groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults() sounds = default.node_sound_glass_defaults()
}) })
end end
-- maybe someday, I can cleanly combine these two functions.
function stained_trapglass_define(arg)
local code=arg.colorcode
local name=arg.colorname
local rawdyename=arg.recipe
local mydye=arg.recipe
local myshadename=arg.shade
local imagename=name
local stained_glass_blocktype = { }
local stained_glass_lightlevel = { }
if stained_glass.trap_full_light then
stained_glass_lightlevel[""] = LIGHT_MAX
stained_glass_blocktype[""] = "moreblocks:trap_super_glow_glass"
end -- see settings.txt for these settings.
if stained_glass.trap_med_light then
stained_glass_lightlevel["lowglow_"] = LIGHT_MAX-3
stained_glass_blocktype["lowglow_"] = "moreblocks:trap_glow_glass"
end
if stained_glass.trap_no_light then
stained_glass_lightlevel["noglow_"] = 0
stained_glass_blocktype["noglow_"] = "moreblocks:trap_glass"
end
for myprefix,myglow in pairs(stained_glass_lightlevel) do
local glasstype = stained_glass_blocktype[myprefix]
local name="trap_" .. name
-- define myrecipe as a table, pass it in.
local myrecipe = { mydye, glasstype, glasstype, glasstype }
-- those four items will ALWAYS be there. For faint and pastel, we
-- need to add additional dyes. If you have defined a new shade, then
-- you should probably handle it here.
if myshadename == "pastel_" then
myrecipe[5] = "dye:white"
end
if myshadename == "faint_" then
myrecipe[5] = "dye:white"
myrecipe[6] = "dye:white"
end
minetest.register_craft({
type = "shapeless",
output = "stained_glass:"..myprefix..name.." 3",
recipe = myrecipe,
})
makenode{blockname=name, glow=myglow, prefix=myprefix, imagename=imagename, walkflag=false}
end
end
function stained_glass_define(arg) function stained_glass_define(arg)
local code=arg.colorcode local code=arg.colorcode
local name=arg.colorname local name=arg.colorname
local rawdyename=arg.recipe local rawdyename=arg.recipe
local mydye=arg.recipe local mydye=arg.recipe
local myshadename=arg.shade local myshadename=arg.shade
local imagename=name
local stained_glass_blocktype = { } local stained_glass_blocktype = { }
@ -138,14 +210,15 @@ function stained_glass_define(arg)
recipe = myrecipe, recipe = myrecipe,
}) })
makenode{blockname=name, glow=myglow, prefix=myprefix} makenode{blockname=name, glow=myglow, prefix=myprefix, imagename=name, walkflag=true}
if myprefix == "" then if myprefix == "" then
local aliasname
minetest.register_alias( "stained_glass:" .. code, "stained_glass:" .. name) minetest.register_alias( "stained_glass:" .. code, "stained_glass:" .. name)
if string.match(name,"redviolet") then if string.match(name,"redviolet") then
oldname=name oldname=name
name=string.gsub(name, "redviolet","red_violet") -- need to support red_violet existence, too. aliasname=string.gsub(name, "redviolet","red_violet") -- need to support red_violet existence, too.
minetest.register_alias( "stained_glass:" .. name, "stained_glass:" .. oldname) minetest.register_alias( "stained_glass:" .. aliasname, "stained_glass:" .. oldname)
end end
end end
-- and an alias from the numeric to the named block -- and an alias from the numeric to the named block
@ -231,6 +304,13 @@ for i in ipairs(stained_glass_hues) do
shade = shadename, shade = shadename,
}) })
stained_trapglass_define({
colorcode = huenumber.."_"..shadenumber.."_7",
colorname = shadename..huename,
recipe = recipevalue,
shade = shadename,
}) -- only defines something if the trap is enabled.
-- below is the automatic "half saturation" block -- below is the automatic "half saturation" block
-- which was mentioned previously -- which was mentioned previously
-- this is unicolor only, so switch dyename -- this is unicolor only, so switch dyename
@ -242,6 +322,12 @@ for i in ipairs(stained_glass_hues) do
recipe = recipevalue.."_s50", recipe = recipevalue.."_s50",
shade = shadename, shade = shadename,
}) })
stained_trapglass_define({
colorcode = huenumber.."_"..shadenumber.."_6",
colorname = shadename..huename.."_s50",
recipe = recipevalue.."_s50",
shade = shadename,
}) -- only defines something if the trap is enabled.
-- because we define two blocks inside this chunk of -- because we define two blocks inside this chunk of
-- code, we can't just define the relevant vars and -- code, we can't just define the relevant vars and
-- move the proc_call after the if-then loop. -- move the proc_call after the if-then loop.
@ -253,6 +339,12 @@ for i in ipairs(stained_glass_hues) do
recipe = recipevalue, recipe = recipevalue,
shade = shadename, shade = shadename,
}) })
stained_trapglass_define({
colorcode = huenumber.."_"..shadenumber.."_",
colorname = shadename..huename,
recipe = recipevalue,
shade = shadename,
}) -- only defines something if the trap is enabled.
end end

View File

@ -1,3 +1,6 @@
stained_glass.full_light = true stained_glass.full_light = true
stained_glass.med_light = true stained_glass.med_light = true
stained_glass.no_light = true stained_glass.no_light = true
stained_glass.trap_full_light = true
stained_glass.trap_med_light = true
stained_glass.trap_no_light = true