diff --git a/mods/crafting/recipes.lua b/mods/crafting/recipes.lua index 5b58d93..47c365c 100644 --- a/mods/crafting/recipes.lua +++ b/mods/crafting/recipes.lua @@ -332,7 +332,7 @@ crafting.register_craft( { output = "default:heated_dirt_path", items = { - "group:soil_path", + "default:dirt_path", "default:ingot_steel", } }) diff --git a/mods/gold/depends.txt b/mods/gold/depends.txt index eac6c48..39f77f5 100644 --- a/mods/gold/depends.txt +++ b/mods/gold/depends.txt @@ -1,2 +1,3 @@ -achievements default +crafting +achievements diff --git a/mods/gold/init.lua b/mods/gold/init.lua index f8ff1bc..18f7e6f 100644 --- a/mods/gold/init.lua +++ b/mods/gold/init.lua @@ -257,15 +257,15 @@ minetest.register_craftitem( stack_max = 120 }) -minetest.register_craft( +crafting.register_craft( { output = "gold:trading_book", - type = "shapeless", - recipe = {"default:book", "gold:gold"} + items = { + "default:book", + "gold:gold", + } }) -minetest.register_alias("gold", "gold:gold") - minetest.register_node( "gold:ore", { diff --git a/mods/jewels/depends.txt b/mods/jewels/depends.txt index 6c67e01..39f77f5 100644 --- a/mods/jewels/depends.txt +++ b/mods/jewels/depends.txt @@ -1,2 +1,3 @@ default +crafting achievements diff --git a/mods/jewels/init.lua b/mods/jewels/init.lua index 22da4b9..4c27de9 100644 --- a/mods/jewels/init.lua +++ b/mods/jewels/init.lua @@ -1,13 +1,38 @@ + -- -- Jewels mod -- By Kaadmy -- jewels = {} + +-- Array of registered jeweled tools + jewels.registered_jewels = {} -local function p(i) - if i >= 0 then i = "+" .. i end +-- Formspec + +local form_bench = default.ui.get_page("default:2part") + +form_bench = form_bench .. "list[current_name;main;2.25,1.75;1,1;]" +form_bench = form_bench .. "listring[current_name;main]" +form_bench = form_bench .. default.ui.get_itemslot_bg(2.25, 1.75, 1, 1) + +form_bench = form_bench .. "label[3.25,1.75;1. Place unjeweled tool here]" +form_bench = form_bench .. "label[3.25,2.25;2. Hold a jewel and punch the bench]" + +form_bench = form_bench .. "list[current_player;main;0.25,4.75;8,4;]" +form_bench = form_bench .. "listring[current_player;main]" +form_bench = form_bench .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) +form_bench = form_bench .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) + +default.ui.register_page("jewels_bench", form_bench) + +local function plus_power(i) + if i >= 0 then + i = "+" .. i + end + return i end @@ -31,6 +56,7 @@ function jewels.register_jewel(toolname, new_toolname, def) if not jewels.registered_jewels[toolname] then jewels.registered_jewels[toolname] = {} end + table.insert(jewels.registered_jewels[toolname], data) local tooldef = minetest.deserialize(minetest.serialize(minetest.registered_tools[toolname])) @@ -59,13 +85,13 @@ function jewels.register_jewel(toolname, new_toolname, def) if data.stats.range and new_tooldef.range then new_tooldef.range = new_tooldef.range + data.stats.range - desc = desc .. "\nRange: " .. p(data.stats.range) + desc = desc .. "\nRange: " .. plus_power(data.stats.range) end if new_tooldef.tool_capabilities then if data.stats.maxdrop and new_tooldef.tool_capabilities.max_drop_level then new_tooldef.tool_capabilities.max_drop_level = new_tooldef.tool_capabilities.max_drop_level + data.stats.maxdrop - desc = desc .. "\nDrop level: " .. p(data.stats.maxdrop) + desc = desc .. "\nDrop level: " .. plus_power(data.stats.maxdrop) end if data.stats.digspeed then @@ -83,19 +109,19 @@ function jewels.register_jewel(toolname, new_toolname, def) end end - desc = desc .. "\nDig time: " .. p(data.stats.digspeed) .. " seconds" + desc = desc .. "\nDig time: " .. plus_power(data.stats.digspeed) .. " seconds" end if data.stats.uses then - desc = desc .. "\nUses: " .. p(data.stats.uses) + desc = desc .. "\nUses: " .. plus_power(data.stats.uses) end if data.stats.maxlevel then - desc = desc .. "\nDig level: " .. p(data.stats.maxlevel) + desc = desc .. "\nDig level: " .. plus_power(data.stats.maxlevel) end if data.stats.fleshy and new_tooldef.tool_capabilities.damage_groups and new_tooldef.tool_capabilities.damage_groups.fleshy then new_tooldef.tool_capabilities.damage_groups.fleshy = new_tooldef.tool_capabilities.damage_groups.fleshy + data.stats.fleshy - desc = desc .. "\nDamage: " .. p(data.stats.fleshy) + desc = desc .. "\nDamage: " .. plus_power(data.stats.fleshy) end end @@ -128,7 +154,7 @@ minetest.register_craftitem( description = "Jewel", inventory_image = "jewels_jewel.png", stack_max = 10 - }) +}) minetest.register_node( "jewels:bench", @@ -141,65 +167,51 @@ minetest.register_node( is_ground_content = false, sounds = default.node_sound_wood_defaults(), on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", default.ui.get_page("jewels_bench")) - meta:set_string("infotext", "Jewelers Workbench") + local meta = minetest.get_meta(pos) + meta:set_string("formspec", default.ui.get_page("jewels_bench")) + meta:set_string("infotext", "Jewelers Workbench") - local inv = meta:get_inventory() - inv:set_size("main", 1) - end, + local inv = meta:get_inventory() + inv:set_size("main", 1) + end, can_dig = function(pos, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() - return inv:is_empty("main") - end, + return inv:is_empty("main") + end, on_punch = function(pos, node, player, pointed_thing) - local itemstack = player:get_wielded_item() + local itemstack = player:get_wielded_item() - if itemstack:get_name() == "jewels:jewel" then - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() + if itemstack:get_name() == "jewels:jewel" then + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() - local itemname = inv:get_stack("main", 1):get_name() + local itemname = inv:get_stack("main", 1):get_name() - if jewels.can_jewel(itemname) then - inv:set_stack("main", 1, ItemStack(jewels.get_jeweled(itemname))) + if jewels.can_jewel(itemname) then + inv:set_stack("main", 1, ItemStack(jewels.get_jeweled(itemname))) - itemstack:take_item() + itemstack:take_item() - achievements.trigger_achievement(player, "jeweler") - achievements.trigger_achievement(player, "master_jeweler") - end - end + achievements.trigger_achievement(player, "jeweler") + achievements.trigger_achievement(player, "master_jeweler") + end + end - player:set_wielded_item(itemstack) - end, - }) + player:set_wielded_item(itemstack) + end, +}) -minetest.register_craft( +crafting.register_craft( { output = "jewels:bench", - recipe = { - {"group:planks", "jewels:jewel", "group:planks"}, - {"default:ingot_carbonsteel", "group:planks", "default:ingot_carbonsteel"}, - {"group:planks", "group:planks", "group:planks"} + items = { + "group:planks 5", + "default:ingot_carbonsteel 2", + "jewels:jewel", } - }) - -local form_bench = default.ui.get_page("default:2part") -form_bench = form_bench .. "list[current_name;main;2.25,1.75;1,1;]" -form_bench = form_bench .. "listring[current_name;main]" -form_bench = form_bench .. default.ui.get_itemslot_bg(2.25, 1.75, 1, 1) - -form_bench = form_bench .. "label[3.25,1.75;1. Place unjeweled tool here]" -form_bench = form_bench .. "label[3.25,2.25;2. Hold a jewel and punch the bench]" - -form_bench = form_bench .. "list[current_player;main;0.25,4.75;8,4;]" -form_bench = form_bench .. "listring[current_player;main]" -form_bench = form_bench .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) -form_bench = form_bench .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) -default.ui.register_page("jewels_bench", form_bench) +}) minetest.register_node( "jewels:jewel_ore", @@ -210,7 +222,7 @@ minetest.register_node( drop = "jewels:jewel", groups = {snappy=1, choppy=1, tree=1}, sounds = default.node_sound_wood_defaults(), - }) +}) minetest.register_ore( { @@ -222,9 +234,7 @@ minetest.register_ore( clust_size = 6, y_min = 0, y_max = 31000, - }) - -dofile(minetest.get_modpath("jewels").."/jewels.lua") +}) -- Achievements @@ -234,7 +244,7 @@ achievements.register_achievement( title = "Jeweler", description = "Jewel a tool", times = 1, - }) +}) achievements.register_achievement( "master_jeweler", @@ -242,6 +252,10 @@ achievements.register_achievement( title = "Master Jeweler", description = "Jewel 10 tools", times = 10, - }) +}) + +-- The tool jewel definitions + +dofile(minetest.get_modpath("jewels").."/jewels.lua") default.log("mod:jewels", "loaded") diff --git a/mods/jewels/jewels.lua b/mods/jewels/jewels.lua index edc5f0e..6b9ca73 100644 --- a/mods/jewels/jewels.lua +++ b/mods/jewels/jewels.lua @@ -3,6 +3,7 @@ -- -- Pickaxes + jewels.register_jewel( "default:pick_stone", "jewels:pick_stone_digspeed", @@ -85,6 +86,7 @@ jewels.register_jewel( }) -- Shovels + jewels.register_jewel( "default:shovel_stone", "jewels:shovel_stone_digspeed", @@ -167,6 +169,7 @@ jewels.register_jewel( }) -- Axes + jewels.register_jewel( "default:axe_stone", "jewels:axe_stone_digspeed", @@ -249,6 +252,7 @@ jewels.register_jewel( }) -- Spears + jewels.register_jewel( "default:spear_stone", "jewels:spear_stone_digspeed", @@ -366,4 +370,4 @@ jewels.register_jewel( } }) -default.log("jewels", "loaded") \ No newline at end of file +default.log("jewels", "loaded") diff --git a/mods/locks/depends.txt b/mods/locks/depends.txt index 6c67e01..39f77f5 100644 --- a/mods/locks/depends.txt +++ b/mods/locks/depends.txt @@ -1,2 +1,3 @@ default +crafting achievements diff --git a/mods/locks/init.lua b/mods/locks/init.lua index 2cc2675..9e22de0 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -1,3 +1,4 @@ + -- -- Locks mod -- By Kaadmy, for Pixture @@ -5,9 +6,13 @@ locks = {} +-- Settings + local picked_time = tonumber(minetest.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds local all_unlocked = minetest.setting_getbool("locks_all_unlocked") +-- API functions + function locks.is_owner(meta, player) local name = player:get_player_name() local owner = meta:get_string("lock_owner") @@ -41,6 +46,8 @@ function locks.is_locked(meta, player) return true end +-- Items and nodes + minetest.register_tool( "locks:pick", { @@ -62,7 +69,8 @@ minetest.register_tool( if own then minetest.chat_send_player( own, - minetest.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!")) + minetest.colorize("#f00", player:get_player_name() + .. " has broken into your locked chest!")) end end @@ -80,26 +88,6 @@ minetest.register_craftitem( wield_image = "locks_lock.png", }) -minetest.register_craft( - { - output = "locks:pick", - recipe = { - {"", "", "default:ingot_steel"}, - {"", "default:stick", ""}, - {"default:stick", "", ""}, - }, -}) - -minetest.register_craft( - { - output = "locks:lock", - recipe = { - {"", "default:ingot_steel", ""}, - {"default:ingot_steel", "", "default:ingot_steel"}, - {"group:planks", "group:planks", "group:planks"}, - }, -}) - minetest.register_node( "locks:chest", { @@ -189,11 +177,33 @@ minetest.register_node( on_blast = function() end, }) -minetest.register_craft( +-- Crafting + +crafting.register_craft( + { + output = "locks:pick", + items = { + "default:ingot_carbonsteel 2", + "default:stick 3", + }, +}) + +crafting.register_craft( + { + output = "locks:lock", + items = { + "default:ingot_steel 3", + "group:planks 2", + }, +}) + +crafting.register_craft( { output = "locks:chest", - type = "shapeless", - recipe = {"default:chest", "locks:lock"}, + items = { + "default:chest", + "locks:lock", + }, }) -- Achievements diff --git a/mods/lumien/depends.txt b/mods/lumien/depends.txt index 2faa29e..ce962e4 100644 --- a/mods/lumien/depends.txt +++ b/mods/lumien/depends.txt @@ -1,4 +1,5 @@ -achievements default tnt util +crafting +achievements diff --git a/mods/lumien/init.lua b/mods/lumien/init.lua index b0cba36..b45e552 100644 --- a/mods/lumien/init.lua +++ b/mods/lumien/init.lua @@ -1,3 +1,4 @@ + -- -- Lumien mod -- By Kaadmy, for Pixture @@ -6,134 +7,20 @@ local lumien_on_radius = 2 local lumien_off_radius = 4 -minetest.register_node( - "lumien:crystal_on", - { - description = "Lumien Crystal", - inventory_image = "lumien_crystal.png", - tiles = {"lumien_block.png"}, - paramtype = "light", - paramtype2 = "wallmounted", - drawtype = "nodebox", - node_box = { - type = "wallmounted", - wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16}, - wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16}, - wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16} - }, +local timer_interval = 1 +local timer = 0 - groups = {crumbly = 3}, - light_source = 13, - drop = "lumien:crystal_off", - sounds = default.node_sound_glass_defaults(), - }) +-- Update function -minetest.register_node( - "lumien:crystal_off", - { - description = "Lumien Crystal", - inventory_image = "lumien_crystal.png", - tiles = {"lumien_block.png"}, - paramtype = "light", - paramtype2 = "wallmounted", - drawtype = "nodebox", - node_box = { - type = "wallmounted", - wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16}, - wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16}, - wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16} - }, +local function on_globalstep(dtime) + timer = timer + dtime - groups = {crumbly = 3}, - light_source = 2, - sounds = default.node_sound_glass_defaults(), - }) + if timer < timer_interval then + return + end -minetest.register_node( - "lumien:block", - { - description = "Lumien Block", - tiles = {"lumien_block.png"}, - groups = {cracky = 1, stone = 1}, - light_source = 14, - sounds = default.node_sound_stone_defaults(), - }) + timer = 0 -minetest.register_node( - "lumien:ore", - { - description = "Lumien Ore", - tiles = {"default_stone.png^lumien_mineral.png"}, - groups = {cracky = 1, stone = 1}, - drop = "lumien:block", - sounds = default.node_sound_stone_defaults(), - }) - -minetest.register_craft( - { - output = "lumien:crystal_off 9", - recipe = {"lumien:block"}, - type = "shapeless", - }) - -minetest.register_craft( - { - output = "lumien:block", - recipe = { - {"lumien:crystal_off", "lumien:crystal_off", "lumien:crystal_off"}, - {"lumien:crystal_off", "lumien:crystal_off", "lumien:crystal_off"}, - {"lumien:crystal_off", "lumien:crystal_off", "lumien:crystal_off"} - }, - }) - -minetest.register_ore( - { - ore_type = "scatter", - ore = "lumien:ore", - wherein = "default:stone", - clust_scarcity = 12*12*12, - clust_num_ores = 10, - clust_size = 10, - y_min = -256, - y_max = -64, - }) - -minetest.register_abm( - { - nodenames = {"lumien:crystal_on"}, - interval = 1, - chance = 1, - action = function(pos, node) - util.nodefunc( - {x = pos.x-1, y = pos.y-1, z = pos.z-1}, - {x = pos.x+1, y = pos.y+1, z = pos.z+1}, - "tnt:tnt", - function(pos) - tnt.burn(pos) - end, - true - ) - - local ok = true - for _,object in ipairs(minetest.get_objects_inside_radius(pos, lumien_off_radius)) do - if object:is_player() then - ok = false - end - end - - if ok then - minetest.set_node( - pos, - { - name = "lumien:crystal_off", - param = node.param, - param2 = node.param2 - }) - end - end, - }) - -local function step(dtime) for _, player in ipairs(minetest.get_connected_players()) do local pos = player:getpos() @@ -150,14 +37,149 @@ local function step(dtime) name = "lumien:crystal_on", param = node.param, param2 = node.param2 - }) + }) end, true ) end end -minetest.register_globalstep(step) +minetest.register_globalstep(on_globalstep) + +-- Nodes + +minetest.register_node( + "lumien:crystal_on", + { + description = "Lumien Crystal", + inventory_image = "lumien_crystal.png", + tiles = {"lumien_block.png"}, + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16}, + wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16}, + wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16} + }, + + groups = {crumbly = 3}, + light_source = 12, + drop = "lumien:crystal_off", + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node( + "lumien:crystal_off", + { + description = "Lumien Crystal", + inventory_image = "lumien_crystal.png", + tiles = {"lumien_block.png"}, + paramtype = "light", + paramtype2 = "wallmounted", + drawtype = "nodebox", + node_box = { + type = "wallmounted", + wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16}, + wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16}, + wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16} + }, + + groups = {crumbly = 3}, + light_source = 2, + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node( + "lumien:block", + { + description = "Lumien Block", + tiles = {"lumien_block.png"}, + groups = {cracky = 1}, + light_source = 14, + sounds = default.node_sound_stone_defaults(), +}) + +-- Ores + +minetest.register_node( + "lumien:ore", + { + description = "Lumien Ore", + tiles = {"default_stone.png^lumien_mineral.png"}, + groups = {cracky = 1, stone = 1}, + drop = "lumien:block", + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_ore( + { + ore_type = "scatter", + ore = "lumien:ore", + wherein = "default:stone", + clust_scarcity = 12*12*12, + clust_num_ores = 10, + clust_size = 10, + y_min = -256, + y_max = -64, +}) + +-- Update functions + +minetest.register_abm( + { + nodenames = {"lumien:crystal_on"}, + interval = timer_interval, + chance = 1, + action = function(pos, node) + util.nodefunc( + {x = pos.x-1, y = pos.y-1, z = pos.z-1}, + {x = pos.x+1, y = pos.y+1, z = pos.z+1}, + "tnt:tnt", + function(pos) + tnt.burn(pos) + end, + true + ) + + local ok = true + + for _,object in ipairs(minetest.get_objects_inside_radius(pos, lumien_off_radius)) do + if object:is_player() then + ok = false + end + end + + if ok then + minetest.set_node( + pos, + { + name = "lumien:crystal_off", + param = node.param, + param2 = node.param2 + }) + end + end, +}) + +-- Crafting + +crafting.register_craft( + { + output = "lumien:crystal_off 9", + items = { + "lumien:block" + }, +}) + +crafting.register_craft( + { + output = "lumien:block", + items = { + "lumien:crystal_off 9", + }, +}) -- Achievements diff --git a/mods/music/depends.txt b/mods/music/depends.txt index 47a7944..c4415ef 100644 --- a/mods/music/depends.txt +++ b/mods/music/depends.txt @@ -1,2 +1,4 @@ -achievements +default util +crafting +achievements diff --git a/mods/music/init.lua b/mods/music/init.lua index de15787..4d7defe 100644 --- a/mods/music/init.lua +++ b/mods/music/init.lua @@ -1,3 +1,4 @@ + -- -- Music player mod -- By Kaadmy, for Pixture @@ -9,7 +10,9 @@ music.default_track = minetest.setting_get("music_track") or "music_catsong" music.track_length = tonumber(minetest.setting_get("music_track_length")) or 30.0 music.volume = tonumber(minetest.setting_get("music_volume")) or 1.0 -music.players = {} -- music players +-- Array of music players + +music.players = {} if minetest.setting_getbool("music_enable") then function music.stop(pos) @@ -169,12 +172,12 @@ else }) end -minetest.register_craft( +crafting.register_craft( { output = "music:player", - recipe = { - {"group:planks", "group:planks", "group:planks"}, - {"group:planks", "default:ingot_steel", "group:planks"}, + items = { + "group:planks 5", + "default:ingot_steel", } }) diff --git a/mods/nav/compass.lua b/mods/nav/compass.lua index 73138e0..369fa13 100644 --- a/mods/nav/compass.lua +++ b/mods/nav/compass.lua @@ -1,121 +1,16 @@ + +-- -- Compass handling +-- local wield_image_0 = "nav_compass_inventory_0.png" local wield_image_1 = "nav_compass_inventory_1.png" -minetest.register_craftitem( - "nav:compass_0", - { - description = "Compass(E)", - - inventory_image = "nav_compass_inventory_0.png^[transformR90", - wield_image = wield_image_0 .. "^[transformR90", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_1", - { - description = "Compass(NE)", - - inventory_image = "nav_compass_inventory_1.png^[transformR90", - wield_image = wield_image_1 .. "^[transformR90", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_2", - { - description = "Compass(N)", - - inventory_image = "nav_compass_inventory_0.png", - wield_image = wield_image_0, - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_3", - { - description = "Compass(NW)", - - inventory_image = "nav_compass_inventory_1.png", - wield_image = wield_image_1, - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_4", - { - description = "Compass(W)", - - inventory_image = "nav_compass_inventory_0.png^[transformR270", - wield_image = wield_image_0 .. "^[transformR270", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_5", - { - description = "Compass(SW)", - - inventory_image = "nav_compass_inventory_1.png^[transformR270", - wield_image = wield_image_1 .. "^[transformR270", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_6", - { - description = "Compass(S)", - - inventory_image = "nav_compass_inventory_0.png^[transformR180", - wield_image = wield_image_0 .. "^[transformR180", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_craftitem( - "nav:compass_7", - { - description = "Compass(SE)", - - inventory_image = "nav_compass_inventory_1.png^[transformR180", - wield_image = wield_image_1 .. "^[transformR180", - - groups = {nav_compass = 1}, - stack_max = 1, - }) - -minetest.register_alias("nav:compass", "nav:compass_2") - -minetest.register_craft( - { - output = "nav:compass_2", - recipe = { - {"", "default:ingot_carbonsteel", ""}, - {"default:ingot_steel", "default:stick", "default:ingot_steel"}, - {"", "default:ingot_steel", ""}, - } - }) - -function step(dtime) +function on_globalstep(dtime) for _, player in pairs(minetest.get_connected_players()) do local inv = player:get_inventory() - local yaw = player:get_look_yaw() + local yaw = player:get_look_horizontal() local dir = math.floor(((yaw / math.pi) * 4) + 0.5) if dir < 0 then @@ -129,7 +24,7 @@ function step(dtime) for i = 1, 8 do local itemstack = inv:get_stack("main", i) local item = minetest.registered_items[itemstack:get_name()] - + if item ~= nil then if item.groups.nav_compass then inv:set_stack("main", i, ItemStack("nav:compass_"..dir)) @@ -139,7 +34,119 @@ function step(dtime) end end -minetest.register_globalstep(step) +minetest.register_globalstep(on_globalstep) + +-- Items + +minetest.register_craftitem( + "nav:compass_0", + { + description = "Compass(N)", + + inventory_image = "nav_compass_inventory_0.png", + wield_image = wield_image_0, + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_1", + { + description = "Compass(NE)", + + inventory_image = "nav_compass_inventory_1.png", + wield_image = wield_image_1, + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_2", + { + description = "Compass(E)", + + inventory_image = "nav_compass_inventory_0.png^[transformR270", + wield_image = wield_image_0 .. "^[transformR270", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_3", + { + description = "Compass(SE)", + + inventory_image = "nav_compass_inventory_1.png^[transformR270", + wield_image = wield_image_1 .. "^[transformR270", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + + +minetest.register_craftitem( + "nav:compass_4", + { + description = "Compass(S)", + + inventory_image = "nav_compass_inventory_0.png^[transformR180", + wield_image = wield_image_0 .. "^[transformR180", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_5", + { + description = "Compass(SW)", + + inventory_image = "nav_compass_inventory_1.png^[transformR180", + wield_image = wield_image_1 .. "^[transformR180", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_6", + { + description = "Compass(W)", + + inventory_image = "nav_compass_inventory_0.png^[transformR90", + wield_image = wield_image_0 .. "^[transformR90", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_craftitem( + "nav:compass_7", + { + description = "Compass(NW)", + + inventory_image = "nav_compass_inventory_1.png^[transformR90", + wield_image = wield_image_1 .. "^[transformR90", + + groups = {nav_compass = 1}, + stack_max = 1, +}) + +minetest.register_alias("nav:compass", "nav:compass_2") + +-- Crafting + +crafting.register_craft( + { + output = "nav:compass_2", + items = { + "default:ingot_steel 4", + "default:stick", + } +}) -- Achievements @@ -150,4 +157,6 @@ achievements.register_achievement( description = "Craft a compass", times = 1, craftitem = "nav:compass_2", - }) \ No newline at end of file +}) + +default.log("compass", "loaded") diff --git a/mods/nav/init.lua b/mods/nav/init.lua index 2952a3c..dc02211 100644 --- a/mods/nav/init.lua +++ b/mods/nav/init.lua @@ -7,3 +7,5 @@ nav = {} dofile(minetest.get_modpath("nav").."/map.lua") dofile(minetest.get_modpath("nav").."/compass.lua") + +default.log("mod:nav", "loaded") diff --git a/mods/nav/map.lua b/mods/nav/map.lua index 9b2ea0f..5dda5d5 100644 --- a/mods/nav/map.lua +++ b/mods/nav/map.lua @@ -1,19 +1,26 @@ + +-- -- Map handling +-- nav.map_radius = 256 nav.waypoints = {} -local form_nav = default.ui.get_page("default:default") -default.ui.register_page("nav:nav", form_nav) - local open_formspecs = {} +-- Timer + +local timer_interval = 0.1 local timer = 10 -local update_time = 0.2 function nav.add_waypoint(pos, name, label, isinfo, type) - nav.waypoints[name] = {pos = pos, label = label, isinfo = isinfo or false, type = type} + nav.waypoints[name] = { + pos = pos, + label = label, + isinfo = isinfo or false, + type = type + } end function nav.remove_waypoint(name) @@ -30,7 +37,8 @@ function nav.get_waypoints_in_square(pos, radius) for name, data in pairs(nav.waypoints) do local wp = data.pos - if wp.x > pos.x-radius and wp.x < pos.x+radius and wp.z > pos.z-radius and wp.z < pos.z+radius then + if wp.x > pos.x-radius and wp.x < pos.x+radius + and wp.z > pos.z-radius and wp.z < pos.z+radius then table.insert(wpts, name) end end @@ -46,8 +54,9 @@ local function get_formspec_waypoint(x, y, name, label, isinfo) local form = "" - form = form .. "image_button["..(x-0.72)..","..(y-0.53)..";0.5,0.5;"..img..";"..name..";;false;false;"..img.."]" - form = form .. "tooltip["..name..";"..minetest.formspec_escape(label).."]" + form = form .. "image_button[" .. (x-0.72) .. "," .. (y-0.53) .. ";0.5,0.5;" + .. img .. ";" .. name .. ";;false;false;" .. img .. "]" + form = form .. "tooltip[" .. name .. ";" .. minetest.formspec_escape(label) .. "]" return form end @@ -61,11 +70,14 @@ function nav.show_map(player) local pos = player:getpos() - local form = default.ui.get_page("nav:nav") + local form = default.ui.get_page("default:default") - form = form .. "field[-1,-1;0,0;nav_map_tracker;;]" + form = form .. "field[-1,-1;0,0;nav_map_tracker;;]" - form = form .. "label[0.25,0.25;"..minetest.formspec_escape(name).." (x: "..math.floor(pos.x+0.5)..", y: "..math.floor(pos.y)..", z: "..math.floor(pos.z+0.5)..")]" + form = form .. "label[0.25,0.25;" .. minetest.formspec_escape(name) + .. " (x: " .. math.floor(pos.x+0.5) + .. ", y: " .. math.floor(pos.y) + .. ", z: " .. math.floor(pos.z+0.5) .. ")]" form = form .. "image[0.5,3;6,6;nav_background.png]" @@ -83,13 +95,16 @@ function nav.show_map(player) form = form .. "image[5.5,3;1,1;nav_map_compass.png]" - form = form .. "label[6.25,6.6;"..nav.map_radius.."m]" - form = form .. "image[5.5,5.5;3,3;"..minetest.formspec_escape("nav_legend.png^[transformFX").."]" + form = form .. "label[6.25,6.6;" .. nav.map_radius .. "m]" + form = form .. "image[5.5,5.5;3,3;" + .. minetest.formspec_escape("nav_legend.png^[transformFX") .. "]" minetest.show_formspec(name, "nav:map", form) end -local function recieve_fields(player, form_name, fields) +-- Formspec interaction + +local function on_player_recieve_fields(player, form_name, fields) if form_name == "nav:map" then if fields.quit or fields.nav_map_tracker then open_formspecs[player:get_player_name()] = false @@ -97,59 +112,83 @@ local function recieve_fields(player, form_name, fields) end end -if minetest.setting_get_pos("static_spawnpoint") and (not minetest.is_singleplayer()) then +if minetest.setting_get_pos("static_spawnpoint") +and (not minetest.is_singleplayer()) then minetest.after( 1.0, function() nav.add_waypoint(minetest.setting_get_pos("static_spawnpoint"), "spawn", "Spawn", true, "spawn") - end) + end) end +-- Joining player + local function on_joinplayer(player) local name = player:get_player_name() minetest.after( 1.0, function() - nav.add_waypoint(player:getpos(), "player_"..name, name, true, "player") - end) + nav.add_waypoint( + player:getpos(), + "player_" .. name, + name, + true, + "player" + ) + end) end +-- Disconnecting player + local function on_leaveplayer(player) local name = player:get_player_name() - nav.remove_waypoint("player_"..name) + nav.remove_waypoint("player_" .. name) end -local function step(dtime) +-- Global update function + +local function on_globalstep(dtime) timer = timer + dtime - if timer > update_time then - local players = {} + if timer < timer_interval then + return + end - for _, player in pairs(minetest.get_connected_players()) do - if player ~= nil then - local name = player:get_player_name() + timer = 0 - players[name] = player + local players = {} - nav.show_map(player) - end + for _, player in pairs(minetest.get_connected_players()) do + if player ~= nil then + local name = player:get_player_name() + + players[name] = player + + nav.show_map(player) end + end - for wptname, wpt in pairs(nav.waypoints) do - if wpt.type == "player" then - if players[wpt.label] ~= nil and minetest.get_player_by_name(wpt.label) ~= nil then - nav.relocate_waypoint(wptname, players[wpt.label]:getpos()) - end - end + for wptname, wpt in pairs(nav.waypoints) do + if wpt.type == "player" then + if players[wpt.label] ~= nil and minetest.get_player_by_name(wpt.label) ~= nil then + nav.relocate_waypoint(wptname, players[wpt.label]:getpos()) + end end - - timer = 0 end end +minetest.register_on_joinplayer(on_joinplayer) +minetest.register_on_leaveplayer(on_leaveplayer) + +minetest.register_on_player_receive_fields(on_player_recieve_fields) + +minetest.register_globalstep(on_globalstep) + +-- Items + minetest.register_craftitem( "nav:map", { @@ -158,27 +197,23 @@ minetest.register_craftitem( wield_image = "nav_inventory.png", stack_max = 1, on_use = function(itemstack, player, pointed_thing) - open_formspecs[player:get_player_name()] = true - nav.show_map(player) - end, - }) + open_formspecs[player:get_player_name()] = true + nav.show_map(player) + end, +}) -minetest.register_craft( +-- Crafting + +crafting.register_craft( { output = "nav:map", - recipe = { - {"default:stick", "default:stick", "default:stick"}, - {"default:paper", "default:paper", "default:paper"}, - {"default:stick", "default:stick", "default:stick"}, + items = { + "default:stick 6", + "default:paper 3", } - }) +}) -minetest.register_on_joinplayer(on_joinplayer) -minetest.register_on_leaveplayer(on_leaveplayer) -minetest.register_globalstep(step) -minetest.register_on_player_receive_fields(recieve_fields) - -- Achievements achievements.register_achievement( @@ -188,4 +223,6 @@ achievements.register_achievement( description = "Craft a map", times = 1, craftitem = "nav:map", - }) +}) + +default.log("map", "loaded") diff --git a/mods/parachute/depends.txt b/mods/parachute/depends.txt index eac6c48..39f77f5 100644 --- a/mods/parachute/depends.txt +++ b/mods/parachute/depends.txt @@ -1,2 +1,3 @@ -achievements default +crafting +achievements diff --git a/mods/parachute/init.lua b/mods/parachute/init.lua index faeead7..5f16eb4 100644 --- a/mods/parachute/init.lua +++ b/mods/parachute/init.lua @@ -1,13 +1,14 @@ + -- -- Parachute mod -- By webdesigner97(No license?) -- Tweaked by Kaadmy, for Pixture -- -function a(v) +function air_physics(v) local m = 80 -- Weight of player, kg local g = -9.81 -- Earth Acceleration, m/s^2 - local cw = 1.33 -- Drag coefficient + local cw = 1.25 -- Drag coefficient local rho = 1.2 -- Density of air (on ground, not accurate), kg/m^3 local A = 25 -- Surface of the parachute, m^2 @@ -21,11 +22,13 @@ minetest.register_craftitem( wield_image = "parachute_inventory.png", stack_max = 1, on_use = function(itemstack, player, pointed_thing) + local name = player:get_player_name() + local pos = player:getpos() local on = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) - if default.player_attached[player:get_player_name()] then + if default.player_attached[name] then return end @@ -35,17 +38,24 @@ minetest.register_craftitem( local ent = minetest.add_entity(pos, "parachute:entity") - ent:setvelocity({x = 0, y = player:get_player_velocity().y, z = 0}) + ent:setvelocity( + { + x = 0, + y = math.min(0, player:get_player_velocity().y), + z = 0 + }) player:set_attach(ent, "", {x = 0, y = -8, z = 0}, {x = 0, y = 0, z = 0}) - ent:setyaw(player:get_look_yaw() - (math.pi / 2)) + ent:setyaw(player:get_look_horizontal()) + ent = ent:get_luaentity() - ent.attached = player + ent.attached = name default.player_attached[player:get_player_name()] = true itemstack:take_item() + return itemstack else minetest.chat_send_player( @@ -69,26 +79,37 @@ minetest.register_entity( local under = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) if self.attached ~= nil then + local player = minetest.get_player_by_name(self.attached) + local vel = self.object:getvelocity() local accel = {x = 0, y = 0, z = 0} - local lookyaw = self.attached:get_look_yaw() + local lookyaw = math.pi - player:get_look_horizontal() - local s = math.sin((math.pi * 0.5) - lookyaw) - local c = math.cos((math.pi * 0.5) - lookyaw) + if lookyaw < 0 then + lookyaw = lookyaw + (math.pi * 2) + end - local sr = math.sin(((math.pi * 0.5) - lookyaw) + (math.pi / 2)) - local cr = math.cos(((math.pi * 0.5) - lookyaw) + (math.pi / 2)) + if lookyaw >= (math.pi * 2) then + lookyaw = lookyaw - (math.pi * 2) + end +-- self.object:setyaw(lookyaw) - local controls = self.attached:get_player_control() + local s = math.sin(lookyaw) + local c = math.cos(lookyaw) - local speed = 3.0 + local sr = math.sin(lookyaw - (math.pi / 2)) + local cr = math.cos(lookyaw - (math.pi / 2)) - if controls.up then + local controls = player:get_player_control() + + local speed = 4.0 + + if controls.down then accel.x = s * speed accel.z = c * speed - elseif controls.down then + elseif controls.up then accel.x = s * -speed accel.z = c * -speed end @@ -101,31 +122,36 @@ minetest.register_entity( accel.z = cr * -speed end - accel.y = accel.y + a(vel.y) * 0.25 + accel.y = accel.y + air_physics(vel.y) * 0.25 self.object:setacceleration(accel) if under.name ~= "air" then - default.player_attached[self.attached:get_player_name()] = false + default.player_attached[self.attached] = false end end if under.name ~= "air" then - default.player_attached[self.attached:get_player_name()] = false + if self.attached ~= nil then + default.player_attached[self.attached] = false + + self.object:set_detach() + end - self.object:set_detach() self.object:remove() end end }) -minetest.register_craft( +-- Crafting + +crafting.register_craft( { output = "parachute:parachute", - recipe = { - {"group:fuzzy", "group:fuzzy", "group:fuzzy"}, - {"default:rope", "", "default:rope"}, - {"", "default:stick", ""} + items = { + "group:fuzzy 3", + "default:rope 4", + "default:stick 6", } })