Update minetest_game mods

This commit is contained in:
rubenwardy 2015-07-13 12:40:26 +01:00
parent 3f888b51c5
commit 745c77cc55
334 changed files with 3213 additions and 20238 deletions

18
mods/beds/Changelog.txt Normal file
View File

@ -0,0 +1,18 @@
1.0.1 beta
----------
- Add backwards compatibility with PilzAdam's beds mod
- Fix placement
- Fix small bugs
- Prevent possible crash
1.1
---
- Add fancy bed model (based on jp's model)
- Add API to register beds
- Allow players always to detach from bed (by donat-b)
- If more than 50% of players want sleep they can skip the night
- Don't show sleep dialog in singleplayer
1.1.1
-----
- Prevent possbile crash by trying to reposition leaving players

29
mods/beds/README.txt Normal file
View File

@ -0,0 +1,29 @@
Minetest mod "Beds"
===================
by BlockMen (c) 2014-2015
Version: 1.1.1
About
~~~~~
This mod adds a bed to Minetest which allows to skip the night. To sleep rightclick the bed, if playing
in singleplayer mode the night gets skipped imideatly. If playing on server you get shown how many other
players are in bed too. If all players are sleeping the night gets skipped aswell. Also the night skip can be forced
if more than 50% of the players are lying in bed and use this option.
Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point
is set to the beds location and you will respawn there after death.
You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf
License of source code, textures: WTFPL
---------------------------------------
(c) Copyright BlockMen (2014-2015)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.

111
mods/beds/api.lua Normal file
View File

@ -0,0 +1,111 @@
function beds.register_bed(name, def)
minetest.register_node(name .. "_bottom", {
description = def.description,
inventory_image = def.inventory_image,
wield_image = def.wield_image,
drawtype = "nodebox",
tiles = def.tiles.bottom,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
stack_max = 1,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = def.nodebox.bottom,
},
selection_box = {
type = "fixed",
fixed = def.selectionbox,
},
after_place_node = function(pos, placer, itemstack)
local n = minetest.get_node_or_nil(pos)
if not n or not n.param2 then
minetest.remove_node(pos)
return true
end
local dir = minetest.facedir_to_dir(n.param2)
local p = vector.add(pos, dir)
local n2 = minetest.get_node_or_nil(p)
local def = n2 and minetest.registered_items[n2.name]
if not def or not def.buildable_to then
minetest.remove_node(pos)
return true
end
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
return false
end,
on_destruct = function(pos)
local n = minetest.get_node_or_nil(pos)
if not n then return end
local dir = minetest.facedir_to_dir(n.param2)
local p = vector.add(pos, dir)
local n2 = minetest.get_node(p)
if minetest.get_item_group(n2.name, "bed") == 2 and n.param2 == n2.param2 then
minetest.remove_node(p)
end
end,
on_rightclick = function(pos, node, clicker)
beds.on_rightclick(pos, clicker)
end,
on_rotate = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir)
local node2 = minetest.get_node_or_nil(p)
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
not node.param2 == node2.param2 then
return false
end
if minetest.is_protected(p, user:get_player_name()) then
minetest.record_protection_violation(p, user:get_player_name())
return false
end
if mode ~= screwdriver.ROTATE_FACE then
return false
end
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
local node3 = minetest.get_node_or_nil(newp)
local def = node3 and minetest.registered_nodes[node3.name]
if not def or not def.buildable_to then
return false
end
if minetest.is_protected(newp, user:get_player_name()) then
minetest.record_protection_violation(newp, user:get_player_name())
return false
end
node.param2 = new_param2
minetest.swap_node(pos, node)
minetest.remove_node(p)
minetest.set_node(newp, {name = node.name:gsub("%_bottom", "_top"), param2 = new_param2})
return true
end,
})
minetest.register_node(name .. "_top", {
drawtype = "nodebox",
tiles = def.tiles.top,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = def.nodebox.top,
},
selection_box = {
type = "fixed",
fixed = {0, 0, 0, 0, 0, 0},
},
})
minetest.register_alias(name, name .. "_bottom")
-- register recipe
minetest.register_craft({
output = name,
recipe = def.recipe
})
end

88
mods/beds/beds.lua Normal file
View File

@ -0,0 +1,88 @@
-- fancy shaped bed
beds.register_bed("beds:fancy_bed", {
description = "Fancy Bed",
inventory_image = "beds_bed_fancy.png",
wield_image = "beds_bed_fancy.png",
tiles = {
bottom = {
"beds_bed_top1.png",
"default_wood.png",
"beds_bed_side1.png",
"beds_bed_side1.png^[transformFX",
"default_wood.png",
"beds_bed_foot.png",
},
top = {
"beds_bed_top2.png",
"default_wood.png",
"beds_bed_side2.png",
"beds_bed_side2.png^[transformFX",
"beds_bed_head.png",
"default_wood.png",
}
},
nodebox = {
bottom = {
{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375},
{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375},
{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375},
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5},
},
top = {
{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5},
{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5},
{-0.5, 0, 0.4375, 0.5, 0.125, 0.5},
{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5},
{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5},
{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5},
{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375},
}
},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = {
{"", "", "group:stick"},
{"wool:red", "wool:red", "wool:white"},
{"group:wood", "group:wood", "group:wood"},
},
})
-- simple shaped bed
beds.register_bed("beds:bed", {
description = "Simple Bed",
inventory_image = "beds_bed.png",
wield_image = "beds_bed.png",
tiles = {
bottom = {
"beds_bed_top_bottom.png^[transformR90",
"default_wood.png",
"beds_bed_side_bottom_r.png",
"beds_bed_side_bottom_r.png^[transformfx",
"beds_transparent.png",
"beds_bed_side_bottom.png"
},
top = {
"beds_bed_top_top.png^[transformR90",
"default_wood.png",
"beds_bed_side_top_r.png",
"beds_bed_side_top_r.png^[transformfx",
"beds_bed_side_top.png",
"beds_transparent.png",
}
},
nodebox = {
bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
},
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5},
recipe = {
{"wool:red", "wool:red", "wool:white"},
{"group:wood", "group:wood", "group:wood"}
},
})
-- aliases for PA's beds mod
minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom")
minetest.register_alias("beds:bed_top_red", "beds:bed_top")

2
mods/beds/depends.txt Normal file
View File

@ -0,0 +1,2 @@
default
wool

213
mods/beds/functions.lua Normal file
View File

@ -0,0 +1,213 @@
local player_in_bed = 0
local is_sp = minetest.is_singleplayer()
local enable_respawn = minetest.setting_getbool("enable_bed_respawn")
if enable_respawn == nil then
enable_respawn = true
end
-- helper functions
local function get_look_yaw(pos)
local n = minetest.get_node(pos)
if n.param2 == 1 then
return 7.9, n.param2
elseif n.param2 == 3 then
return 4.75, n.param2
elseif n.param2 == 0 then
return 3.15, n.param2
else
return 6.28, n.param2
end
end
local function check_in_beds(players)
local in_bed = beds.player
if not players then
players = minetest.get_connected_players()
end
for n, player in ipairs(players) do
local name = player:get_player_name()
if not in_bed[name] then
return false
end
end
return #players > 0
end
local function lay_down(player, pos, bed_pos, state, skip)
local name = player:get_player_name()
local hud_flags = player:hud_get_flags()
if not player or not name then
return
end
-- stand up
if state ~= nil and not state then
local p = beds.pos[name] or nil
if beds.player[name] ~= nil then
beds.player[name] = nil
player_in_bed = player_in_bed - 1
end
-- skip here to prevent sending player specific changes (used for leaving players)
if skip then
return
end
if p then
player:setpos(p)
end
-- physics, eye_offset, etc
player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
player:set_look_yaw(math.random(1, 180)/100)
default.player_attached[name] = false
player:set_physics_override(1, 1, 1)
hud_flags.wielditem = true
default.player_set_animation(player, "stand" , 30)
-- lay down
else
beds.player[name] = 1
beds.pos[name] = pos
player_in_bed = player_in_bed + 1
-- physics, eye_offset, etc
player:set_eye_offset({x=0,y=-13,z=0}, {x=0,y=0,z=0})
local yaw, param2 = get_look_yaw(bed_pos)
player:set_look_yaw(yaw)
local dir = minetest.facedir_to_dir(param2)
local p = {x=bed_pos.x+dir.x/2,y=bed_pos.y,z=bed_pos.z+dir.z/2}
player:set_physics_override(0, 0, 0)
player:setpos(p)
default.player_attached[name] = true
hud_flags.wielditem = false
default.player_set_animation(player, "lay" , 0)
end
player:hud_set_flags(hud_flags)
end
local function update_formspecs(finished)
local ges = #minetest.get_connected_players()
local form_n = ""
local is_majority = (ges/2) < player_in_bed
if finished then
form_n = beds.formspec ..
"label[2.7,11; Good morning.]"
else
form_n = beds.formspec ..
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
if is_majority then
form_n = form_n ..
"button_exit[2,8;4,0.75;force;Force night skip]"
end
end
for name,_ in pairs(beds.player) do
minetest.show_formspec(name, "beds_form", form_n)
end
end
-- public functions
function beds.kick_players()
for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name)
lay_down(player, nil, nil, false)
end
end
function beds.skip_night()
minetest.set_timeofday(0.23)
beds.set_spawns()
end
function beds.on_rightclick(pos, player)
local name = player:get_player_name()
local ppos = player:getpos()
local tod = minetest.get_timeofday()
if tod > 0.2 and tod < 0.805 then
if beds.player[name] then
lay_down(player, nil, nil, false)
end
minetest.chat_send_player(name, "You can only sleep at night.")
return
end
-- move to bed
if not beds.player[name] then
lay_down(player, ppos, pos)
else
lay_down(player, nil, nil, false)
end
if not is_sp then
update_formspecs(false)
end
-- skip the night and let all players stand up
if check_in_beds() then
minetest.after(2, function()
beds.skip_night()
if not is_sp then
update_formspecs(true)
end
beds.kick_players()
end)
end
end
-- callbacks
minetest.register_on_joinplayer(function(player)
beds.read_spawns()
end)
-- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player)
if not enable_respawn then
return false
end
local name = player:get_player_name()
local pos = beds.spawn[name] or nil
if pos then
player:setpos(pos)
return true
end
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
lay_down(player, nil, nil, false, true)
beds.player[name] = nil
if check_in_beds() then
minetest.after(2, function()
beds.skip_night()
update_formspecs(true)
beds.kick_players()
end)
end
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "beds_form" then
return
end
if fields.quit or fields.leave then
lay_down(player, nil, nil, false)
update_formspecs(false)
end
if fields.force then
beds.skip_night()
update_formspecs(true)
beds.kick_players()
end
end)

16
mods/beds/init.lua Normal file
View File

@ -0,0 +1,16 @@
beds = {}
beds.player = {}
beds.pos = {}
beds.spawn = {}
beds.formspec = "size[8,15;true]"..
"bgcolor[#080808BB; true]"..
"button_exit[2,12;4,0.75;leave;Leave Bed]"
local modpath = minetest.get_modpath("beds")
-- load files
dofile(modpath.."/functions.lua")
dofile(modpath.."/api.lua")
dofile(modpath.."/beds.lua")
dofile(modpath.."/spawns.lua")

58
mods/beds/spawns.lua Normal file
View File

@ -0,0 +1,58 @@
local world_path = minetest.get_worldpath()
local org_file = world_path .. "/beds_spawns"
local file = world_path .. "/beds_spawns"
local bkwd = false
-- check for PA's beds mod spawns
local cf = io.open(world_path .. "/beds_player_spawns", "r")
if cf ~= nil then
io.close(cf)
file = world_path .. "/beds_player_spawns"
bkwd = true
end
function beds.read_spawns()
local spawns = beds.spawn
local input = io.open(file, "r")
if input and not bkwd then
repeat
local x = input:read("*n")
if x == nil then
break
end
local y = input:read("*n")
local z = input:read("*n")
local name = input:read("*l")
spawns[name:sub(2)] = {x = x, y = y, z = z}
until input:read(0) == nil
io.close(input)
elseif input and bkwd then
beds.spawn = minetest.deserialize(input:read("*all"))
input:close()
beds.save_spawns()
os.rename(file, file .. ".backup")
file = org_file
else
spawns = {}
end
end
function beds.save_spawns()
if not beds.spawn then
return
end
local output = io.open(org_file, "w")
for i, v in pairs(beds.spawn) do
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
end
io.close(output)
end
function beds.set_spawns()
for name,_ in pairs(beds.player) do
local player = minetest.get_player_by_name(name)
local p = player:getpos()
beds.spawn[name] = p
end
beds.save_spawns()
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

View File

@ -34,7 +34,7 @@ local boat = {
physical = true, physical = true,
collisionbox = {-0.5, -0.4, -0.5, 0.5, 0.3, 0.5}, collisionbox = {-0.5, -0.4, -0.5, 0.5, 0.3, 0.5},
visual = "mesh", visual = "mesh",
mesh = "boat.x", mesh = "boat.obj",
textures = {"default_wood.png"}, textures = {"default_wood.png"},
driver = nil, driver = nil,

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 546 B

View File

@ -1,6 +1,8 @@
-- Minetest 0.4 mod: bones -- Minetest 0.4 mod: bones
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
bones = {}
local function is_owner(pos, name) local function is_owner(pos, name)
local owner = minetest.get_meta(pos):get_string("owner") local owner = minetest.get_meta(pos):get_string("owner")
if owner == "" or owner == name then if owner == "" or owner == name then
@ -9,6 +11,19 @@ local function is_owner(pos, name)
return false return false
end end
bones.bones_formspec =
"size[8,9]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[current_name;main;0,0.3;8,4;]"..
"list[current_player;main;0,4.85;8,1;]"..
"list[current_player;main;0,6.08;8,3;8]"..
default.get_hotbar_bg(0,4.85)
local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 1200)
local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early") or (share_bones_time/4))
minetest.register_node("bones:bones", { minetest.register_node("bones:bones", {
description = "Bones", description = "Bones",
tiles = { tiles = {
@ -28,7 +43,7 @@ minetest.register_node("bones:bones", {
can_dig = function(pos, player) can_dig = function(pos, player)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
return is_owner(pos, player:get_player_name()) or inv:is_empty("main") return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
@ -84,22 +99,47 @@ minetest.register_node("bones:bones", {
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local publish = 1200 local time = meta:get_int("time") + elapsed
if tonumber(minetest.setting_get("share_bones_time")) then if time >= share_bones_time then
publish = tonumber(minetest.setting_get("share_bones_time"))
end
if publish == 0 then
return
end
if minetest.get_gametime() >= meta:get_int("time") + publish then
meta:set_string("infotext", meta:get_string("owner").."'s old bones") meta:set_string("infotext", meta:get_string("owner").."'s old bones")
meta:set_string("owner", "") meta:set_string("owner", "")
else else
meta:set_int("time", time)
return true return true
end end
end, end,
}) })
local function may_replace(pos, player)
local node_name = minetest.get_node(pos).name
local node_definition = minetest.registered_nodes[node_name]
-- if the node is unknown, we let the protection mod decide
-- this is consistent with when a player could dig or not dig it
-- unknown decoration would often be removed
-- while unknown building materials in use would usually be left
if not node_definition then
-- only replace nodes that are not protected
return not minetest.is_protected(pos, player:get_player_name())
end
-- allow replacing air and liquids
if node_name == "air" or node_definition.liquidtype ~= "none" then
return true
end
-- don't replace filled chests and other nodes that don't allow it
local can_dig_func = node_definition.can_dig
if can_dig_func and not can_dig_func(pos, player) then
return false
end
-- default to each nodes buildable_to; if a placed block would replace it, why shouldn't bones?
-- flowers being squished by bones are more realistical than a squished stone, too
-- exception are of course any protected buildable_to
return node_definition.buildable_to and not minetest.is_protected(pos, player:get_player_name())
end
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
if minetest.setting_getbool("creative_mode") then if minetest.setting_getbool("creative_mode") then
return return
@ -118,26 +158,29 @@ minetest.register_on_dieplayer(function(player)
local param2 = minetest.dir_to_facedir(player:get_look_dir()) local param2 = minetest.dir_to_facedir(player:get_look_dir())
local player_name = player:get_player_name() local player_name = player:get_player_name()
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
local nn = minetest.get_node(pos).name
if minetest.registered_nodes[nn].can_dig and
not minetest.registered_nodes[nn].can_dig(pos, player) then
-- drop items instead of delete if (not may_replace(pos, player)) then
for i=1,player_inv:get_size("main") do if (may_replace({x=pos.x, y=pos.y+1, z=pos.z}, player)) then
minetest.add_item(pos, player_inv:get_stack("main", i)) -- drop one node above if there's space
-- this should solve most cases of protection related deaths in which players dig straight down
-- yet keeps the bones reachable
pos.y = pos.y+1
else
-- drop items instead of delete
for i=1,player_inv:get_size("main") do
minetest.add_item(pos, player_inv:get_stack("main", i))
end
for i=1,player_inv:get_size("craft") do
minetest.add_item(pos, player_inv:get_stack("craft", i))
end
-- empty lists main and craft
player_inv:set_list("main", {})
player_inv:set_list("craft", {})
return
end end
for i=1,player_inv:get_size("craft") do
minetest.add_item(pos, player_inv:get_stack("craft", i))
end
-- empty lists main and craft
player_inv:set_list("main", {})
player_inv:set_list("craft", {})
return
end end
minetest.dig_node(pos) minetest.set_node(pos, {name="bones:bones", param2=param2})
minetest.add_node(pos, {name="bones:bones", param2=param2})
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -157,13 +200,20 @@ minetest.register_on_dieplayer(function(player)
player_inv:set_list("main", {}) player_inv:set_list("main", {})
player_inv:set_list("craft", {}) player_inv:set_list("craft", {})
meta:set_string("formspec", "size[8,9;]".. meta:set_string("formspec", bones.bones_formspec)
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", player_name.."'s fresh bones")
meta:set_string("owner", player_name) meta:set_string("owner", player_name)
meta:set_int("time", minetest.get_gametime())
local timer = minetest.get_node_timer(pos) if share_bones_time ~= 0 then
timer:start(10) meta:set_string("infotext", player_name.."'s fresh bones")
if share_bones_time_early == 0 or not minetest.is_protected(pos, player_name) then
meta:set_int("time", 0)
else
meta:set_int("time", (share_bones_time - share_bones_time_early))
end
minetest.get_node_timer(pos):start(10)
else
meta:set_string("infotext", player_name.."'s bones")
end
end) end)

View File

@ -30,12 +30,14 @@ local function check_protection(pos, name, text)
end end
-- Register a new liquid -- Register a new liquid
-- source = name of the source node -- source = name of the source node
-- flowing = name of the flowing node -- flowing = name of the flowing node
-- itemname = name of the new bucket item (or nil if liquid is not takeable) -- itemname = name of the new bucket item (or nil if liquid is not takeable)
-- inventory_image = texture of the new bucket item (ignored if itemname == nil) -- inventory_image = texture of the new bucket item (ignored if itemname == nil)
-- name = text description of the bucket item
-- groups = (optional) groups of the bucket item, for example {water_bucket = 1}
-- This function can be called from any mod (that depends on bucket). -- This function can be called from any mod (that depends on bucket).
function bucket.register_liquid(source, flowing, itemname, inventory_image, name) function bucket.register_liquid(source, flowing, itemname, inventory_image, name, groups)
bucket.liquids[source] = { bucket.liquids[source] = {
source = source, source = source,
flowing = flowing, flowing = flowing,
@ -49,6 +51,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
inventory_image = inventory_image, inventory_image = inventory_image,
stack_max = 1, stack_max = 1,
liquids_pointable = true, liquids_pointable = true,
groups = groups,
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node -- Must be pointing to node
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
@ -105,7 +108,7 @@ end
minetest.register_craftitem("bucket:bucket_empty", { minetest.register_craftitem("bucket:bucket_empty", {
description = "Empty Bucket", description = "Empty Bucket",
inventory_image = "bucket.png", inventory_image = "bucket.png",
stack_max = 1, stack_max = 99,
liquids_pointable = true, liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
-- Must be pointing to node -- Must be pointing to node
@ -115,17 +118,41 @@ minetest.register_craftitem("bucket:bucket_empty", {
-- Check if pointing to a liquid source -- Check if pointing to a liquid source
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
local liquiddef = bucket.liquids[node.name] local liquiddef = bucket.liquids[node.name]
if liquiddef ~= nil and liquiddef.itemname ~= nil and local item_count = user:get_wielded_item():get_count()
node.name == liquiddef.source then
if liquiddef ~= nil
and liquiddef.itemname ~= nil
and node.name == liquiddef.source then
if check_protection(pointed_thing.under, if check_protection(pointed_thing.under,
user:get_player_name(), user:get_player_name(),
"take ".. node.name) then "take ".. node.name) then
return return
end end
-- default set to return filled bucket
local giving_back = liquiddef.itemname
-- check if holding more than 1 empty bucket
if item_count > 1 then
-- if space in inventory add filled bucked, otherwise drop as item
local inv = user:get_inventory()
if inv:room_for_item("main", {name=liquiddef.itemname}) then
inv:add_item("main", liquiddef.itemname)
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, liquiddef.itemname)
end
-- set to return empty buckets minus 1
giving_back = "bucket:bucket_empty "..tostring(item_count-1)
end
minetest.add_node(pointed_thing.under, {name="air"}) minetest.add_node(pointed_thing.under, {name="air"})
return ItemStack(liquiddef.itemname) return ItemStack(giving_back)
end end
end, end,
}) })
@ -135,7 +162,17 @@ bucket.register_liquid(
"default:water_flowing", "default:water_flowing",
"bucket:bucket_water", "bucket:bucket_water",
"bucket_water.png", "bucket_water.png",
"Water Bucket" "Water Bucket",
{water_bucket = 1}
)
bucket.register_liquid(
"default:river_water_source",
"default:river_water_flowing",
"bucket:bucket_river_water",
"bucket_river_water.png",
"River Water Bucket",
{water_bucket = 1}
) )
bucket.register_liquid( bucket.register_liquid(
@ -152,3 +189,4 @@ minetest.register_craft({
burntime = 60, burntime = 60,
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
}) })

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

View File

@ -250,10 +250,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
else else
local colors = "" local colors = ""
for color, code in pairs(ctf.flag_colors) do for color, code in pairs(ctf.flag_colors) do
if color ~= "" then if colors ~= "" then
color ..= ", " colors = colors .. ", "
end end
color ..= color colors = colors .. color
end end
minetest.chat_send_player(name,"Color "..fields.color.. minetest.chat_send_player(name,"Color "..fields.color..
" does not exist! Available: " .. colors) " does not exist! Available: " .. colors)

View File

@ -4,6 +4,7 @@ function init()
ctf._set("flag.capture_take", false) ctf._set("flag.capture_take", false)
ctf._set("flag.names", true) ctf._set("flag.names", true)
ctf._set("flag.protect_distance", 25) ctf._set("flag.protect_distance", 25)
ctf._set("gui.tab.flags", true)
ctf._set("gui.team.teleport_to_flag", true) ctf._set("gui.team.teleport_to_flag", true)
ctf._set("gui.team.teleport_to_spawn", false) ctf._set("gui.team.teleport_to_spawn", false)
end end

View File

@ -82,10 +82,15 @@ creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
"list[current_player;main;5,4.75;8,3;8]".. "list[current_player;main;5,4.75;8,3;8]"..
"list[current_player;craft;8,0;3,3;]".. "list[current_player;craft;8,0;3,3;]"..
"list[current_player;craftpreview;12,1;1,1;]".. "list[current_player;craftpreview;12,1;1,1;]"..
"image[11,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]".. "list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]"..
"label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]".. "label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]"..
"button[0.3,6.5;1.6,1;creative_prev;<<]".. "button[0.3,6.5;1.6,1;creative_prev;<<]"..
"button[2.7,6.5;1.6,1;creative_next;>>]".. "button[2.7,6.5;1.6,1;creative_next;>>]"..
"listring[current_player;main]"..
"listring[current_player;craft]"..
"listring[current_player;main]"..
"listring[detached:creative;main]"..
"label[5,1.5;Trash:]".. "label[5,1.5;Trash:]"..
"list[detached:creative_trash;main;5,2;1,1;]".. "list[detached:creative_trash;main;5,2;1,1;]"..
default.get_hotbar_bg(5,3.5) default.get_hotbar_bg(5,3.5)

View File

@ -62,12 +62,10 @@ VanessaE (WTFPL):
default_desert_stone.png default_desert_stone.png
default_desert_stone_brick.png default_desert_stone_brick.png
default_sand.png default_sand.png
default_sandstone_brick.png
Calinou (CC BY-SA): Calinou (CC BY-SA):
default_brick.png default_brick.png
default_papyrus.png default_papyrus.png
default_copper_lump.png
default_mineral_copper.png default_mineral_copper.png
default_glass_detail.png default_glass_detail.png
@ -83,7 +81,6 @@ PilzAdam (WTFPL):
default_junglewood.png default_junglewood.png
default_obsidian_glass.png default_obsidian_glass.png
default_obsidian_shard.png default_obsidian_shard.png
default_gold_lump.png
default_mineral_gold.png default_mineral_gold.png
default_snowball.png default_snowball.png
@ -111,6 +108,11 @@ paramat (CC BY-SA 3.0):
default_pinetree.png default_pinetree.png
default_pinetree_top.png default_pinetree_top.png
default_pinewood.png default_pinewood.png
default_sandstone_brick.png
default_obsidian_brick.png
default_river_water.png
default_river_water_source_animated.png
default_river_water_flowing_animated.png
brunob.santos (CC BY-SA 4.0): brunob.santos (CC BY-SA 4.0):
default_desert_cobble.png default_desert_cobble.png
@ -119,22 +121,21 @@ BlockMen (CC BY-SA 3.0):
default_stone_brick.png default_stone_brick.png
default_wood.png default_wood.png
default_clay_brick.png default_clay_brick.png
default_tool_steelsword.png default_iron_ingot.png
default_bronze_ingot.png
default_copper_ingot.png
default_gold_ingot.png default_gold_ingot.png
default_tool_steelsword.png
default_diamond.png default_diamond.png
default_diamond_block.png default_book.png
default_tool_*.png default_tool_*.png
default_lava_source_animated.png default_lava_source_animated.png
default_lava_flowing_animated.png default_lava_flowing_animated.png
default_book.png
default_paper.png
default_stick.png default_stick.png
default_chest_front.png default_chest_front.png
default_chest_lock.png default_chest_lock.png
default_chest_side.png default_chest_side.png
default_chest_top.png default_chest_top.png
default_mineral_mese.png
default_meselamp.png
bubble.png bubble.png
heart.png heart.png
gui_*.png gui_*.png
@ -189,3 +190,15 @@ Mito551 (sounds) (CC BY-SA):
default_dirt_footstep.1.ogg default_dirt_footstep.1.ogg
default_dirt_footstep.2.ogg default_dirt_footstep.2.ogg
default_glass_footstep.ogg default_glass_footstep.ogg
Gambit (WTFPL):
default_bronze_ingot.png
default_copper_ingot.png
default_copper_lump.png
default_iron_lump.png
default_gold_lump.png
default_clay_lump.png
default_coal.png
default_grass_*.png
default_paper.png
default_diamond_block.png

View File

@ -1,6 +1,7 @@
-- aliases (Minetest 0.4 mod) -- mods/default/aliases.lua
-- Provides alias for most default items
-- Aliases to support loading worlds using nodes following the old naming convention
-- These can also be helpful when using chat commands, for example /giveme
minetest.register_alias("stone", "default:stone") minetest.register_alias("stone", "default:stone")
minetest.register_alias("stone_with_coal", "default:stone_with_coal") minetest.register_alias("stone_with_coal", "default:stone_with_coal")
minetest.register_alias("stone_with_iron", "default:stone_with_iron") minetest.register_alias("stone_with_iron", "default:stone_with_iron")
@ -65,3 +66,7 @@ minetest.register_alias("lump_of_iron", "default:iron_lump")
minetest.register_alias("lump_of_clay", "default:clay_lump") minetest.register_alias("lump_of_clay", "default:clay_lump")
minetest.register_alias("steel_ingot", "default:steel_ingot") minetest.register_alias("steel_ingot", "default:steel_ingot")
minetest.register_alias("clay_brick", "default:clay_brick") minetest.register_alias("clay_brick", "default:clay_brick")
minetest.register_alias("snow", "default:snow")
-- Mese now comes in the form of blocks, ore, crystal and fragments
minetest.register_alias("default:mese", "default:mese_block")

View File

@ -324,7 +324,7 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'default:rail 15', output = 'default:rail 24',
recipe = { recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'}, {'default:steel_ingot', '', 'default:steel_ingot'},
{'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, {'default:steel_ingot', 'group:stick', 'default:steel_ingot'},
@ -564,6 +564,14 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({
output = 'default:meselamp 1',
recipe = {
{'', 'default:mese_crystal',''},
{'default:mese_crystal', 'default:glass', 'default:mese_crystal'},
}
})
minetest.register_craft({ minetest.register_craft({
output = 'default:obsidian_shard 9', output = 'default:obsidian_shard 9',
recipe = { recipe = {
@ -650,6 +658,12 @@ minetest.register_craft({
recipe = "default:cobble", recipe = "default:cobble",
}) })
minetest.register_craft({
type = "cooking",
output = "default:stone",
recipe = "default:mossycobble",
})
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "default:desert_stone", output = "default:desert_stone",

View File

@ -11,10 +11,80 @@ minetest.register_craftitem("default:paper", {
inventory_image = "default_paper.png", inventory_image = "default_paper.png",
}) })
local function book_on_use(itemstack, user, pointed_thing)
local player_name = user:get_player_name()
local data = minetest.deserialize(itemstack:get_metadata())
local title, text, owner = "", "", player_name
if data then
title, text, owner = data.title, data.text, data.owner
end
local formspec
if owner == player_name then
formspec = "size[8,8]"..default.gui_bg..
"field[0.5,1;7.5,0;title;Title:;"..
minetest.formspec_escape(title).."]"..
"textarea[0.5,1.5;7.5,7;text;Contents:;"..
minetest.formspec_escape(text).."]"..
"button_exit[2.5,7.5;3,1;save;Save]"
else
formspec = "size[8,8]"..default.gui_bg..
"label[0.5,0.5;by "..owner.."]"..
"label[0.5,0;"..minetest.formspec_escape(title).."]"..
"textarea[0.5,1.5;7.5,7;;"..minetest.formspec_escape(text)..";]"
end
minetest.show_formspec(user:get_player_name(), "default:book", formspec)
end
minetest.register_on_player_receive_fields(function(player, form_name, fields)
if form_name ~= "default:book" or not fields.save or
fields.title == "" or fields.text == "" then
return
end
local inv = player:get_inventory()
local stack = player:get_wielded_item()
local new_stack, data
if stack:get_name() ~= "default:book_written" then
local count = stack:get_count()
if count == 1 then
stack:set_name("default:book_written")
else
stack:set_count(count - 1)
new_stack = ItemStack("default:book_written")
end
else
data = minetest.deserialize(stack:get_metadata())
end
if not data then data = {} end
data.title = fields.title
data.text = fields.text
data.owner = player:get_player_name()
local data_str = minetest.serialize(data)
if new_stack then
new_stack:set_metadata(data_str)
if inv:room_for_item("main", new_stack) then
inv:add_item("main", new_stack)
else
minetest.add_item(player:getpos(), new_stack)
end
else
stack:set_metadata(data_str)
end
player:set_wielded_item(stack)
end)
minetest.register_craftitem("default:book", { minetest.register_craftitem("default:book", {
description = "Book", description = "Book",
inventory_image = "default_book.png", inventory_image = "default_book.png",
groups = {book=1}, groups = {book=1},
on_use = book_on_use,
})
minetest.register_craftitem("default:book_written", {
description = "Book With Text",
inventory_image = "default_book.png",
groups = {book=1, not_in_creative_inventory=1},
stack_max = 1,
on_use = book_on_use,
}) })
minetest.register_craftitem("default:coal_lump", { minetest.register_craftitem("default:coal_lump", {

View File

@ -7,20 +7,20 @@
function default.node_sound_defaults(table) function default.node_sound_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="", gain=1.0} {name = "", gain = 1.0}
table.dug = table.dug or table.dug = table.dug or
{name="default_dug_node", gain=0.25} {name = "default_dug_node", gain = 0.25}
table.place = table.place or table.place = table.place or
{name="default_place_node_hard", gain=1.0} {name = "default_place_node_hard", gain = 1.0}
return table return table
end end
function default.node_sound_stone_defaults(table) function default.node_sound_stone_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_hard_footstep", gain=0.5} {name = "default_hard_footstep", gain = 0.5}
table.dug = table.dug or table.dug = table.dug or
{name="default_hard_footstep", gain=1.0} {name = "default_hard_footstep", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
@ -28,11 +28,11 @@ end
function default.node_sound_dirt_defaults(table) function default.node_sound_dirt_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_dirt_footstep", gain=1.0} {name = "default_dirt_footstep", gain = 1.0}
table.dug = table.dug or table.dug = table.dug or
{name="default_dirt_footstep", gain=1.5} {name = "default_dirt_footstep", gain = 1.5}
table.place = table.place or table.place = table.place or
{name="default_place_node", gain=1.0} {name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
@ -40,11 +40,11 @@ end
function default.node_sound_sand_defaults(table) function default.node_sound_sand_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_sand_footstep", gain=0.2} {name = "default_sand_footstep", gain = 0.2}
table.dug = table.dug or table.dug = table.dug or
{name="default_sand_footstep", gain=0.4} {name = "default_sand_footstep", gain = 0.4}
table.place = table.place or table.place = table.place or
{name="default_place_node", gain=1.0} {name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
@ -52,9 +52,9 @@ end
function default.node_sound_wood_defaults(table) function default.node_sound_wood_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_wood_footstep", gain=0.5} {name = "default_wood_footstep", gain = 0.5}
table.dug = table.dug or table.dug = table.dug or
{name="default_wood_footstep", gain=1.0} {name = "default_wood_footstep", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
@ -62,13 +62,13 @@ end
function default.node_sound_leaves_defaults(table) function default.node_sound_leaves_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_grass_footstep", gain=0.35} {name = "default_grass_footstep", gain = 0.35}
table.dug = table.dug or table.dug = table.dug or
{name="default_grass_footstep", gain=0.7} {name = "default_grass_footstep", gain = 0.7}
table.dig = table.dig or table.dig = table.dig or
{name="default_dig_crumbly", gain=0.4} {name = "default_dig_crumbly", gain = 0.4}
table.place = table.place or table.place = table.place or
{name="default_place_node", gain=1.0} {name = "default_place_node", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
@ -76,69 +76,26 @@ end
function default.node_sound_glass_defaults(table) function default.node_sound_glass_defaults(table)
table = table or {} table = table or {}
table.footstep = table.footstep or table.footstep = table.footstep or
{name="default_glass_footstep", gain=0.5} {name = "default_glass_footstep", gain = 0.5}
table.dug = table.dug or table.dug = table.dug or
{name="default_break_glass", gain=1.0} {name = "default_break_glass", gain = 1.0}
default.node_sound_defaults(table) default.node_sound_defaults(table)
return table return table
end end
--
-- Legacy
--
function default.spawn_falling_node(p, nodename)
spawn_falling_node(p, nodename)
end
-- Horrible crap to support old code
-- Don't use this and never do what this does, it's completely wrong!
-- (More specifically, the client and the C++ code doesn't get the group)
function default.register_falling_node(nodename, texture)
minetest.log("error", debug.traceback())
minetest.log('error', "WARNING: default.register_falling_node is deprecated")
if minetest.registered_nodes[nodename] then
minetest.registered_nodes[nodename].groups.falling_node = 1
end
end
--
-- Global callbacks
--
-- Global environment step function
function on_step(dtime)
-- print("on_step")
end
minetest.register_globalstep(on_step)
function on_placenode(p, node)
--print("on_placenode")
end
minetest.register_on_placenode(on_placenode)
function on_dignode(p, node)
--print("on_dignode")
end
minetest.register_on_dignode(on_dignode)
function on_punchnode(p, node)
end
minetest.register_on_punchnode(on_punchnode)
-- --
-- Lavacooling -- Lavacooling
-- --
default.cool_lava_source = function(pos) default.cool_lava_source = function(pos)
minetest.set_node(pos, {name="default:obsidian"}) minetest.set_node(pos, {name = "default:obsidian"})
minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25}) minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25})
end end
default.cool_lava_flowing = function(pos) default.cool_lava_flowing = function(pos)
minetest.set_node(pos, {name="default:stone"}) minetest.set_node(pos, {name = "default:stone"})
minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25}) minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25})
end end
minetest.register_abm({ minetest.register_abm({
@ -146,8 +103,8 @@ minetest.register_abm({
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(...)
default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider) default.cool_lava_flowing(...)
end, end,
}) })
@ -156,37 +113,71 @@ minetest.register_abm({
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(...)
default.cool_lava_source(pos, node, active_object_count, active_object_count_wider) default.cool_lava_source(...)
end, end,
}) })
-- --
-- Papyrus and cactus growing -- Papyrus and cactus growing
-- --
-- wrapping the functions in abm action is necessary to make overriding them possible
function default.grow_cactus(pos, node)
if node.param2 >= 4 then
return
end
pos.y = pos.y - 1
if minetest.get_item_group(minetest.get_node(pos).name, "sand") == 0 then
return
end
pos.y = pos.y + 1
local height = 0
while node.name == "default:cactus" and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= "air" then
return
end
minetest.set_node(pos, {name = "default:cactus"})
return true
end
function default.grow_papyrus(pos, node)
pos.y = pos.y - 1
local name = minetest.get_node(pos).name
if name ~= "default:dirt_with_grass" and name ~= "default:dirt" then
return
end
if not minetest.find_node_near(pos, 3, {"group:water"}) then
return
end
pos.y = pos.y + 1
local height = 0
while node.name == "default:papyrus" and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= "air" then
return
end
minetest.set_node(pos, {name = "default:papyrus"})
return true
end
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:cactus"}, nodenames = {"default:cactus"},
neighbors = {"group:sand"}, neighbors = {"group:sand"},
interval = 50, interval = 50,
chance = 20, chance = 20,
action = function(pos, node) action = function(...)
pos.y = pos.y-1 default.grow_cactus(...)
local name = minetest.get_node(pos).name end
if minetest.get_item_group(name, "sand") ~= 0 then
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:cactus"})
end
end
end
end,
}) })
minetest.register_abm({ minetest.register_abm({
@ -194,28 +185,12 @@ minetest.register_abm({
neighbors = {"default:dirt", "default:dirt_with_grass"}, neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 50, interval = 50,
chance = 20, chance = 20,
action = function(pos, node) action = function(...)
pos.y = pos.y-1 default.grow_papyrus(...)
local name = minetest.get_node(pos).name end
if name == "default:dirt" or name == "default:dirt_with_grass" then
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
end
end,
}) })
-- --
-- dig upwards -- dig upwards
-- --
@ -229,6 +204,7 @@ function default.dig_up(pos, node, digger)
end end
end end
-- --
-- Leafdecay -- Leafdecay
-- --
@ -277,8 +253,10 @@ minetest.register_abm({
if trunkp then if trunkp then
local n = minetest.get_node(trunkp) local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name] local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing work at the border of the active area -- Assume ignore is a trunk, to make the thing
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then -- work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and
reg.groups.tree ~= 0) then
--print("cached trunk still exists") --print("cached trunk still exists")
return return
end end
@ -292,7 +270,8 @@ minetest.register_abm({
end end
default.leafdecay_trunk_find_allow_accumulator = default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1 default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing work at the border of the active area -- Assume ignore is a trunk, to make the thing
-- work at the border of the active area
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"}) local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then if p1 then
do_preserve = true do_preserve = true
@ -323,3 +302,44 @@ minetest.register_abm({
end end
}) })
--
-- Grass growing
--
minetest.register_abm({
nodenames = {"default:dirt"},
interval = 2,
chance = 200,
action = function(pos, node)
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and
nodedef.liquidtype == "none" and
(minetest.get_node_light(above) or 0) >= 13 then
if name == "default:snow" or name == "default:snowblock" then
minetest.set_node(pos, {name = "default:dirt_with_snow"})
else
minetest.set_node(pos, {name = "default:dirt_with_grass"})
end
end
end
})
minetest.register_abm({
nodenames = {"default:dirt_with_grass"},
interval = 2,
chance = 20,
action = function(pos, node)
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or
nodedef.paramtype == "light") and
nodedef.liquidtype == "none") then
minetest.set_node(pos, {name = "default:dirt"})
end
end
})

View File

@ -18,6 +18,10 @@ local function active_formspec(fuel_percent, item_percent)
"list[current_name;dst;4.75,0.96;2,2;]".. "list[current_name;dst;4.75,0.96;2,2;]"..
"list[current_player;main;0,4.25;8,1;]".. "list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]".. "list[current_player;main;0,5.5;8,3;8]"..
"listring[current_name;dst]"..
"listring[current_player;main]"..
"listring[current_name;src]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25) default.get_hotbar_bg(0, 4.25)
return formspec return formspec
end end
@ -34,6 +38,10 @@ local inactive_formspec =
"list[current_name;dst;4.75,0.96;2,2;]".. "list[current_name;dst;4.75,0.96;2,2;]"..
"list[current_player;main;0,4.25;8,1;]".. "list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]".. "list[current_player;main;0,5.5;8,3;8]"..
"listring[current_name;dst]"..
"listring[current_player;main]"..
"listring[current_name;src]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4.25) default.get_hotbar_bg(0, 4.25)
-- --

View File

@ -1,16 +1,13 @@
-- Minetest 0.4 mod: default -- Minetest 0.4 mod: default
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
-- The API documentation in here was moved into doc/lua_api.txt -- The API documentation in here was moved into game_api.txt
WATER_ALPHA = 160
WATER_VISC = 1
LAVA_VISC = 7
LIGHT_MAX = 14
-- Definitions made by this mod that other mods can use too -- Definitions made by this mod that other mods can use too
default = {} default = {}
default.LIGHT_MAX = 14
-- GUI related stuff -- GUI related stuff
default.gui_bg = "bgcolor[#080808BB;true]" default.gui_bg = "bgcolor[#080808BB;true]"
default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]" default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]"
@ -24,7 +21,7 @@ function default.get_hotbar_bg(x,y)
return out return out
end end
default.gui_suvival_form = "size[8,8.5]".. default.gui_survival_form = "size[8,8.5]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
@ -33,6 +30,8 @@ default.gui_suvival_form = "size[8,8.5]"..
"list[current_player;craft;1.75,0.5;3,3;]".. "list[current_player;craft;1.75,0.5;3,3;]"..
"list[current_player;craftpreview;5.75,1.5;1,1;]".. "list[current_player;craftpreview;5.75,1.5;1,1;]"..
"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. "image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"listring[current_player;main]"..
"listring[current_player;craft]"..
default.get_hotbar_bg(0,4.25) default.get_hotbar_bg(0,4.25)
-- Load files -- Load files
@ -46,3 +45,4 @@ dofile(minetest.get_modpath("default").."/mapgen.lua")
dofile(minetest.get_modpath("default").."/player.lua") dofile(minetest.get_modpath("default").."/player.lua")
dofile(minetest.get_modpath("default").."/trees.lua") dofile(minetest.get_modpath("default").."/trees.lua")
dofile(minetest.get_modpath("default").."/aliases.lua") dofile(minetest.get_modpath("default").."/aliases.lua")
dofile(minetest.get_modpath("default").."/legacy.lua")

25
mods/default/legacy.lua Normal file
View File

@ -0,0 +1,25 @@
-- mods/default/legacy.lua
-- Horrible crap to support old code registering falling nodes
-- Don't use this and never do what this does, it's completely wrong!
-- (More specifically, the client and the C++ code doesn't get the group)
function default.register_falling_node(nodename, texture)
minetest.log("error", debug.traceback())
minetest.log('error', "WARNING: default.register_falling_node is deprecated")
if minetest.registered_nodes[nodename] then
minetest.registered_nodes[nodename].groups.falling_node = 1
end
end
function default.spawn_falling_node(p, nodename)
spawn_falling_node(p, nodename)
end
-- Liquids
WATER_ALPHA = minetest.registered_nodes["default:water_source"].alpha
WATER_VISC = minetest.registered_nodes["default:water_source"].liquid_viscosity
LAVA_VISC = minetest.registered_nodes["default:lava_source"].liquid_viscosity
LIGHT_MAX = default.LIGHT_MAX
-- Formspecs
default.gui_suvival_form = default.gui_survival_form

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ function default.player_register_model(name, def)
end end
-- Default player appearance -- Default player appearance
default.player_register_model("character.x", { default.player_register_model("character.b3d", {
animation_speed = 30, animation_speed = 30,
textures = {"character.png", }, textures = {"character.png", },
animations = { animations = {
@ -93,12 +93,12 @@ end
-- Update appearance when the player joins -- Update appearance when the player joins
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
default.player_attached[player:get_player_name()] = false default.player_attached[player:get_player_name()] = false
default.player_set_model(player, "character.x") default.player_set_model(player, "character.b3d")
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
-- set GUI -- set GUI
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
player:set_inventory_formspec(default.gui_suvival_form) player:set_inventory_formspec(default.gui_survival_form)
end end
player:hud_set_hotbar_image("gui_hotbar.png") player:hud_set_hotbar_image("gui_hotbar.png")
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 576 B

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 B

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 647 B

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 B

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 260 B

Some files were not shown because too many files have changed in this diff Show More