diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c93fc3..46e1790 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Dec 2nd - STILL UNDER DEVELOPMENT] Major Update: The Greatest Update +## [Dec 2nd - Dec 22nd] Major Update: The Greatest Update **THIS UPDATE CONTAINS BREAKING CHANGES!!** diff --git a/mods/ITEMS/pyutest_buckets/init.lua b/mods/ITEMS/pyutest_buckets/init.lua index cab2bfd..ad31923 100644 --- a/mods/ITEMS/pyutest_buckets/init.lua +++ b/mods/ITEMS/pyutest_buckets/init.lua @@ -34,13 +34,13 @@ core.register_craft({ } }) -PyuTest.make_liquid_bucket = function(name, desc, source, color) +PyuTest.make_liquid_bucket = function(name, desc, source, color, groups) local colorspec = core.colorspec_to_colorstring(color) local texture = string.format("pyutest-bucket.png^(pyutest-bucket-overlay.png^[colorize:%s)", colorspec) - PyuTest.make_node(name, desc, { + PyuTest.make_node(name, desc, PyuTest.util.tableconcat({ bucket = 1 - }, {}, { + }, groups or {}), {}, { drawtype = "airlike", walkable = false, pointable = false, @@ -67,7 +67,10 @@ PyuTest.make_liquid_bucket = function(name, desc, source, color) }) end -PyuTest.make_liquid_bucket("pyutest_buckets:water_bucket", "Bucket of Water", "pyutest_blocks:water_source", "blue") +PyuTest.make_liquid_bucket("pyutest_buckets:water_bucket", "Bucket of Water", +"pyutest_blocks:water_source", "blue", { + brewing_fuel = 1, +}) PyuTest.make_liquid_bucket("pyutest_buckets:lava_bucket", "Bucket of Lava", "pyutest_blocks:lava_source", "orange") PyuTest.make_liquid_bucket("pyutest_buckets:acid_bucket", "Bucket of Acid", "pyutest_blocks:liquid_acid_source", "#6c7232") PyuTest.make_liquid_bucket("pyutest_buckets:oil_bucket", "Bucket of Oil", "pyutest_blocks:oil_source", PyuTest.COLORS.black[2]) diff --git a/mods/ITEMS/pyutest_potions/api.lua b/mods/ITEMS/pyutest_potions/api.lua new file mode 100644 index 0000000..a3c746b --- /dev/null +++ b/mods/ITEMS/pyutest_potions/api.lua @@ -0,0 +1,95 @@ +PyuTest.potion_recipes = {} + +PyuTest.make_potion = function (name, desc, options) + local colorspec = core.colorspec_to_colorstring(options.color or "red") + local texture = string.format("pyutest-glass-bottle.png^(pyutest-bottle-overlay.png^[colorize:%s)", colorspec) + local ptexture = string.format("pyutest-snowball-particle.png^[colorize:%s", colorspec) + + local l = options.length or 60 + local m = options.multiplier or 1.15 + local e_id = name .. "_splash" + + if options.craft ~= nil then + PyuTest.potion_recipes[options.craft] = name + end + + PyuTest.make_projectile(e_id, { + visual = "sprite", + textures = {texture}, + }, { + _slowdown = false, + }, { + on_hit_node = function (self, pos, node) + splash(pos + vector.new(0, 1, 0)) + end, + on_hit_object = function (self, object) + splash(self.object:get_pos(), self.object) + end + }) + + local function drink(itemstack, user, pointed_thing) + if user == nil or not user:is_player() then + return + end + + if options.action then + options.action(itemstack, user, pointed_thing) + else + local playername = user:get_player_name() + PyuTest.status_effect_add(playername, options.effect, m, l) + end + + itemstack:take_item() + return itemstack + end + + local function splash(pos, obj) + local rad = options.radius or 2 + for o in core.objects_inside_radius(pos, rad) do + if o ~= obj then + if o:is_player() then + if options.action_splash then + options.action_splash(o) + else + local playername = o:get_player_name() + PyuTest.status_effect_add(playername, options.effect, m, l) + end + end + end + end + + local vel = 2 + core.add_particlespawner({ + amount = math.random(5, 10), + time = 0.8, + exptime = 0.4, + vertical = true, + glow = core.LIGHT_MAX, + minsize = 1.3, + maxsize = 1.3, + + texture = ptexture, + pos = pos, + minvel = vector.new(-vel, -vel, -vel), + maxvel = vector.new(vel, vel, vel), + }) + end + + local function launch(itemstack, user, pointed_thing) + core.sound_play("pyutest-throw", { + player = user:get_player_name() + }) + PyuTest.shoot_projectile_from_object(e_id, user) + + itemstack:take_item() + return itemstack + end + + PyuTest.make_item(name, desc, { + potion = 1 + }, texture, { + on_use = drink, + on_place = launch, + on_secondary_use = launch + }) +end diff --git a/mods/ITEMS/pyutest_potions/cauldron.lua b/mods/ITEMS/pyutest_potions/cauldron.lua new file mode 100644 index 0000000..84ea261 --- /dev/null +++ b/mods/ITEMS/pyutest_potions/cauldron.lua @@ -0,0 +1,104 @@ +-- from https://git.minetest.land/VoxeLibre/VoxeLibre/src/branch/master/mods/ITEMS/mcl_cauldrons/init.lua#L20 +local node_box = { + type = "fixed", + fixed = { + {-0.5, -0.1875, -0.5, -0.375, 0.5, 0.5}, -- Left wall + {0.375, -0.1875, -0.5, 0.5, 0.5, 0.5}, -- Right wall + {-0.375, -0.1875, 0.375, 0.375, 0.5, 0.5}, -- Back wall + {-0.375, -0.1875, -0.5, 0.375, 0.5, -0.375}, -- Front wall + {-0.5, -0.3125, -0.5, 0.5, -0.1875, 0.5}, -- Floor + {-0.5, -0.5, -0.5, -0.375, -0.3125, -0.25}, -- Left front foot, part 1 + {-0.375, -0.5, -0.5, -0.25, -0.3125, -0.375}, -- Left front foot, part 2 + {-0.5, -0.5, 0.25, -0.375, -0.3125, 0.5}, -- Left back foot, part 1 + {-0.375, -0.5, 0.375, -0.25, -0.3125, 0.5}, -- Left back foot, part 2 + {0.375, -0.5, 0.25, 0.5, -0.3125, 0.5}, -- Right back foot, part 1 + {0.25, -0.5, 0.375, 0.375, -0.3125, 0.5}, -- Right back foot, part 2 + {0.375, -0.5, -0.5, 0.5, -0.3125, -0.25}, -- Right front foot, part 1 + {0.25, -0.5, -0.5, 0.375, -0.3125, -0.375}, -- Right front foot, part 2 + } +} + +local function cauldron_formspec(pos) + local spos = string.format("%d,%d,%d", pos.x, pos.y, pos.z) + + local formspec = { + "size[8,9]", + "list[nodemeta:", spos, ";main;0,0;8,4;]", + "list[context;src;1,1;1,1;]", + "list[context;fuel;1,2.5;1,1;]", + "list[context;dst;5,1.25;2,2;]", + "button[2,3.5;4,2;brew;Brew]", + "list[current_player;main;0,5;8,4;]" + } + + return table.concat(formspec) +end + +local function on_construct(pos) + local meta = core.get_meta(pos) + local inventory = meta:get_inventory() + inventory:set_size("src", 1) + inventory:set_size("fuel", 1) + inventory:set_size("dst", 4) + meta:set_string("formspec", cauldron_formspec(pos)) +end + +local function on_destruct(pos) + local drops = {} + PyuTest.get_inventory_drops(pos, "src", drops) + PyuTest.get_inventory_drops(pos, "fuel", drops) + PyuTest.get_inventory_drops(pos, "dst", drops) + + for _, v in pairs(drops) do + core.add_item(pos, v) + end +end + +local function on_receive_fields(pos, formname, fields, player) + if fields.quit then return end + + local meta = core.get_meta(pos) + local inv = meta:get_inventory() + + if fields.brew then + local src = inv:get_stack("src", 1) + local fuel = inv:get_stack("fuel", 1) + + if core.get_item_group(fuel:get_name(), "brewing_fuel") == 0 then + return + end + + local output = PyuTest.potion_recipes[src:get_name()] + + if output == nil then + return + end + + inv:add_item("dst", output) + src:take_item() + fuel:take_item() + inv:set_stack("src", 1, src) + inv:set_stack("fuel", 1, fuel) + end +end + +PyuTest.make_node("pyutest_potions:cauldron", "Cauldron", { + cracky = PyuTest.BLOCK_NORMAL, + cauldron = 1, +}, {"pyutest-metal.png"}, { + drawtype = "nodebox", + paramtype = "light", + node_box = node_box, + on_construct = on_construct, + on_destruct = on_destruct, + on_receive_fields = on_receive_fields +}) + +core.register_craft({ + output = "pyutest_potions:cauldron", + recipe = { + {"pyutest_ores:iron_ingot", "", "pyutest_ores:iron_ingot"}, + {"pyutest_ores:iron_ingot", "", "pyutest_ores:iron_ingot"}, + {"pyutest_ores:iron_ingot", "pyutest_ores:iron_ingot", "pyutest_ores:iron_ingot"}, + } +}) diff --git a/mods/ITEMS/pyutest_potions/init.lua b/mods/ITEMS/pyutest_potions/init.lua index de5d80c..c2e4f34 100644 --- a/mods/ITEMS/pyutest_potions/init.lua +++ b/mods/ITEMS/pyutest_potions/init.lua @@ -1,145 +1,5 @@ -PyuTest.make_potion = function (name, desc, options) - local colorspec = core.colorspec_to_colorstring(options.color or "red") - local texture = string.format("pyutest-glass-bottle.png^(pyutest-bottle-overlay.png^[colorize:%s)", colorspec) - local ptexture = string.format("pyutest-snowball-particle.png^[colorize:%s", colorspec) +local modpath = core.get_modpath(core.get_current_modname()) - local l = options.length or 60 - local m = options.multiplier or 1.15 - local e_id = name .. "_splash" - - local function splash(pos, obj) - local rad = options.radius or 2 - for o in core.objects_inside_radius(pos, rad) do - if o ~= obj then - if o:is_player() then - if options.action_splash then - options.action_splash(o) - else - local playername = o:get_player_name() - PyuTest.status_effect_add(playername, options.effect, m) - - core.after(l, function () - PyuTest.status_effect_remove(playername, options.effect) - end) - end - end - end - end - - local vel = 2 - core.add_particlespawner({ - amount = math.random(5, 10), - time = 0.8, - exptime = 0.4, - vertical = true, - glow = core.LIGHT_MAX, - minsize = 1.3, - maxsize = 1.3, - - texture = ptexture, - pos = pos, - minvel = vector.new(-vel, -vel, -vel), - maxvel = vector.new(vel, vel, vel), - }) - end - - PyuTest.make_projectile(e_id, { - visual = "sprite", - textures = {texture}, - }, { - _slowdown = false, - }, { - on_hit_node = function (self, pos, node) - splash(pos + vector.new(0, 1, 0)) - end, - on_hit_object = function (self, object) - splash(self.object:get_pos(), self.object) - end - }) - - local function drink(itemstack, user, pointed_thing) - if user == nil or not user:is_player() then - return - end - - if options.action then - options.action(itemstack, user, pointed_thing) - else - local playername = user:get_player_name() - PyuTest.status_effect_add(playername, options.effect, m) - - core.after(l, function () - PyuTest.status_effect_remove(playername, options.effect) - end) - end - - itemstack:take_item() - return itemstack - end - - local function launch(itemstack, user, pointed_thing) - core.sound_play("pyutest-throw", { - player = user:get_player_name() - }) - PyuTest.shoot_projectile_from_object(e_id, user) - - itemstack:take_item() - return itemstack - end - - PyuTest.make_item(name, desc, { - potion = 1 - }, texture, { - on_use = drink, - on_place = launch, - on_secondary_use = launch - }) -end - -PyuTest.make_potion("pyutest_potions:speed", "Speed Potion", { - color = PyuTest.COLORS.turquoise[2], - effect = "speed", - multiplier = 2.5, - length = 60 -}) - -PyuTest.make_potion("pyutest_potions:slowness", "Slowness Potion", { - color = PyuTest.COLORS.grey[2], - effect = "speed", - multiplier = 0.45, - length = 60 -}) - -PyuTest.make_potion("pyutest_potions:jump_boost", "Jump Boost Potion", { - color = PyuTest.COLORS.pink[2], - effect = "jump_boost", - multiplier = 2.5, - length = 60 -}) - -PyuTest.make_potion("pyutest_potions:low_gravity", "Low Gravity Potion", { - color = PyuTest.COLORS.chartreuse[2], - effect = "low_gravity", - multiplier = 0.25, - length = 30 -}) - -PyuTest.make_potion("pyutest_potions:instant_damage", "Instant Damage Potion", { - color = PyuTest.COLORS.bloodred[2], - action = function (itemstack, user, pointed_thing) - PyuTest.deal_damage(user, 6, PyuTest.DAMAGE_TYPES.magic()) - end, - action_splash = function (object) - PyuTest.deal_damage(object, 6, PyuTest.DAMAGE_TYPES.magic()) - end -}) - -PyuTest.make_potion("pyutest_potions:instant_health", "Instant Health Potion", { - color = PyuTest.COLORS.red[2], - action = function (itemstack, user, pointed_thing) - PyuTest.deal_damage(user, -6, PyuTest.DAMAGE_TYPES.magic()) - end, - action_splash = function (object) - PyuTest.deal_damage(object, -6, PyuTest.DAMAGE_TYPES.magic()) - end -}) +dofile(modpath .. "/api.lua") +dofile(modpath .. "/potions.lua") +dofile(modpath .. "/cauldron.lua") diff --git a/mods/ITEMS/pyutest_potions/potions.lua b/mods/ITEMS/pyutest_potions/potions.lua new file mode 100644 index 0000000..0bbdc54 --- /dev/null +++ b/mods/ITEMS/pyutest_potions/potions.lua @@ -0,0 +1,51 @@ +PyuTest.make_potion("pyutest_potions:speed", "Speed Potion", { + color = PyuTest.COLORS.turquoise[2], + effect = "speed", + multiplier = 2.5, + length = 60, + craft = "pyutest_tools:sugar" +}) + +PyuTest.make_potion("pyutest_potions:slowness", "Slowness Potion", { + color = PyuTest.COLORS.grey[2], + effect = "speed", + multiplier = 0.45, + length = 60, + craft = "pyutest_tools:ash" +}) + +PyuTest.make_potion("pyutest_potions:jump_boost", "Jump Boost Potion", { + color = PyuTest.COLORS.pink[2], + effect = "jump_boost", + multiplier = 2.5, + length = 60, + craft = "pyutest_tools:paper" +}) + +PyuTest.make_potion("pyutest_potions:low_gravity", "Low Gravity Potion", { + color = PyuTest.COLORS.chartreuse[2], + effect = "low_gravity", + multiplier = 0.25, + length = 30, + craft = "pyutest_tools:snowball" +}) + +PyuTest.make_potion("pyutest_potions:instant_damage", "Instant Damage Potion", { + color = PyuTest.COLORS.bloodred[2], + action = function (itemstack, user, pointed_thing) + PyuTest.deal_damage(user, 6, PyuTest.DAMAGE_TYPES.magic()) + end, + action_splash = function (object) + PyuTest.deal_damage(object, 6, PyuTest.DAMAGE_TYPES.magic()) + end +}) + +PyuTest.make_potion("pyutest_potions:instant_health", "Instant Health Potion", { + color = PyuTest.COLORS.red[2], + action = function (itemstack, user, pointed_thing) + PyuTest.deal_damage(user, -6, PyuTest.DAMAGE_TYPES.magic()) + end, + action_splash = function (object) + PyuTest.deal_damage(object, -6, PyuTest.DAMAGE_TYPES.magic()) + end +}) diff --git a/mods/PLAYER/pyutest_effects/init.lua b/mods/PLAYER/pyutest_effects/init.lua index 1c49460..10fb42a 100644 --- a/mods/PLAYER/pyutest_effects/init.lua +++ b/mods/PLAYER/pyutest_effects/init.lua @@ -7,8 +7,14 @@ PyuTest.STATUS_EFFECTS = { "low_gravity" } -PyuTest.status_effect_add = function(player, name, multiplier) +PyuTest.status_effect_add = function(player, name, multiplier, length) effects[player][name] = multiplier + + if length ~= nil then + core.after(length, function() + PyuTest.status_effect_remove(player, name) + end) + end end PyuTest.status_effect_remove = function (player, name) @@ -100,11 +106,7 @@ core.register_chatcommand("effect", { local time = tonumber(split[4]) local multiplier = tonumber(split[5]) for _, v in pairs(targets) do - PyuTest.status_effect_add(v, effect, multiplier) - - core.after(time, function () - PyuTest.status_effect_remove(v, effect) - end) + PyuTest.status_effect_add(v, effect, multiplier, time) end elseif option == "remove" and #split == 3 then for _, v in pairs(targets) do