added ability to disable/enable full/med/low-glow glass independently

This commit is contained in:
andersje 2013-08-30 20:52:19 -05:00
parent ef0071fd77
commit da48353f86
4 changed files with 277 additions and 257 deletions

View File

@ -1,7 +1,6 @@
Doyousketch2's Stained Glass mod Doyousketch2's Stained Glass mod
ver 1.4 ver 1.6
Image: http://oi47.tinypic.com/hst6s3.jpg Image: http://oi47.tinypic.com/hst6s3.jpg
@ -87,6 +86,8 @@ The Palette includes:
Full & half-saturation, medium and dark shades have been included Full & half-saturation, medium and dark shades have been included
as well as light, pastel, and faint tints. as well as light, pastel, and faint tints.
Look at settings.txt to see how you can enable/disable full-glow, half-glow and no-glow blocks -- tested in all combinations. enjoy.
============================================================================== ==============================================================================
@ -101,6 +102,9 @@ or /giveme stained_glass:pastel_yellow
or /giveme stained_glass:faint_yellow or /giveme stained_glass:faint_yellow
or /giveme stained_glass:yellow or /giveme stained_glass:yellow
or /giveme stained_glass:lowglow_yellow
or /giveme stained_glass:noglow_dark_green
You get the idea. You get the idea.

View File

@ -2,6 +2,10 @@
Changelog Changelog
--------- ---------
ver 1.6
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.
ver 1.5.1 ver 1.5.1
Mon 26 Aug 2013 Mon 26 Aug 2013

519
init.lua
View File

@ -1,255 +1,264 @@
--[[ --[[
Stained Glass Stained Glass
This mod provides luminescent stained glass blocks for Minetest 0.4.7+ This mod provides luminescent stained glass blocks for Minetest 0.4.7+
Depends: Depends:
[moreblocks] by Calinou [moreblocks] by Calinou
[unifieddyes] by VanessaE [unifieddyes] by VanessaE
============================================================================== ==============================================================================
Sat 04 May 2013 01:52:35 PM EDT Sat 04 May 2013 01:52:35 PM EDT
Copyright (C) 2013, Eli Innis Copyright (C) 2013, Eli Innis
Email: doyousketch2 @ yahoo.com Email: doyousketch2 @ yahoo.com
Unified Dyes was released under GNU-GPL 2.0, see LICENSE for info. Unified Dyes was released under GNU-GPL 2.0, see LICENSE for info.
More Blocks was released under zlib/libpng for code and CC BY-SA 3.0 Unported for textures, see LICENSE.txt for info. More Blocks was released under zlib/libpng for code and CC BY-SA 3.0 Unported for textures, see LICENSE.txt for info.
Additional changes by VanessaEzekowitz in July 2013 to take all items Additional changes by VanessaEzekowitz in July 2013 to take all items
out of creative inventory. out of creative inventory.
August 2013 -- Jeremy Anderson tries to get this working after the new color August 2013 -- Jeremy Anderson tries to get this working after the new color
changes, and to resurrect the craft recipes. Still GPL'd as far as I'm concerned. changes, and to resurrect the craft recipes. Still GPL'd as far as I'm concerned.
August 2013 -- rewritten a bit by VanessaEzekowitz to further condense the code. August 2013 -- rewritten a bit by VanessaEzekowitz to further condense the code.
============================================================================== ==============================================================================
Recipe for standard colors: Recipe for standard colors:
dye dye
super glow glass super glow glass
super glow glass super glow glass
super glow glass super glow glass
Recipe for pastel colors: Recipe for pastel colors:
light dye light dye
white paint white paint
super glow glass super glow glass
super glow glass super glow glass
super glow glass super glow glass
Recipe for faint colors: Recipe for faint colors:
light dye light dye
white paint white paint
white paint white paint
super glow glass super glow glass
super glow glass super glow glass
super glow glass super glow glass
recipe for low-glow-stained-glass: recipe for low-glow-stained-glass:
as above, but substitute 'glow glass' for super glow glass. as above, but substitute 'glow glass' for super glow glass.
recipe for no-glow-stained-glass: recipe for no-glow-stained-glass:
as regular stained glass, but substitute plain 'glass' for super glow glass as regular stained glass, but substitute plain 'glass' for super glow glass
All recipes produce three stained glass blocks. All recipes produce three stained glass blocks.
============================================================================== ==============================================================================
]]-- ]]--
function makenode(arg) 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
--register item attributes --register item attributes
minetest.register_node("stained_glass:"..myprefix..name, { minetest.register_node("stained_glass:"..myprefix..name, {
description = "Stained Glass - "..myprefix..name, description = "Stained Glass - "..myprefix..name,
drawtype = "glasslike", drawtype = "glasslike",
tiles = {"stained_glass_" .. name .. ".png"}, tiles = {"stained_glass_" .. name .. ".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,
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
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 stained_glass_blocktype = { local stained_glass_blocktype = { }
[""]="moreblocks:super_glow_glass" ,
["lowglow_"]="moreblocks:glow_glass", local stained_glass_lightlevel = { }
["noglow_"]="default:glass",
-- here you can define alternate glowlevels, with if stained_glass.full_light then
-- what type of glass they should use. stained_glass_lightlevel[""] = LIGHT_MAX
-- levels added here must be added stained_glass_blocktype[""] = "moreblocks:super_glow_glass"
-- below (in stained_glass_lightlevel), too. end -- see settings.txt for these settings.
}
if stained_glass.med_light then
local stained_glass_lightlevel = { stained_glass_lightlevel["lowglow_"] = LIGHT_MAX-3
["noglow_"] = 0, stained_glass_blocktype["lowglow_"] = "moreblocks:glow_glass"
[""] = LIGHT_MAX, end
["lowglow_"] = LIGHT_MAX-3,
if stained_glass.no_light then
-- define alternate light levels here, with a new stained_glass_lightlevel["noglow_"] = 0
-- prefix name and a new light level. perhaps you'd stained_glass_blocktype["noglow_"] = "default:glass"
-- like "dim" at a level of '6' for example. end
}
for myprefix,myglow in pairs(stained_glass_lightlevel) do
for myprefix,myglow in pairs(stained_glass_lightlevel) do local glasstype = stained_glass_blocktype[myprefix]
local glasstype = stained_glass_blocktype[myprefix]
-- define myrecipe as a table, pass it in.
-- define myrecipe as a table, pass it in.
local myrecipe = { mydye, glasstype, glasstype, glasstype }
local myrecipe = { mydye, glasstype, glasstype, glasstype } -- those four items will ALWAYS be there. For faint and pastel, we
-- 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
-- need to add additional dyes. If you have defined a new shade, then -- you should probably handle it here.
-- you should probably handle it here.
if myshadename == "pastel_" then
if myshadename == "pastel_" then myrecipe[5] = "dye:white"
myrecipe[5] = "dye:white" end
end
if myshadename == "faint_" then
if myshadename == "faint_" then myrecipe[5] = "dye:white"
myrecipe[5] = "dye:white" myrecipe[6] = "dye:white"
myrecipe[6] = "dye:white" end
end
minetest.register_craft({
minetest.register_craft({ type = "shapeless",
type = "shapeless", output = "stained_glass:"..myprefix..name.." 3",
output = "stained_glass:"..myprefix..name.." 3", recipe = myrecipe,
recipe = myrecipe, })
})
makenode{blockname=name, glow=myglow, prefix=myprefix}
makenode{blockname=name, glow=myglow, prefix=myprefix}
if myprefix == "" then
if myprefix == "" then 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.
name=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:" .. name, "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 -- we need to keep the numeric block for all the people that used
-- we need to keep the numeric block for all the people that used -- pre-v1.4 blocks in their worlds.
-- pre-v1.4 blocks in their worlds. -- no aliases for noglow- and lowglow- blocks, because they didn't
-- no aliases for noglow- and lowglow- blocks, because they didn't -- exist until v1.5
-- exist until v1.5 end
end end
end
-- true means this color's recipe must use a direct "dye:xxxxx" item name
-- true means this color's recipe must use a direct "dye:xxxxx" item name -- (perhaps because the related groups overlap two or more distinct colors)
-- (perhaps because the related groups overlap two or more distinct colors) -- false means the recipe uses "group:dye,unicolor_xxxxx"
-- false means the recipe uses "group:dye,unicolor_xxxxx"
stained_glass= {}
stained_glass_hues = { local worldpath=minetest.get_worldpath()
{ "yellow", true }, local modpath=minetest.get_modpath("stained_glass")
{ "lime", false }, dofile(modpath .. "/settings.txt")
{ "green", true },
{ "aqua", false }, -- the new settings.txt file has a variety of possible settings.
{ "cyan", false }, -- see the file for examples. We'll access those settings where its important, in
{ "skyblue", true }, -- the stained glass module, where we'll build up the tables to contain
{ "blue", false }, -- only what we need.
{ "violet", false },
{ "magenta", true }, stained_glass_hues = {
{ "redviolet", true }, { "yellow", true },
{ "red", true }, { "lime", false },
{ "orange", false }, { "green", true },
{ "aqua", false },
-- please note that these only apply when our shadelevel is "" { "cyan", false },
{ "skyblue", true },
} { "blue", false },
{ "violet", false },
stained_glass_shades = { { "magenta", true },
{"dark_", 3 }, { "redviolet", true },
{"medium_", 4 }, { "red", true },
{"", 5 }, -- full brightness { "orange", false },
{"light_", 8 },
{"pastel_", 9 }, -- please note that these only apply when our shadelevel is ""
{"faint_", 91 }
}
-- note that dark_ medium_ and plain also have a half-saturation
-- equivalent automatically defined in the code stained_glass_shades = {
} {"dark_", 3 },
{"medium_", 4 },
for i in ipairs(stained_glass_hues) do {"", 5 }, -- full brightness
{"light_", 8 },
local huename = stained_glass_hues[i][1] {"pastel_", 9 },
local huenumber = i {"faint_", 91 }
for j in ipairs(stained_glass_shades) do -- note that dark_ medium_ and plain also have a half-saturation
-- equivalent automatically defined in the code
local shadename = stained_glass_shades[j][1] }
local shadenumber = stained_glass_shades[j][2]
for i in ipairs(stained_glass_hues) do
local recipevalue = nil
local huename = stained_glass_hues[i][1]
recipevalue = "group:dye,unicolor_"..shadename..huename local huenumber = i
if (shadename == "" and stained_glass_hues[i][2]) then
-- print(huename .. " is set to true -- substituting dye:huename ") for j in ipairs(stained_glass_shades) do
recipevalue = "dye:"..huename
elseif (shadename=="pastel_" or shadename=="faint_") then local shadename = stained_glass_shades[j][1]
-- force light_dye for pastel and faint colors local shadenumber = stained_glass_shades[j][2]
recipevalue = "group:dye,unicolor_light_"..huename
else -- default case local recipevalue = nil
recipevalue = "group:dye,unicolor_"..shadename..huename
end recipevalue = "group:dye,unicolor_"..shadename..huename
if (shadename == "" and stained_glass_hues[i][2]) then
if shadename == "dark_" or shadename == "medium_" or shadename == "" then -- print(huename .. " is set to true -- substituting dye:huename ")
stained_glass_define({ recipevalue = "dye:"..huename
colorcode = huenumber.."_"..shadenumber.."_7", elseif (shadename=="pastel_" or shadename=="faint_") then
colorname = shadename..huename, -- force light_dye for pastel and faint colors
recipe = recipevalue, recipevalue = "group:dye,unicolor_light_"..huename
shade = shadename, else -- default case
}) recipevalue = "group:dye,unicolor_"..shadename..huename
end
-- below is the automatic "half saturation" block
-- which was mentioned previously if shadename == "dark_" or shadename == "medium_" or shadename == "" then
-- this is unicolor only, so switch dyename stained_glass_define({
-- back to unicolor... colorcode = huenumber.."_"..shadenumber.."_7",
recipevalue="group:dye,unicolor_"..shadename..huename colorname = shadename..huename,
stained_glass_define({ recipe = recipevalue,
colorcode = huenumber.."_"..shadenumber.."_6", shade = shadename,
colorname = shadename..huename.."_s50", })
recipe = recipevalue.."_s50",
shade = shadename, -- below is the automatic "half saturation" block
}) -- which was mentioned previously
-- because we define two blocks inside this chunk of -- this is unicolor only, so switch dyename
-- code, we can't just define the relevant vars and -- back to unicolor...
-- move the proc_call after the if-then loop. recipevalue="group:dye,unicolor_"..shadename..huename
stained_glass_define({
elseif shadename == "light_" or shadename == "pastel_" or shadename == "faint_" then colorcode = huenumber.."_"..shadenumber.."_6",
stained_glass_define({ colorname = shadename..huename.."_s50",
colorcode = huenumber.."_"..shadenumber.."_", recipe = recipevalue.."_s50",
colorname = shadename..huename, shade = shadename,
recipe = recipevalue, })
shade = shadename, -- because we define two blocks inside this chunk of
}) -- code, we can't just define the relevant vars and
-- move the proc_call after the if-then loop.
end
elseif shadename == "light_" or shadename == "pastel_" or shadename == "faint_" then
end stained_glass_define({
end colorcode = huenumber.."_"..shadenumber.."_",
colorname = shadename..huename,
print("[stained_glass] Loaded!") recipe = recipevalue,
shade = shadename,
})
end
end
end
print("[stained_glass] Loaded!")

3
settings.txt Normal file
View File

@ -0,0 +1,3 @@
stained_glass.full_light = true
stained_glass.med_light = true
stained_glass.no_light = true