forked from minetest-mods/stained_glass
massive cleanup. all craft recipes working and tested.
This commit is contained in:
parent
0409a59892
commit
b21069b7f1
|
@ -2,6 +2,11 @@
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
---------
|
---------
|
||||||
|
ver 1.5.1
|
||||||
|
|
||||||
|
Mon 26 Aug 2013
|
||||||
|
prompted by VanessaE's initial cleanup, MUCH cleanup of the code. No need to have > 1 file anymore.
|
||||||
|
|
||||||
|
|
||||||
ver 1.5
|
ver 1.5
|
||||||
|
|
||||||
|
|
222
init.lua
222
init.lua
|
@ -1,8 +1,8 @@
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
Stained Glass 1.5
|
Stained Glass
|
||||||
|
|
||||||
This mod provides luminescent stained glass blocks for Minetest 0.4.x.
|
This mod provides luminescent stained glass blocks for Minetest 0.4.7+
|
||||||
|
|
||||||
Depends:
|
Depends:
|
||||||
[moreblocks] by Calinou
|
[moreblocks] by Calinou
|
||||||
|
@ -23,7 +23,6 @@ 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.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -68,114 +67,93 @@ All recipes produce three stained glass blocks.
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
function makenode(arg)
|
function makenode(arg)
|
||||||
name=arg.blockname
|
local name=arg.blockname
|
||||||
|
local myglow=arg.glow
|
||||||
|
local myprefix=arg.prefix
|
||||||
|
|
||||||
--register item attributes
|
--register item attributes
|
||||||
|
|
||||||
minetest.register_node("stained_glass:"..arg.prefix..name, {
|
minetest.register_node("stained_glass:"..myprefix..name, {
|
||||||
description = "Stained Glass - "..arg.prefix..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 = arg.light,
|
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)
|
||||||
|
local code=arg.colorcode
|
||||||
|
local name=arg.colorname
|
||||||
|
local rawdyename=arg.recipe
|
||||||
|
local mydye=arg.recipe
|
||||||
|
local myshadename=arg.shade
|
||||||
|
|
||||||
-- the purpose of this is to abstract out all the registration
|
local stained_glass_blocktype = {
|
||||||
-- stuff - duplicated code is bad mmmmmkay? At least where one can avoid it
|
[""]="moreblocks:super_glow_glass" ,
|
||||||
|
["lowglow_"]="moreblocks:glow_glass",
|
||||||
|
["noglow_"]="default:glass",
|
||||||
|
-- here you can define alternate glowlevels, with
|
||||||
|
-- what type of glass they should use.
|
||||||
|
-- levels added here must be added
|
||||||
|
-- below (in stained_glass_lightlevel), too.
|
||||||
|
}
|
||||||
|
|
||||||
-- so, instead of 4 loops that each have craft registrations,
|
local stained_glass_lightlevel = {
|
||||||
-- we'll have one block that does registrations, and just call
|
["noglow_"] = 0,
|
||||||
-- the procedure repeatedly
|
[""] = LIGHT_MAX,
|
||||||
--
|
["lowglow_"] = LIGHT_MAX-3,
|
||||||
|
|
||||||
function stained_glass_define_regular(arg)
|
-- define alternate light levels here, with a new
|
||||||
code=arg.colorcode
|
-- prefix name and a new light level. perhaps you'd
|
||||||
name=arg.colorname
|
-- like "dim" at a level of '6' for example.
|
||||||
mydye=arg.recipe
|
}
|
||||||
myprefix = arg.prefix
|
|
||||||
glasstype = arg.glasstype
|
|
||||||
|
|
||||||
minetest.register_craft({
|
for myprefix,myglow in pairs(stained_glass_lightlevel) do
|
||||||
type = "shapeless",
|
local glasstype = stained_glass_blocktype[myprefix]
|
||||||
output = "stained_glass:"..myprefix..name.." 3",
|
|
||||||
recipe = {
|
|
||||||
mydye,
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
makenode{blockname=name, light=arg.light, prefix=myprefix}
|
-- define myrecipe as a table, pass it in.
|
||||||
|
|
||||||
if myprefix == "" then
|
local myrecipe = { mydye, glasstype, glasstype, glasstype }
|
||||||
minetest.register_alias( "stained_glass:" .. code, "stained_glass:" .. name)
|
-- those four items will ALWAYS be there. For faint and pastel, we
|
||||||
end
|
-- need to add additional dyes. If you have defined a new shade, then
|
||||||
-- and an alias from the numeric to the named block
|
-- you should probably handle it here.
|
||||||
-- we need to keep the numeric block for all the people that used
|
|
||||||
-- pre-v1.4 blocks in their worlds.
|
|
||||||
|
|
||||||
end
|
if myshadename == "pastel_" then
|
||||||
|
myrecipe[5] = "dye:white"
|
||||||
|
end
|
||||||
|
|
||||||
function stained_glass_define_pastel(arg)
|
if myshadename == "faint_" then
|
||||||
code=arg.colorcode
|
myrecipe[5] = "dye:white"
|
||||||
name=arg.colorname
|
myrecipe[6] = "dye:white"
|
||||||
mydye=arg.recipe
|
end
|
||||||
myprefix = arg.prefix
|
|
||||||
glasstype = arg.glasstype
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "stained_glass:"..myprefix..name .." 3",
|
output = "stained_glass:"..myprefix..name.." 3",
|
||||||
recipe = {
|
recipe = myrecipe,
|
||||||
mydye,
|
})
|
||||||
"dye:white",
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
makenode{blockname=name,light=arg.light, 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)
|
||||||
end
|
if string.match(name,"redviolet") then
|
||||||
end
|
oldname=name
|
||||||
|
name=string.gsub(name, "redviolet","red_violet") -- need to support red_violet existence, too.
|
||||||
function stained_glass_define_faint(arg)
|
minetest.register_alias( "stained_glass:" .. name, "stained_glass:" .. oldname)
|
||||||
code=arg.colorcode
|
end
|
||||||
name=arg.colorname
|
end
|
||||||
mydye=arg.recipe
|
-- and an alias from the numeric to the named block
|
||||||
myprefix = arg.prefix
|
-- we need to keep the numeric block for all the people that used
|
||||||
glasstype = arg.glasstype
|
-- pre-v1.4 blocks in their worlds.
|
||||||
|
-- no aliases for noglow- and lowglow- blocks, because they didn't
|
||||||
minetest.register_craft({
|
-- exist until v1.5
|
||||||
type = "shapeless",
|
|
||||||
output = "stained_glass:"..myprefix..name.." 3",
|
|
||||||
recipe = {
|
|
||||||
mydye,
|
|
||||||
"dye:white",
|
|
||||||
"dye:white",
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
glasstype,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
--register item attributes
|
|
||||||
--
|
|
||||||
makenode{blockname=name,light=arg.light, prefix=myprefix}
|
|
||||||
|
|
||||||
if myprefix == "" then
|
|
||||||
minetest.register_alias( "stained_glass:" .. code, "stained_glass:" .. name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,13 +167,16 @@ stained_glass_hues = {
|
||||||
{ "green", true },
|
{ "green", true },
|
||||||
{ "aqua", false },
|
{ "aqua", false },
|
||||||
{ "cyan", false },
|
{ "cyan", false },
|
||||||
{ "skyblue", false },
|
{ "skyblue", true },
|
||||||
{ "blue", false },
|
{ "blue", false },
|
||||||
{ "violet", true },
|
{ "violet", false },
|
||||||
{ "magenta", true },
|
{ "magenta", true },
|
||||||
{ "redviolet", true },
|
{ "redviolet", true },
|
||||||
{ "red", true },
|
{ "red", true },
|
||||||
{ "orange", false },
|
{ "orange", false },
|
||||||
|
|
||||||
|
-- please note that these only apply when our shadelevel is ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stained_glass_shades = {
|
stained_glass_shades = {
|
||||||
|
@ -205,14 +186,69 @@ stained_glass_shades = {
|
||||||
{"light_", 8 },
|
{"light_", 8 },
|
||||||
{"pastel_", 9 },
|
{"pastel_", 9 },
|
||||||
{"faint_", 91 }
|
{"faint_", 91 }
|
||||||
|
|
||||||
|
-- note that dark_ medium_ and plain also have a half-saturation
|
||||||
|
-- equivalent automatically defined in the code
|
||||||
}
|
}
|
||||||
|
|
||||||
dofile(minetest.get_modpath("stained_glass").."/high_glow.lua")
|
for i in ipairs(stained_glass_hues) do
|
||||||
dofile(minetest.get_modpath("stained_glass").."/low_glow.lua")
|
|
||||||
dofile(minetest.get_modpath("stained_glass").."/no_glow.lua")
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("stained_glass").."/noglow.lua")
|
local huename = stained_glass_hues[i][1]
|
||||||
dofile(minetest.get_modpath("stained_glass").."/lowglow.lua")
|
local huenumber = i
|
||||||
|
|
||||||
|
for j in ipairs(stained_glass_shades) do
|
||||||
|
|
||||||
|
local shadename = stained_glass_shades[j][1]
|
||||||
|
local shadenumber = stained_glass_shades[j][2]
|
||||||
|
|
||||||
|
local recipevalue = nil
|
||||||
|
|
||||||
|
recipevalue = "group:dye,unicolor_"..shadename..huename
|
||||||
|
if (shadename == "" and stained_glass_hues[i][2]) then
|
||||||
|
-- print(huename .. " is set to true -- substituting dye:huename ")
|
||||||
|
recipevalue = "dye:"..huename
|
||||||
|
elseif (shadename=="pastel_" or shadename=="faint_") then
|
||||||
|
-- force light_dye for pastel and faint colors
|
||||||
|
recipevalue = "group:dye,unicolor_light_"..huename
|
||||||
|
else -- default case
|
||||||
|
recipevalue = "group:dye,unicolor_"..shadename..huename
|
||||||
|
end
|
||||||
|
|
||||||
|
if shadename == "dark_" or shadename == "medium_" or shadename == "" then
|
||||||
|
stained_glass_define({
|
||||||
|
colorcode = huenumber.."_"..shadenumber.."_7",
|
||||||
|
colorname = shadename..huename,
|
||||||
|
recipe = recipevalue,
|
||||||
|
shade = shadename,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- below is the automatic "half saturation" block
|
||||||
|
-- which was mentioned previously
|
||||||
|
-- this is unicolor only, so switch dyename
|
||||||
|
-- back to unicolor...
|
||||||
|
recipevalue="group:dye,unicolor_"..shadename..huename
|
||||||
|
stained_glass_define({
|
||||||
|
colorcode = huenumber.."_"..shadenumber.."_6",
|
||||||
|
colorname = shadename..huename.."_s50",
|
||||||
|
recipe = recipevalue.."_s50",
|
||||||
|
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.
|
||||||
|
|
||||||
|
elseif shadename == "light_" or shadename == "pastel_" or shadename == "faint_" then
|
||||||
|
stained_glass_define({
|
||||||
|
colorcode = huenumber.."_"..shadenumber.."_",
|
||||||
|
colorname = shadename..huename,
|
||||||
|
recipe = recipevalue,
|
||||||
|
shade = shadename,
|
||||||
|
})
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
print("[stained_glass] Loaded!")
|
print("[stained_glass] Loaded!")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user