Major Update: 'Items and Utilities': Add Gunpowder, Coins, Sugar, and Ash. Add replacenear Chat Command, New Colored Blocks, New Grass, Revamp Light Texture, New Flower Type, New TNT Crafting Recipe, Add Crying Obsidian, and more!

This commit is contained in:
IamPyu 2024-06-14 18:19:12 -06:00
parent 839af08866
commit b6167af5dc
18 changed files with 213 additions and 73 deletions

View File

@ -0,0 +1,40 @@
-- Building tools
minetest.register_chatcommand("replacenear", {
privs = {
creative = true
},
func = function (name, param)
local parts = param:split(" ")
if #parts == 3 then
local player = minetest.get_player_by_name(name)
local pos = player:get_pos()
local range = tonumber(parts[1]) or 5
local from = parts[2]:split(",")
local to = parts[3]
local replaced = 0
local function replace(p)
for _, v in pairs(from) do
local name = minetest.get_node(p).name
local anyblock_match = (v == "anyblock" and name ~= "air" and name ~= "ignore")
if name == v or v == "any" or anyblock_match then
minetest.set_node(p, {name = to})
replaced = replaced + 1
end
end
end
for dx = -range, range do
for dz = -range, range do
for dy = -range, range do
local npos = {x = pos.x + dx, y = pos.y + dy, z = pos.z + dz}
replace(npos)
end
end
end
return true, string.format("Replaced %d blocks", replaced)
end
return false, "Requires 3 arguments"
end
})

View File

@ -14,7 +14,7 @@ minetest.register_abm({
nodenames = PyuTestCore.building_blocks,
neighbors = {"pyutest_core:contagious_acid"},
interval = 3.4,
chance = 8.7,
chance = 3.7,
catchup = true,
action = function (pos)
minetest.set_node(pos, {name = "pyutest_core:contagious_acid"})

View File

@ -41,67 +41,62 @@ PyuTestCore.node_boxes = {
PyuTestCore.building_blocks = {}
PyuTestCore.make_colored_blocks = function (color, dcolor, tex, colorspec, cgroups, bdrawtype, light)
PyuTestCore.make_building_blocks = function (color, dcolor, tex, colortint, cgroups, extra_conf)
local groups = cgroups or {
block = PyuTestCore.BLOCK_BREAKABLE_NORMAL
}
local econf = extra_conf or {}
local id_block = "pyutest_core:"..color.."_block"
local id_carpet = "pyutest_core:"..color.."_carpet"
local id_slab = "pyutest_core:"..color.."_slab"
local id_pillar = "pyutest_core:"..color.."_pillar"
minetest.register_node(id_block, {
minetest.register_node(id_block, PyuTestCore.util.tableconcat({
description = Translate(dcolor.." Block"),
drawtype = bdrawtype,
tiles = {tex},
color = colorspec,
color = colortint,
groups = groups,
sounds = PyuTestCore.make_node_sounds(),
paramtype = light and "light" or nil,
sunlight_propagates = light and true or nil
})
}, econf))
table.insert(PyuTestCore.building_blocks, id_block)
minetest.register_node(id_carpet, {
minetest.register_node(id_carpet, PyuTestCore.util.tableconcat({
description = Translate(dcolor .. " Carpet"),
tiles = {tex},
groups = groups,
color = colorspec,
color = colortint,
drawtype = "nodebox",
paramtype = "light",
paramtyp2 = "facedir",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.CARPET,
sounds = PyuTestCore.make_node_sounds(),
sunlight_propagates = light and true or nil
})
}, econf))
table.insert(PyuTestCore.building_blocks, id_carpet)
minetest.register_node(id_slab, {
minetest.register_node(id_slab, PyuTestCore.util.tableconcat({
description = Translate(dcolor.." Slab"),
tiles = {tex},
groups = groups,
color = colorspec,
color = colortint,
drawtype = "nodebox",
paramtype = "light",
paramtyp2 = "facedir",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.SLAB,
sounds = PyuTestCore.make_node_sounds(),
sunlight_propagates = light and true or nil
})
}, econf))
table.insert(PyuTestCore.building_blocks, id_slab)
minetest.register_node(id_pillar, {
minetest.register_node(id_pillar, PyuTestCore.util.tableconcat({
description = Translate(dcolor.." Pillar"),
tiles = {tex},
groups = groups,
color = colorspec,
color = colortint,
drawtype = "nodebox",
paramtype = "light",
paramtyp2 = "facedir",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.PILLAR,
sounds = PyuTestCore.make_node_sounds(),
sunlight_propagates = light and true or nil
})
}, econf))
table.insert(PyuTestCore.building_blocks, id_pillar)
minetest.register_craft({
@ -144,11 +139,13 @@ PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles)
walkable = false,
pointable = false,
buildable_to = true,
is_ground_content = false,
use_texture_alpha = "blend",
paramtype = "light",
drop = "",
drowning = 1,
liquidtype = liquidtype,
liquid_viscosity = 1,
liquid_alternative_flowing = nsname.."_flowing",
liquid_alternative_source = nsname.."_source"
}
@ -159,34 +156,45 @@ PyuTestCore.make_liquid = function (nsname, sname, desc, groups, tiles)
PyuTestCore.make_node(nsname.."_flowing", sname.."_flowing", "Flowing " .. desc, groups, tiles, make_liquid_flags("flowing"))
end
PyuTestCore.make_colored_blocks("grass", "Grass", "grass.png", nil)
PyuTestCore.make_colored_blocks("dirt", "Dirt", "dirt.png", nil)
PyuTestCore.make_colored_blocks("stone", "Stone", "stone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_colored_blocks("iron", "Iron", "iron.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_colored_blocks("wooden", "Wooden", "wood.png", nil)
PyuTestCore.make_colored_blocks("snow", "Snow", "snow.png", nil)
PyuTestCore.make_colored_blocks("sand", "Sand", "sand.png", nil)
PyuTestCore.make_colored_blocks("sandstone", "Sandstone", "sandstone.png", nil)
PyuTestCore.make_colored_blocks("ice", "Ice", "ice.png", nil)
PyuTestCore.make_colored_blocks("leaves", "Leaves", "leaves.png", nil)
PyuTestCore.make_colored_blocks("mushroom", "Mushroom", "mushroom.png", nil)
PyuTestCore.make_colored_blocks("mushroom_stem", "Mushroom Stem", "mushroom-stem.png", nil)
PyuTestCore.make_colored_blocks("mycelium", "Mycelium", "mycelium.png", nil)
PyuTestCore.make_colored_blocks("hellstone", "Hellstone", "hellstone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_colored_blocks("basalt", "Basalt", "basalt.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_colored_blocks("obsidian", "Obsidian", "obsidian.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_FOREVER})
PyuTestCore.make_colored_blocks("haybale", "Haybale", "haybale.png", nil)
PyuTestCore.make_building_blocks("grass", "Grass", "grass.png", nil, nil, {drop = "pyutest_core:dirt_block"})
PyuTestCore.make_building_blocks("dirt", "Dirt", "dirt.png", nil)
PyuTestCore.make_building_blocks("stone", "Stone", "stone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_building_blocks("iron", "Iron", "iron.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_building_blocks("wooden", "Wooden", "wood.png", nil)
PyuTestCore.make_building_blocks("snow", "Snow", "snow.png", nil)
PyuTestCore.make_building_blocks("sand", "Sand", "sand.png", nil)
PyuTestCore.make_building_blocks("sandstone", "Sandstone", "sandstone.png", nil)
PyuTestCore.make_building_blocks("ice", "Ice", "ice.png", nil)
PyuTestCore.make_building_blocks("leaves", "Leaves", "leaves.png", nil)
PyuTestCore.make_building_blocks("mushroom", "Mushroom", "mushroom.png", nil)
PyuTestCore.make_building_blocks("mushroom_stem", "Mushroom Stem", "mushroom-stem.png", nil)
PyuTestCore.make_building_blocks("mycelium", "Mycelium", "mycelium.png", nil)
PyuTestCore.make_building_blocks("hellstone", "Hellstone", "hellstone.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_building_blocks("basalt", "Basalt", "basalt.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_LONG})
PyuTestCore.make_building_blocks("obsidian", "Obsidian", "obsidian.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_FOREVER})
PyuTestCore.make_building_blocks("haybale", "Haybale", "haybale.png", nil)
PyuTestCore.make_building_blocks("crying_obsidian", "Crying Obsidian", "crying-obsidian.png", nil, {block = PyuTestCore.BLOCK_BREAKABLE_FOREVER})
PyuTestCore.make_colored_blocks("white", "White", "wool.png", "white")
PyuTestCore.make_colored_blocks("red", "Red", "wool.png", "red")
PyuTestCore.make_colored_blocks("orange", "Orange", "wool.png", "orange")
PyuTestCore.make_colored_blocks("yellow", "Yellow", "wool.png", "yellow")
PyuTestCore.make_colored_blocks("green", "Green", "wool.png", "green")
PyuTestCore.make_colored_blocks("blue", "Blue", "wool.png", "blue")
PyuTestCore.make_colored_blocks("purple", "Purple", "wool.png", "purple")
PyuTestCore.make_colored_blocks("black", "Black", "wool.png", "black")
PyuTestCore.make_colored_blocks("pink", "Pink", "wool.png", "hotpink")
PyuTestCore.make_colored_blocks("cherry", "Cherry", "wool.png", "lightpink")
PyuTestCore.make_building_blocks("color_white", "White", "wool.png", "white")
PyuTestCore.make_building_blocks("color_red", "Red", "wool.png", "red")
PyuTestCore.make_building_blocks("color_orange", "Orange", "wool.png", "orange")
PyuTestCore.make_building_blocks("color_yellow", "Yellow", "wool.png", "yellow")
PyuTestCore.make_building_blocks("color_green", "Green", "wool.png", "green")
PyuTestCore.make_building_blocks("color_blue", "Blue", "wool.png", "blue")
PyuTestCore.make_building_blocks("color_purple", "Purple", "wool.png", "purple")
PyuTestCore.make_building_blocks("color_black", "Black", "wool.png", "black")
PyuTestCore.make_building_blocks("color_pink", "Pink", "wool.png", "hotpink")
PyuTestCore.make_building_blocks("color_cherry", "Cherry", "wool.png", "lightpink")
PyuTestCore.make_building_blocks("color_brown", "Brown", "wool.png", "brown")
PyuTestCore.make_building_blocks("color_gray", "Gray", "wool.png", "gray")
PyuTestCore.make_building_blocks("color_teal", "Teal", "wool.png", "teal")
PyuTestCore.make_building_blocks("color_cyan", "Cyan", "wool.png", "cyan")
PyuTestCore.make_building_blocks("color_yellowgreen", "Yellow Green", "wool.png", "yellowgreen")
PyuTestCore.make_building_blocks("color_plum", "Plum", "wool.png", "plum")
PyuTestCore.make_building_blocks("color_gold", "Gold", "wool.png", "gold")
PyuTestCore.make_building_blocks("color_skyblue", "Sky Blue", "wool.png", "skyblue")
PyuTestCore.make_building_blocks("color_darkviolet", "Dark Violet", "wool.png", "darkviolet")
PyuTestCore.make_building_blocks("color_violet", "Violet", "wool.png", "violet")
PyuTestCore.make_node("pyutest_core:light", "light", "Light", {
snappy = 1,
@ -195,6 +203,10 @@ PyuTestCore.make_node("pyutest_core:light", "light", "Light", {
}, {
"light.png"
}, {
drawtype = "torchlike",
walkable = false,
paramtype = "light",
sunlight_propagates = true,
light_source = minetest.LIGHT_MAX,
on_rightclick = function ()
if minetest.get_timeofday() >= 0.5 then
@ -216,7 +228,7 @@ PyuTestCore.make_node("pyutest_core:torch", "torch", "Torch", {
walkable = false,
drawtype = "torchlike",
paramtype = "light",
inventory_image = "torch.png"
inventory_image = "torch.png",
})
PyuTestCore.make_node("pyutest_core:sponge", "sponge", "Sponge", {
@ -272,6 +284,20 @@ PyuTestCore.make_node("pyutest_core:flower3", "blue_daisy", "Blue Daisy", {
inventory_image = "flower3.png"
})
PyuTestCore.make_node("pyutest_core:flower4", "lavender", "Lavender", {
snappy = 1,
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
}, {"flower4.png"}, {
drawtype = "plantlike",
walkable = false,
waving = 1,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
inventory_image = "flower4.png"
})
PyuTestCore.make_node("pyutest_core:deadbush", "deadbush", "Deadbush", {
snappy = 1,
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
@ -285,6 +311,19 @@ PyuTestCore.make_node("pyutest_core:deadbush", "deadbush", "Deadbush", {
inventory_image = "deadbush.png"
})
PyuTestCore.make_node("pyutest_core:grass_plant", "grass_plant", "Grass", {
snappy = 1,
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
}, {"grass-plant.png"}, {
drawtype = "plantlike",
walkable = false,
waving = 1,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
inventory_image = "grass-plant.png"
})
PyuTestCore.make_node("pyutest_core:tree_sapling", "tree_sapling", "Tree Sapling", {
snappy = 1,
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
@ -298,9 +337,17 @@ PyuTestCore.make_node("pyutest_core:tree_sapling", "tree_sapling", "Tree Sapling
inventory_image = "sapling.png",
on_timer = function (pos)
local trees = {
"tree",
"tree2"
}
math.randomseed(os.time())
local selected_tree = trees[math.random(#trees)]
minetest.remove_node(pos)
pos.y = pos.y - 1
minetest.place_schematic(pos, PyuTestCore.get_schem_path("tree"), "random", nil, false, "place_center_x, place_center_z")
minetest.place_schematic(pos, PyuTestCore.get_schem_path(selected_tree), "random", nil, false, "place_center_x, place_center_z")
end,
on_rightclick = function (pos)
@ -369,6 +416,22 @@ PyuTestCore.make_node("pyutest_core:tnt", "tnt", "TNT", {
end
})
PyuTestCore.make_node("pyutest_core:crate", "crate", "Crate", {
block = PyuTestCore.BLOCK_BREAKABLE_NORMAL
}, {"crate.png"}, {
on_rightclick = function (pos, node, clicker)
local barrel_name = string.format("crate_x%d_y%d_z%d", pos.x, pos.y, pos.z)
local inventory = minetest.get_inventory({type="detached", name = barrel_name})
if inventory == nil then
inventory = minetest.create_detached_inventory(barrel_name)
inventory:set_size("main", 64)
inventory:set_width("main", 8)
end
end
})
PyuTestCore.make_liquid("pyutest_core:water", "water", "Water", {}, {"water.png"})
PyuTestCore.make_liquid("pyutest_core:lava", "lava", "Lava", {}, {"lava.png"})
PyuTestCore.make_liquid("pyutest_core:oil", "oil", "Oil", {}, {"oil.png"})

View File

@ -31,3 +31,11 @@ minetest.register_craft({
{"pyutest_core:torch", "pyutest_core:torch"}
}
})
minetest.register_craft({
output = "pyutest_core:tnt 3",
recipe = {
{"pyutest_core:sand_block", "pyutest_core:gunpowder"},
{"pyutest_core:gunpowder", "pyutest_core:sand_block"}
}
})

View File

@ -8,6 +8,13 @@ PyuTestCore = {
util = {
toint = function (float)
return tonumber(string.format("%d", float))
end,
tableconcat = function (t1, t2)
local nt = t1
for k, v in pairs(t2) do
nt[k] = v
end
return nt
end
}
}

View File

@ -1,18 +1,3 @@
-- player privs
minetest.register_on_joinplayer(function(player)
minetest.set_player_privs(player:get_player_name(), {
interact = true,
shout = true,
fly = true,
fast = true,
noclip = true,
give = true,
teleport = true,
bring = true,
settime = true
})
end)
-- player hand
minetest.register_item(":", {
type = "none",

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

View File

@ -51,10 +51,6 @@ PyuTestCore.make_tool("pyutest_core:pickaxe", "pickaxe", "Pickaxe", {}, "pickaxe
}
})
PyuTestCore.make_item("pyutest_core:stick", "stick", "Stick", {}, "stick.png", {
stack_max = 99
})
PyuTestCore.make_tool("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", {
on_use = function (_, user)
if user == nil then
@ -64,3 +60,33 @@ PyuTestCore.make_tool("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", {
PyuTestCore.create_explosion(pos, 2)
end
})
PyuTestCore.make_item("pyutest_core:stick", "stick", "Stick", {}, "stick.png", {
stack_max = 99
})
PyuTestCore.make_item("pyutest_core:gunpowder", "gunpowder", "Gunpowder", {}, "powder.png", {
color = "dimgray",
stack_max = 99
})
PyuTestCore.make_item("pyutest_core:ash", "ash", "Ash", {}, "powder.png", {
color = "gray",
stack_max = 99
})
PyuTestCore.make_item("pyutest_core:sugar", "sugar", "Sugar", {}, "powder.png", {
stack_max = 99
})
PyuTestCore.make_item("pyutest_core:coin", "coin", "Coin", {}, "coin.png", {
stack_max = 99,
on_secondary_use = function (_, user)
local pos = user:get_pos()
minetest.sound_play({name = "coin", gain = 1}, {
pos = pos
})
return nil
end
})

View File

@ -6,12 +6,23 @@ minetest.register_decoration({
biomes = {"forest", "grassland"},
y_max = PyuTestCore_BiomeTops.grassland,
y_min = 1,
decoration = {"pyutest_core:flower", "pyutest_core:flower2", "pyutest_core:flower3"}
decoration = {"pyutest_core:flower", "pyutest_core:flower2", "pyutest_core:flower3", "pyutest_core:flower4"}
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"pyutest_core:dirt_block"},
place_on = {"pyutest_core:grass_block"},
sidelen = 16,
fill_ratio = 0.048,
biomes = {"grassland"},
y_max = PyuTestCore_BiomeTops.grassland,
y_min = 1,
decoration = "pyutest_core:grass_plant"
})
minetest.register_decoration({
deco_type = "simple",
place_on = {"pyutest_core:dirt_block", "pyutest_core:sand_block"},
sidelen = 16,
fill_ratio = 0.019,
biomes = {"wasteland", "desert"},