Move magic wand info into nodes

master
Wuzzy 2021-08-04 09:29:49 +02:00
parent ac3f2592e6
commit 0638ff39dc
9 changed files with 60 additions and 61 deletions

View File

@ -14,6 +14,7 @@ minetest.register_node("hades_core:dirt", {
is_ground_content = true,
groups = {crumbly=3,soil=1,dirt=1, porous=1},
sounds = hades_sounds.node_sound_dirt_defaults(),
_hades_magic_next = "hades_core:dirt_with_grass_l1",
})
-- ... with grass cover
@ -44,6 +45,7 @@ minetest.register_node("hades_core:dirt_with_grass", {
local ret = minetest.item_place(itemstack, placer, pointed_thing, param2)
return ret
end,
_hades_magic_next = "hades_core:dirt",
})
-- Intermediate grass growth levels
@ -56,6 +58,12 @@ for l=1, 3 do
else
sounds = hades_sounds.node_sound_dirt_defaults()
end
local mnext
if l < 3 then
mnext = "hades_core:dirt_with_grass_l"..(l+1)
else
mnext = "hades_core:dirt_with_grass"
end
minetest.register_node("hades_core:dirt_with_grass_l"..l, {
description = S("Dirt with Growing Grass (Stage @1)", l),
tiles = {{name="default_dirt.png", color="white"}},
@ -82,6 +90,7 @@ for l=1, 3 do
local ret = minetest.item_place(itemstack, placer, pointed_thing, param2)
return ret
end,
_hades_magic_next = mnext,
})
end

View File

@ -189,6 +189,12 @@ hades_farming.register_plant = function(name, def)
if def.description_plant then
description_plant = S(def.description_plant, S("Stage @1", i))
end
local mnext
if i<def.steps then
mnext = mname .. ":" .. pname .. "_" .. (i+1)
else
mnext = mname .. ":" .. pname .. "_1"
end
minetest.register_node(mname .. ":" .. pname .. "_" .. i, {
drawtype = "plantlike",
description = description_plant,
@ -210,6 +216,7 @@ hades_farming.register_plant = function(name, def)
},
groups = nodegroups,
sounds = hades_sounds.node_sound_grass_defaults(),
_hades_magic_next = mnext,
})
end

View File

@ -33,7 +33,8 @@ minetest.register_node("hades_farming:soil", {
base = "hades_core:dirt",
dry = "hades_farming:soil",
wet = "hades_farming:soil_wet"
}
},
_hades_magic_next = "hades_farming:soil_wet",
})
minetest.register_node("hades_farming:soil_wet", {
@ -49,7 +50,8 @@ minetest.register_node("hades_farming:soil_wet", {
base = "hades_core:dirt",
dry = "hades_farming:soil",
wet = "hades_farming:soil_wet"
}
},
_hades_magic_next = "hades_farming:soil",
})

View File

@ -65,6 +65,7 @@ minetest.register_node("hades_grass:grass_1", {
local ret = minetest.item_place(itemstack, placer, pointed_thing, param2)
return ItemStack("hades_grass:grass_1 "..ret:get_count())
end,
_hades_magic_next = "hades_grass:grass_2",
})
for i=2,5 do
@ -96,6 +97,7 @@ for i=2,5 do
local ret = minetest.item_place(stack, placer, pointed_thing, param2)
return ret
end,
_hades_magic_next = "hades_grass:grass_"..(i%5+1),
})
end
@ -258,6 +260,7 @@ minetest.register_node("hades_grass:dead_grass_1", {
type = "fixed",
fixed = {-6/16, -0.5, -6/16, 6/16, -5/16, 6/16},
},
_hades_magic_next = "hades_grass:dead_grass_2",
})
for i=2,5 do
@ -283,6 +286,7 @@ for i=2,5 do
type = "fixed",
fixed = {-6/16, -0.5, -6/16, 6/16, -3/16, 6/16},
},
_hades_magic_next = "hades_grass:dead_grass_"..(i%5+1),
})
end

View File

@ -1,58 +1,8 @@
local S = minetest.get_translator("hades_magic_wand")
local cycles = {
{ "hades_core:dirt", "hades_core:dirt_with_grass_l1", "hades_core:dirt_with_grass_l2", "hades_core:dirt_with_grass_l3", "hades_core:dirt_with_grass" },
{ "hades_farming:soil", "hades_farming:soil_wet" },
{ "hades_grass:grass_1", "hades_grass:grass_2", "hades_grass:grass_3", "hades_grass:grass_4", "hades_grass:grass_5" },
{ "hades_grass:dead_grass_1", "hades_grass:dead_grass_2", "hades_grass:dead_grass_3", "hades_grass:dead_grass_4", "hades_grass:dead_grass_5" },
{ "hades_waterplants:seaweed_4", "hades_waterplants:seaweed_2", "hades_waterplants:seaweed_3", "hades_waterplants:seaweed" },
{ "hades_waterplants:waterlily", "hades_waterplants:waterlily_225", "hades_waterplants:waterlily_45", "hades_waterplants:waterlily_675", "hades_waterplants:waterlily_s3", "hades_waterplants:waterlily_s1", "hades_waterplants:waterlily_s2", "hades_waterplants:waterlily_s4" },
{ "hades_vines:willow", "hades_vines:willow_rotten" },
{ "hades_vines:jungle", "hades_vines:jungle_rotten" },
{ "hades_vines:cave", "hades_vines:cave_rotten" },
{ "hades_refruit:bud_apple", "hades_refruit:flower_apple", "hades_trees:apple" },
{ "hades_refruit:bud_olive", "hades_refruit:flower_olive", "hades_trees:olive" },
{ "hades_refruit:bud_cocoa", "hades_refruit:flower_cocoa", "hades_trees:cocoa_pod" },
{ "hades_refruit:bud_coconut", "hades_refruit:flower_coconut", "hades_trees:coconut" },
{ "hades_refruit:bud_banana", "hades_refruit:flower_banana", "hades_trees:banana" },
{ "hades_refruit:bud_orange", "hades_refruit:flower_orange", "hades_trees:orange" },
}
local seeds = {
{ 3, "hades_farming", { "cotton", "wheat", "spice", "potato", "strawberry", "tomato" } },
}
for s=1,#seeds do
local seedinfo = seeds[s]
local max = seedinfo[1]
local mod = seedinfo[2]
local seedtypes = seedinfo[3]
for t=1, #seedtypes do
local seed = seedtypes[1]
local seeditems = { mod..":seed_"..seed }
for i=1,max do
table.insert(seeditems, mod..":"..seed.."_"..i)
end
table.insert(cycles, seeditems)
end
end
local conversions = {}
for c=1, #cycles do
for d=1, #cycles[c] do
local cthis = cycles[c][d]
local next_num = d+1
if next_num > #cycles[c] then
next_num = 1
end
local cnext = cycles[c][next_num]
conversions[cthis] = cnext
end
end
minetest.register_craftitem("hades_magic_wand:magic_wand", {
description = S("Magic Wand"),
_tt_help = S("Changes block state"),
_tt_help = S("Changes block variant"),
inventory_image = "default_stick.png^[colorize:#940EFE:127",
wield_image = "default_stick.png^[colorize:#940EFE:127",
groups = { tool = 1, disable_repair = 1 },
@ -60,8 +10,9 @@ minetest.register_craftitem("hades_magic_wand:magic_wand", {
if pointed_thing.type == "node" then
local pos = pointed_thing.under
local node = minetest.get_node(pointed_thing.under)
if conversions[node.name] then
node.name = conversions[node.name]
local def = minetest.registered_items[node.name]
if def and def._hades_magic_next then
node.name = def._hades_magic_next
minetest.swap_node(pos, node)
end
end

View File

@ -1,2 +1,2 @@
name = hades_magic_wand
description = Tool that cycles through block states for Creative Mode
description = Tool that cycles through block variants for Creative Mode

View File

@ -16,6 +16,10 @@ function hades_refruit.add_hades_refruit(id, def)
groups_fruit = table.copy(groups)
groups_fruit.fruit_regrow = 3
local bud_itemstring = "hades_refruit:bud_"..id
local flower_itemstring = "hades_refruit:flower_"..id
minetest.override_item(def.fruit_itemstring, {
groups = groups_fruit,
place_param2 = 1,
@ -29,12 +33,10 @@ function hades_refruit.add_hades_refruit(id, def)
return
end
end,
node_dig_prediction = "hades_refruit:bud_"..id,
node_dig_prediction = bud_itemstring,
_hades_magic_next = bud_itemstring,
})
local bud_itemstring = "hades_refruit:bud_"..id
local flower_itemstring = "hades_refruit:flower_"..id
minetest.register_node(bud_itemstring, {
description = def.bud_description,
_tt_help = def.bud_tt,
@ -53,6 +55,7 @@ function hades_refruit.add_hades_refruit(id, def)
groups = {fruit_regrow=1, snappy=2,oddly_breakable_by_hand=3,flammable=2,leafdecay=3,leafdecay_drop=1},
drop = def.bud_drop or {},
sounds = hades_sounds.node_sound_leaves_defaults(),
_hades_magic_next = flower_itemstring,
})
minetest.register_node(flower_itemstring, {
description = def.flower_description,
@ -72,6 +75,7 @@ function hades_refruit.add_hades_refruit(id, def)
groups = {fruit_regrow=2, snappy=2,oddly_breakable_by_hand=3,flammable=2,leafdecay=3,leafdecay_drop=1},
drop = def.flower_drop or {},
sounds = hades_sounds.node_sound_leaves_defaults(),
_hades_magic_next = def.fruit_itemstring,
})
minetest.register_abm({

View File

@ -171,6 +171,11 @@ local function register_vine(id, def)
local is_centered = def.groups.vines == 2
local mnext
if def.description_rotten then
mnext = "hades_vines:"..id.."_rotten"
end
minetest.register_node("hades_vines:"..id, {
description = def.description_normal,
_tt_help = tt_surv,
@ -195,7 +200,8 @@ local function register_vine(id, def)
on_dig = on_dig,
on_rotate = on_rotate,
after_dig_node = after_dig_node,
})
_hades_magic_next = mnext,
})
if def.description_rotten then
local groups_rotten = table.copy(def.groups)
@ -222,6 +228,7 @@ local function register_vine(id, def)
on_place = get_on_place(is_centered),
on_dig = on_dig,
after_dig_node = after_dig_node,
_hades_magic_next = "hades_vines:"..id,
})
end
end

View File

@ -98,6 +98,7 @@ local on_place_waterlily = generate_on_place("hades_waterplants:waterlily", lili
for i in ipairs(lilies_list) do
local deg1 = ""
local deg1_next = ""
local deg2 = ""
local is_classic = false
local lily_groups = {snappy = 3,flammable=2,waterlily=1,falling_node=1,float=1}
@ -109,6 +110,12 @@ for i in ipairs(lilies_list) do
deg2 = "_"..lilies_list[i][2]
lily_groups = { snappy = 3,flammable=2,waterlily=1, not_in_creative_inventory=1,falling_node=1,float=1 }
end
if i < #lilies_list then
deg1_next = "_"..lilies_list[i+1][1]
else
deg1_next = ""
end
local mnext = "hades_waterplants:waterlily"..deg1_next
local on_rotate = "simple"
if is_classic and has_screwdriver then
@ -168,6 +175,7 @@ for i in ipairs(lilies_list) do
node_placement_prediction = "",
on_place = on_place_waterlily,
on_rotate = on_rotate,
_hades_magic_next = mnext,
})
end
@ -185,6 +193,12 @@ for i in ipairs(seaweed_list) do
num = "_"..seaweed_list[i][1]
seaweed_groups = { snappy = 3,flammable=2,seaweed=1, not_in_creative_inventory=1,falling_node=1,float=1 }
end
local mnext
if i < #seaweed_list then
mnext = "hades_waterplants:seaweed_"..seaweed_list[i+1][1]
else
mnext = "hades_waterplants:seaweed"
end
minetest.register_node("hades_waterplants:seaweed"..num, {
description = S("Seaweed"),
@ -219,6 +233,7 @@ for i in ipairs(seaweed_list) do
node_placement_prediction = "",
on_place = on_place_seaweed,
on_rotate = "simple",
_hades_magic_next = mnext,
})
end