More crafing recipes and fix parachutes and compasses

This commit is contained in:
KaadmY 2017-05-16 10:47:12 -07:00
parent 063ff13475
commit 0feaa580d5
17 changed files with 548 additions and 414 deletions

View File

@ -332,7 +332,7 @@ crafting.register_craft(
{ {
output = "default:heated_dirt_path", output = "default:heated_dirt_path",
items = { items = {
"group:soil_path", "default:dirt_path",
"default:ingot_steel", "default:ingot_steel",
} }
}) })

View File

@ -1,2 +1,3 @@
achievements
default default
crafting
achievements

View File

@ -257,15 +257,15 @@ minetest.register_craftitem(
stack_max = 120 stack_max = 120
}) })
minetest.register_craft( crafting.register_craft(
{ {
output = "gold:trading_book", output = "gold:trading_book",
type = "shapeless", items = {
recipe = {"default:book", "gold:gold"} "default:book",
"gold:gold",
}
}) })
minetest.register_alias("gold", "gold:gold")
minetest.register_node( minetest.register_node(
"gold:ore", "gold:ore",
{ {

View File

@ -1,2 +1,3 @@
default default
crafting
achievements achievements

View File

@ -1,13 +1,38 @@
-- --
-- Jewels mod -- Jewels mod
-- By Kaadmy -- By Kaadmy
-- --
jewels = {} jewels = {}
-- Array of registered jeweled tools
jewels.registered_jewels = {} jewels.registered_jewels = {}
local function p(i) -- Formspec
if i >= 0 then i = "+" .. i end
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 return i
end end
@ -31,6 +56,7 @@ function jewels.register_jewel(toolname, new_toolname, def)
if not jewels.registered_jewels[toolname] then if not jewels.registered_jewels[toolname] then
jewels.registered_jewels[toolname] = {} jewels.registered_jewels[toolname] = {}
end end
table.insert(jewels.registered_jewels[toolname], data) table.insert(jewels.registered_jewels[toolname], data)
local tooldef = minetest.deserialize(minetest.serialize(minetest.registered_tools[toolname])) 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 if data.stats.range and new_tooldef.range then
new_tooldef.range = new_tooldef.range + data.stats.range 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 end
if new_tooldef.tool_capabilities then if new_tooldef.tool_capabilities then
if data.stats.maxdrop and new_tooldef.tool_capabilities.max_drop_level 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 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 end
if data.stats.digspeed then if data.stats.digspeed then
@ -83,19 +109,19 @@ function jewels.register_jewel(toolname, new_toolname, def)
end end
end end
desc = desc .. "\nDig time: " .. p(data.stats.digspeed) .. " seconds" desc = desc .. "\nDig time: " .. plus_power(data.stats.digspeed) .. " seconds"
end end
if data.stats.uses then if data.stats.uses then
desc = desc .. "\nUses: " .. p(data.stats.uses) desc = desc .. "\nUses: " .. plus_power(data.stats.uses)
end end
if data.stats.maxlevel then if data.stats.maxlevel then
desc = desc .. "\nDig level: " .. p(data.stats.maxlevel) desc = desc .. "\nDig level: " .. plus_power(data.stats.maxlevel)
end end
if data.stats.fleshy and new_tooldef.tool_capabilities.damage_groups and new_tooldef.tool_capabilities.damage_groups.fleshy then 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 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
end end
@ -128,7 +154,7 @@ minetest.register_craftitem(
description = "Jewel", description = "Jewel",
inventory_image = "jewels_jewel.png", inventory_image = "jewels_jewel.png",
stack_max = 10 stack_max = 10
}) })
minetest.register_node( minetest.register_node(
"jewels:bench", "jewels:bench",
@ -141,65 +167,51 @@ minetest.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("jewels_bench")) meta:set_string("formspec", default.ui.get_page("jewels_bench"))
meta:set_string("infotext", "Jewelers Workbench") meta:set_string("infotext", "Jewelers Workbench")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 1) inv:set_size("main", 1)
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") return inv:is_empty("main")
end, end,
on_punch = function(pos, node, player, pointed_thing) 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 if itemstack:get_name() == "jewels:jewel" then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() 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 if jewels.can_jewel(itemname) then
inv:set_stack("main", 1, ItemStack(jewels.get_jeweled(itemname))) 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, "jeweler")
achievements.trigger_achievement(player, "master_jeweler") achievements.trigger_achievement(player, "master_jeweler")
end end
end end
player:set_wielded_item(itemstack) player:set_wielded_item(itemstack)
end, end,
}) })
minetest.register_craft( crafting.register_craft(
{ {
output = "jewels:bench", output = "jewels:bench",
recipe = { items = {
{"group:planks", "jewels:jewel", "group:planks"}, "group:planks 5",
{"default:ingot_carbonsteel", "group:planks", "default:ingot_carbonsteel"}, "default:ingot_carbonsteel 2",
{"group:planks", "group:planks", "group:planks"} "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( minetest.register_node(
"jewels:jewel_ore", "jewels:jewel_ore",
@ -210,7 +222,7 @@ minetest.register_node(
drop = "jewels:jewel", drop = "jewels:jewel",
groups = {snappy=1, choppy=1, tree=1}, groups = {snappy=1, choppy=1, tree=1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
minetest.register_ore( minetest.register_ore(
{ {
@ -222,9 +234,7 @@ minetest.register_ore(
clust_size = 6, clust_size = 6,
y_min = 0, y_min = 0,
y_max = 31000, y_max = 31000,
}) })
dofile(minetest.get_modpath("jewels").."/jewels.lua")
-- Achievements -- Achievements
@ -234,7 +244,7 @@ achievements.register_achievement(
title = "Jeweler", title = "Jeweler",
description = "Jewel a tool", description = "Jewel a tool",
times = 1, times = 1,
}) })
achievements.register_achievement( achievements.register_achievement(
"master_jeweler", "master_jeweler",
@ -242,6 +252,10 @@ achievements.register_achievement(
title = "Master Jeweler", title = "Master Jeweler",
description = "Jewel 10 tools", description = "Jewel 10 tools",
times = 10, times = 10,
}) })
-- The tool jewel definitions
dofile(minetest.get_modpath("jewels").."/jewels.lua")
default.log("mod:jewels", "loaded") default.log("mod:jewels", "loaded")

View File

@ -3,6 +3,7 @@
-- --
-- Pickaxes -- Pickaxes
jewels.register_jewel( jewels.register_jewel(
"default:pick_stone", "default:pick_stone",
"jewels:pick_stone_digspeed", "jewels:pick_stone_digspeed",
@ -85,6 +86,7 @@ jewels.register_jewel(
}) })
-- Shovels -- Shovels
jewels.register_jewel( jewels.register_jewel(
"default:shovel_stone", "default:shovel_stone",
"jewels:shovel_stone_digspeed", "jewels:shovel_stone_digspeed",
@ -167,6 +169,7 @@ jewels.register_jewel(
}) })
-- Axes -- Axes
jewels.register_jewel( jewels.register_jewel(
"default:axe_stone", "default:axe_stone",
"jewels:axe_stone_digspeed", "jewels:axe_stone_digspeed",
@ -249,6 +252,7 @@ jewels.register_jewel(
}) })
-- Spears -- Spears
jewels.register_jewel( jewels.register_jewel(
"default:spear_stone", "default:spear_stone",
"jewels:spear_stone_digspeed", "jewels:spear_stone_digspeed",
@ -366,4 +370,4 @@ jewels.register_jewel(
} }
}) })
default.log("jewels", "loaded") default.log("jewels", "loaded")

View File

@ -1,2 +1,3 @@
default default
crafting
achievements achievements

View File

@ -1,3 +1,4 @@
-- --
-- Locks mod -- Locks mod
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
@ -5,9 +6,13 @@
locks = {} locks = {}
-- Settings
local picked_time = tonumber(minetest.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds 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") local all_unlocked = minetest.setting_getbool("locks_all_unlocked")
-- API functions
function locks.is_owner(meta, player) function locks.is_owner(meta, player)
local name = player:get_player_name() local name = player:get_player_name()
local owner = meta:get_string("lock_owner") local owner = meta:get_string("lock_owner")
@ -41,6 +46,8 @@ function locks.is_locked(meta, player)
return true return true
end end
-- Items and nodes
minetest.register_tool( minetest.register_tool(
"locks:pick", "locks:pick",
{ {
@ -62,7 +69,8 @@ minetest.register_tool(
if own then if own then
minetest.chat_send_player( minetest.chat_send_player(
own, 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
end end
@ -80,26 +88,6 @@ minetest.register_craftitem(
wield_image = "locks_lock.png", 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( minetest.register_node(
"locks:chest", "locks:chest",
{ {
@ -189,11 +177,33 @@ minetest.register_node(
on_blast = function() end, 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", output = "locks:chest",
type = "shapeless", items = {
recipe = {"default:chest", "locks:lock"}, "default:chest",
"locks:lock",
},
}) })
-- Achievements -- Achievements

View File

@ -1,4 +1,5 @@
achievements
default default
tnt tnt
util util
crafting
achievements

View File

@ -1,3 +1,4 @@
-- --
-- Lumien mod -- Lumien mod
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
@ -6,134 +7,20 @@
local lumien_on_radius = 2 local lumien_on_radius = 2
local lumien_off_radius = 4 local lumien_off_radius = 4
minetest.register_node( local timer_interval = 1
"lumien:crystal_on", local timer = 0
{
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}, -- Update function
light_source = 13,
drop = "lumien:crystal_off",
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node( local function on_globalstep(dtime)
"lumien:crystal_off", timer = timer + dtime
{
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}, if timer < timer_interval then
light_source = 2, return
sounds = default.node_sound_glass_defaults(), end
})
minetest.register_node( timer = 0
"lumien:block",
{
description = "Lumien Block",
tiles = {"lumien_block.png"},
groups = {cracky = 1, stone = 1},
light_source = 14,
sounds = default.node_sound_stone_defaults(),
})
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 for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos() local pos = player:getpos()
@ -150,14 +37,149 @@ local function step(dtime)
name = "lumien:crystal_on", name = "lumien:crystal_on",
param = node.param, param = node.param,
param2 = node.param2 param2 = node.param2
}) })
end, end,
true true
) )
end end
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 -- Achievements

View File

@ -1,2 +1,4 @@
achievements default
util util
crafting
achievements

View File

@ -1,3 +1,4 @@
-- --
-- Music player mod -- Music player mod
-- By Kaadmy, for Pixture -- 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.track_length = tonumber(minetest.setting_get("music_track_length")) or 30.0
music.volume = tonumber(minetest.setting_get("music_volume")) or 1.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 if minetest.setting_getbool("music_enable") then
function music.stop(pos) function music.stop(pos)
@ -169,12 +172,12 @@ else
}) })
end end
minetest.register_craft( crafting.register_craft(
{ {
output = "music:player", output = "music:player",
recipe = { items = {
{"group:planks", "group:planks", "group:planks"}, "group:planks 5",
{"group:planks", "default:ingot_steel", "group:planks"}, "default:ingot_steel",
} }
}) })

View File

@ -1,121 +1,16 @@
--
-- Compass handling -- Compass handling
--
local wield_image_0 = "nav_compass_inventory_0.png" local wield_image_0 = "nav_compass_inventory_0.png"
local wield_image_1 = "nav_compass_inventory_1.png" local wield_image_1 = "nav_compass_inventory_1.png"
minetest.register_craftitem( function on_globalstep(dtime)
"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)
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local inv = player:get_inventory() 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) local dir = math.floor(((yaw / math.pi) * 4) + 0.5)
if dir < 0 then if dir < 0 then
@ -129,7 +24,7 @@ function step(dtime)
for i = 1, 8 do for i = 1, 8 do
local itemstack = inv:get_stack("main", i) local itemstack = inv:get_stack("main", i)
local item = minetest.registered_items[itemstack:get_name()] local item = minetest.registered_items[itemstack:get_name()]
if item ~= nil then if item ~= nil then
if item.groups.nav_compass then if item.groups.nav_compass then
inv:set_stack("main", i, ItemStack("nav:compass_"..dir)) inv:set_stack("main", i, ItemStack("nav:compass_"..dir))
@ -139,7 +34,119 @@ function step(dtime)
end end
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 -- Achievements
@ -150,4 +157,6 @@ achievements.register_achievement(
description = "Craft a compass", description = "Craft a compass",
times = 1, times = 1,
craftitem = "nav:compass_2", craftitem = "nav:compass_2",
}) })
default.log("compass", "loaded")

View File

@ -7,3 +7,5 @@ nav = {}
dofile(minetest.get_modpath("nav").."/map.lua") dofile(minetest.get_modpath("nav").."/map.lua")
dofile(minetest.get_modpath("nav").."/compass.lua") dofile(minetest.get_modpath("nav").."/compass.lua")
default.log("mod:nav", "loaded")

View File

@ -1,19 +1,26 @@
--
-- Map handling -- Map handling
--
nav.map_radius = 256 nav.map_radius = 256
nav.waypoints = {} nav.waypoints = {}
local form_nav = default.ui.get_page("default:default")
default.ui.register_page("nav:nav", form_nav)
local open_formspecs = {} local open_formspecs = {}
-- Timer
local timer_interval = 0.1
local timer = 10 local timer = 10
local update_time = 0.2
function nav.add_waypoint(pos, name, label, isinfo, type) 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 end
function nav.remove_waypoint(name) 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 for name, data in pairs(nav.waypoints) do
local wp = data.pos 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) table.insert(wpts, name)
end end
end end
@ -46,8 +54,9 @@ local function get_formspec_waypoint(x, y, name, label, isinfo)
local form = "" local form = ""
form = form .. "image_button["..(x-0.72)..","..(y-0.53)..";0.5,0.5;"..img..";"..name..";;false;false;"..img.."]" form = form .. "image_button[" .. (x-0.72) .. "," .. (y-0.53) .. ";0.5,0.5;"
form = form .. "tooltip["..name..";"..minetest.formspec_escape(label).."]" .. img .. ";" .. name .. ";;false;false;" .. img .. "]"
form = form .. "tooltip[" .. name .. ";" .. minetest.formspec_escape(label) .. "]"
return form return form
end end
@ -61,11 +70,14 @@ function nav.show_map(player)
local pos = player:getpos() 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]" 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 .. "image[5.5,3;1,1;nav_map_compass.png]"
form = form .. "label[6.25,6.6;"..nav.map_radius.."m]" 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 .. "image[5.5,5.5;3,3;"
.. minetest.formspec_escape("nav_legend.png^[transformFX") .. "]"
minetest.show_formspec(name, "nav:map", form) minetest.show_formspec(name, "nav:map", form)
end 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 form_name == "nav:map" then
if fields.quit or fields.nav_map_tracker then if fields.quit or fields.nav_map_tracker then
open_formspecs[player:get_player_name()] = false open_formspecs[player:get_player_name()] = false
@ -97,59 +112,83 @@ local function recieve_fields(player, form_name, fields)
end end
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( minetest.after(
1.0, 1.0,
function() function()
nav.add_waypoint(minetest.setting_get_pos("static_spawnpoint"), nav.add_waypoint(minetest.setting_get_pos("static_spawnpoint"),
"spawn", "Spawn", true, "spawn") "spawn", "Spawn", true, "spawn")
end) end)
end end
-- Joining player
local function on_joinplayer(player) local function on_joinplayer(player)
local name = player:get_player_name() local name = player:get_player_name()
minetest.after( minetest.after(
1.0, 1.0,
function() function()
nav.add_waypoint(player:getpos(), "player_"..name, name, true, "player") nav.add_waypoint(
end) player:getpos(),
"player_" .. name,
name,
true,
"player"
)
end)
end end
-- Disconnecting player
local function on_leaveplayer(player) local function on_leaveplayer(player)
local name = player:get_player_name() local name = player:get_player_name()
nav.remove_waypoint("player_"..name) nav.remove_waypoint("player_" .. name)
end end
local function step(dtime) -- Global update function
local function on_globalstep(dtime)
timer = timer + dtime timer = timer + dtime
if timer > update_time then if timer < timer_interval then
local players = {} return
end
for _, player in pairs(minetest.get_connected_players()) do timer = 0
if player ~= nil then
local name = player:get_player_name()
players[name] = player local players = {}
nav.show_map(player) for _, player in pairs(minetest.get_connected_players()) do
end if player ~= nil then
local name = player:get_player_name()
players[name] = player
nav.show_map(player)
end end
end
for wptname, wpt in pairs(nav.waypoints) do for wptname, wpt in pairs(nav.waypoints) do
if wpt.type == "player" then if wpt.type == "player" then
if players[wpt.label] ~= nil and minetest.get_player_by_name(wpt.label) ~= nil then if players[wpt.label] ~= nil and minetest.get_player_by_name(wpt.label) ~= nil then
nav.relocate_waypoint(wptname, players[wpt.label]:getpos()) nav.relocate_waypoint(wptname, players[wpt.label]:getpos())
end end
end
end end
timer = 0
end end
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( minetest.register_craftitem(
"nav:map", "nav:map",
{ {
@ -158,27 +197,23 @@ minetest.register_craftitem(
wield_image = "nav_inventory.png", wield_image = "nav_inventory.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
open_formspecs[player:get_player_name()] = true open_formspecs[player:get_player_name()] = true
nav.show_map(player) nav.show_map(player)
end, end,
}) })
minetest.register_craft( -- Crafting
crafting.register_craft(
{ {
output = "nav:map", output = "nav:map",
recipe = { items = {
{"default:stick", "default:stick", "default:stick"}, "default:stick 6",
{"default:paper", "default:paper", "default:paper"}, "default:paper 3",
{"default:stick", "default:stick", "default:stick"},
} }
}) })
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
achievements.register_achievement( achievements.register_achievement(
@ -188,4 +223,6 @@ achievements.register_achievement(
description = "Craft a map", description = "Craft a map",
times = 1, times = 1,
craftitem = "nav:map", craftitem = "nav:map",
}) })
default.log("map", "loaded")

View File

@ -1,2 +1,3 @@
achievements
default default
crafting
achievements

View File

@ -1,13 +1,14 @@
-- --
-- Parachute mod -- Parachute mod
-- By webdesigner97(No license?) -- By webdesigner97(No license?)
-- Tweaked by Kaadmy, for Pixture -- Tweaked by Kaadmy, for Pixture
-- --
function a(v) function air_physics(v)
local m = 80 -- Weight of player, kg local m = 80 -- Weight of player, kg
local g = -9.81 -- Earth Acceleration, m/s^2 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 rho = 1.2 -- Density of air (on ground, not accurate), kg/m^3
local A = 25 -- Surface of the parachute, m^2 local A = 25 -- Surface of the parachute, m^2
@ -21,11 +22,13 @@ minetest.register_craftitem(
wield_image = "parachute_inventory.png", wield_image = "parachute_inventory.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name()
local pos = player:getpos() local pos = player:getpos()
local on = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) 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 return
end end
@ -35,17 +38,24 @@ minetest.register_craftitem(
local ent = minetest.add_entity(pos, "parachute:entity") 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}) 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 = ent:get_luaentity()
ent.attached = player ent.attached = name
default.player_attached[player:get_player_name()] = true default.player_attached[player:get_player_name()] = true
itemstack:take_item() itemstack:take_item()
return itemstack return itemstack
else else
minetest.chat_send_player( 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}) local under = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if self.attached ~= nil then if self.attached ~= nil then
local player = minetest.get_player_by_name(self.attached)
local vel = self.object:getvelocity() local vel = self.object:getvelocity()
local accel = {x = 0, y = 0, z = 0} 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) if lookyaw < 0 then
local c = math.cos((math.pi * 0.5) - lookyaw) lookyaw = lookyaw + (math.pi * 2)
end
local sr = math.sin(((math.pi * 0.5) - lookyaw) + (math.pi / 2)) if lookyaw >= (math.pi * 2) then
local cr = math.cos(((math.pi * 0.5) - lookyaw) + (math.pi / 2)) 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.x = s * speed
accel.z = c * speed accel.z = c * speed
elseif controls.down then elseif controls.up then
accel.x = s * -speed accel.x = s * -speed
accel.z = c * -speed accel.z = c * -speed
end end
@ -101,31 +122,36 @@ minetest.register_entity(
accel.z = cr * -speed accel.z = cr * -speed
end end
accel.y = accel.y + a(vel.y) * 0.25 accel.y = accel.y + air_physics(vel.y) * 0.25
self.object:setacceleration(accel) self.object:setacceleration(accel)
if under.name ~= "air" then if under.name ~= "air" then
default.player_attached[self.attached:get_player_name()] = false default.player_attached[self.attached] = false
end end
end end
if under.name ~= "air" then 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() self.object:remove()
end end
end end
}) })
minetest.register_craft( -- Crafting
crafting.register_craft(
{ {
output = "parachute:parachute", output = "parachute:parachute",
recipe = { items = {
{"group:fuzzy", "group:fuzzy", "group:fuzzy"}, "group:fuzzy 3",
{"default:rope", "", "default:rope"}, "default:rope 4",
{"", "default:stick", ""} "default:stick 6",
} }
}) })