diff --git a/CHANGELOG.md b/CHANGELOG.md index cc19c5e..c7c5043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,9 +18,11 @@ Notable Game Changes: - Improved command system and added Command Blocks - Added many new commands, while also improving some builtin Luanti ones. - Redesign the electricity system using a system similar to [Age of Mending's](https://content.luanti.org/packages/Sumianvoice/pmb_core/) wiring system -- New electricity devices: +- New electricity devices and components: - Dropper - Dispenser + - Note Block + - Delayer Other Game Changes: @@ -57,6 +59,7 @@ Other Game Changes: - Mushroom biomes are now marked as lowlands, only going up to Y 10 - Superslime now bounces the player slightly higher - Add back the Rubies that were removed a while ago! +- New Heater Device recipe Code Changes: diff --git a/CREDITS.md b/CREDITS.md index 9a6454d..285f93e 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -6,7 +6,11 @@ Programming done by me. ## Sounds -Sounds generated with [JFXR](https://jfxr.frozenfractal.com) +Most sounds are generated with [JFXR](https://jfxr.frozenfractal.com) + +Credit for sounds I didn't make and are not made with JFXR: + +- Piano F#.wav by pinkyfinger -- https://freesound.org/s/68445/ -- License: Creative Commons 0 ## Textures diff --git a/TODO.md b/TODO.md index 63c2477..8075045 100644 --- a/TODO.md +++ b/TODO.md @@ -9,7 +9,3 @@ Those transports include: - Boats - Horses - Railways and Minecarts - -## Electricity Update Pt. 2 - -Self-explanatory, this update would improve the electricity system. Currently it is badly made and even has the ability to freeze the entire server, or if in a singleplayer world your entire desktop. diff --git a/mods/CORE/pyutest/sounds/pyutest-note.ogg b/mods/CORE/pyutest/sounds/pyutest-note.ogg new file mode 100644 index 0000000..e044313 Binary files /dev/null and b/mods/CORE/pyutest/sounds/pyutest-note.ogg differ diff --git a/mods/ITEMS/pyutest_electricity/api.lua b/mods/ITEMS/pyutest_electricity/api.lua index 321dae8..2d671f6 100644 --- a/mods/ITEMS/pyutest_electricity/api.lua +++ b/mods/ITEMS/pyutest_electricity/api.lua @@ -1,9 +1,9 @@ -PyuTest.electricity_activate = function(pos, sender_pos) +PyuTest.electricity_activate = function(pos, sender_pos, sender) local node = core.get_node(pos) local def = core.registered_nodes[node.name] if def.__on_electricity_input then - def.__on_electricity_input(pos, node, sender_pos) + def.__on_electricity_input(pos, node, sender_pos, sender) end end @@ -15,14 +15,14 @@ end PyuTest.component_action = function (pos, interacter) core.sound_play("button", { pos = pos, - gain = 1 + gain = 0.35 }) local p = PyuTest.get_node_electricity_targets(pos) if p then for _, pp in pairs(p) do - PyuTest.electricity_activate(pp, pos) + PyuTest.electricity_activate(pp, pos, interacter) end else core.chat_send_player(interacter:get_player_name(), "This component isn't bound to anything!") diff --git a/mods/ITEMS/pyutest_electricity/components/delayer.lua b/mods/ITEMS/pyutest_electricity/components/delayer.lua new file mode 100644 index 0000000..f3c9c46 --- /dev/null +++ b/mods/ITEMS/pyutest_electricity/components/delayer.lua @@ -0,0 +1,53 @@ +local DELAYS = { + 0.2, + 0.4, + 0.6, + 0.8, + 1.0 +} + +local DELAY_POSITION_KEY = "delay" + +local function after_place_node(pos) + local meta = core.get_meta(pos) + meta:set_int(DELAY_POSITION_KEY, 1) + + PyuTest.component_after_place_node(pos) +end + +local function on_rightclick(pos, node, clicker) + local meta = core.get_meta(pos) + local dpos = meta:get_int(DELAY_POSITION_KEY) + + if dpos == #DELAYS then + meta:set_int(DELAY_POSITION_KEY, 1) + else + meta:set_int(DELAY_POSITION_KEY, dpos + 1) + end + + local seconds = DELAYS[meta:get_int(DELAY_POSITION_KEY)] + core.chat_send_player(clicker:get_player_name(), string.format("Delay set to %f seconds", seconds)) +end + +PyuTest.make_electricity_device("pyutest_electricity:delayer", "Delayer", { + cracky = PyuTest.BLOCK_NORMAL +}, {"pyutest-delayer.png"}, nil, { + after_place_node = after_place_node, + on_rightclick = on_rightclick +}, function (pos, node, sender_pos, sender) + local meta = core.get_meta(pos) + local seconds = DELAYS[meta:get_int(DELAY_POSITION_KEY)] + + core.after(seconds, function () + PyuTest.component_action(pos, sender) + end) +end) + +core.register_craft({ + output = "pyutest_electricity:button", + recipe = { + { "group:cobble", "group:cobble", "group:cobble" }, + { "group:cobble", "pyutest_ores:zinc_ingot", "group:cobble" }, + { "group:cobble", "group:cobble", "group:cobble" } + }, +}) diff --git a/mods/ITEMS/pyutest_electricity/devices.lua b/mods/ITEMS/pyutest_electricity/devices.lua index 9970fa2..7c77bda 100644 --- a/mods/ITEMS/pyutest_electricity/devices.lua +++ b/mods/ITEMS/pyutest_electricity/devices.lua @@ -17,7 +17,7 @@ end) PyuTest.make_electricity_device("pyutest_electricity:heater_device", "Heater Device", { cracky = PyuTest.BLOCK_FAST -}, { "pyutest-heater.png" }, "pyutest_blocks:fire", nil, function(pos, node, sender_pos) +}, { "pyutest-heater.png" }, "pyutest_blocks:magma", nil, function(pos, node, sender_pos) PyuTest.dorange(pos, 2, function(p) local n = core.get_node(p) diff --git a/mods/ITEMS/pyutest_electricity/devices/noteblock.lua b/mods/ITEMS/pyutest_electricity/devices/noteblock.lua new file mode 100644 index 0000000..8df50a4 --- /dev/null +++ b/mods/ITEMS/pyutest_electricity/devices/noteblock.lua @@ -0,0 +1,78 @@ +-- Thanks Minecraft wiki! https://minecraft.wiki/w/Note_Block +local NOTES = { + {2^(-12/12), "#77D700"}, + {2^(-11/12), "#95C000"}, + {2^(-10/12), "#B2A500"}, + {2^(-9/12), "#CC8600"}, + {2^(-8/12), "#E26500"}, + {2^(-7/12), "#F34100"}, + {2^(-6/12), "#FC1E00"}, + {2^(-5/12), "#FE000F"}, + {2^(-4/12), "#F70033"}, + {2^(-3/12), "#E8005A"}, + {2^(-2/12), "#CF0083"}, + {2^(-1/12), "#AE00A9"}, + {2^(0/12), "#8600CC"}, + {2^(1/12), "#5B00E7"}, + {2^(2/12), "#2D00F9"}, + {2^(3/12), "#020AFE"}, + {2^(4/12), "#0037F6"}, + {2^(5/12), "#0068E0"}, + {2^(6/12), "#009ABC"}, + {2^(7/12), "#00C68D"}, + {2^(8/12), "#00E958"}, + {2^(9/12), "#00FC21"}, + {2^(10/12), "#1FFC00"}, + {2^(11/12), "#59E800"}, + {2^(12/12), "#94C100"}, +} + +local NOTE_POSITION_KEY = "pitch_position" + +local function after_place_node(pos) + local meta = core.get_meta(pos) + + meta:set_int(NOTE_POSITION_KEY, #NOTES) +end + +local function play_sound(pos) + local meta = core.get_meta(pos) + local opts = NOTES[meta:get_int(NOTE_POSITION_KEY)] + local pitch = opts[1] + + core.sound_play("pyutest-note", { + pos = pos, + gain = 0.5, + pitch = pitch + }) + + math.randomseed(os.time()) + core.add_particle({ + texture = "pyutest-note.png^[multiply:"..opts[2], + pos = pos + vector.new(0, 1, 0), + velocity = vector.new(0, 0.45, 0), + expirationtime = 1, + size = 2, + vertical = true, + }) +end + +PyuTest.make_electricity_device("pyutest_electricity:note_block", "Note Block", { + choppy = PyuTest.BLOCK_FAST +}, {"pyutest-note-block.png"}, nil, { + after_place_node = after_place_node, + on_rightclick = function (pos, node, clicker) + local meta = core.get_meta(pos) + local ppos = meta:get_int(NOTE_POSITION_KEY) + + if ppos == #NOTES then + meta:set_int(NOTE_POSITION_KEY, 1) + else + meta:set_int(NOTE_POSITION_KEY, ppos + 1) + end + + play_sound(pos) + end +}, function (pos, node, sender_pos) + play_sound(pos) +end) diff --git a/mods/ITEMS/pyutest_electricity/init.lua b/mods/ITEMS/pyutest_electricity/init.lua index 79d3a46..8d77e43 100644 --- a/mods/ITEMS/pyutest_electricity/init.lua +++ b/mods/ITEMS/pyutest_electricity/init.lua @@ -2,8 +2,12 @@ local modpath = core.get_modpath("pyutest_electricity") dofile(modpath .. "/wirecutter.lua") dofile(modpath .. "/api.lua") + dofile(modpath .. "/components.lua") +dofile(modpath .. "/components/delayer.lua") + dofile(modpath .. "/devices.lua") dofile(modpath .. "/devices/lamp.lua") dofile(modpath .. "/devices/dropper.lua") +dofile(modpath .. "/devices/noteblock.lua") dofile(modpath .. "/devices/command_block.lua") diff --git a/mods/ITEMS/pyutest_electricity/wirecutter.lua b/mods/ITEMS/pyutest_electricity/wirecutter.lua index 8c26ee6..c98202d 100644 --- a/mods/ITEMS/pyutest_electricity/wirecutter.lua +++ b/mods/ITEMS/pyutest_electricity/wirecutter.lua @@ -1,4 +1,5 @@ PyuTest.WIRECUTTER_META_NAME = "WIRECUTTER_TARGET" + local function wirecutter_meta(pos) return core.serialize({ x = pos.x, diff --git a/textures/pyutest-delayer.png b/textures/pyutest-delayer.png new file mode 100644 index 0000000..ef70bb1 Binary files /dev/null and b/textures/pyutest-delayer.png differ diff --git a/textures/pyutest-note-block.png b/textures/pyutest-note-block.png new file mode 100644 index 0000000..2cd481a Binary files /dev/null and b/textures/pyutest-note-block.png differ diff --git a/textures/pyutest-note.png b/textures/pyutest-note.png new file mode 100644 index 0000000..4eb122f Binary files /dev/null and b/textures/pyutest-note.png differ