add games

master
Funket 2016-03-03 00:27:31 +08:00
parent e61a9d1274
commit 6c47e5ac89
2222 changed files with 278092 additions and 0 deletions

1
games/hungry_games/game.conf Executable file
View File

@ -0,0 +1 @@
name = Hungry Game

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -0,0 +1,11 @@
3D Armor - Visible Player Armor
===============================
Default Item Textures (C) Cisoun - WTFPL
Armor Textures: Copyright (C) 2013 Ryan Jones - CC-BY-SA
Source Code: Copyright (C) 2013 Stuart Jones - GPL v3
Special credit to Jordach and MirceaKitsune for providing the default 3d character model.

View File

@ -0,0 +1,138 @@
armor_api = {
default_character_skin = "3d_armor_character.png",
player_hp = {},
wielded_items = {},
}
armor_api.get_player_skin = function(self, name)
local mod_path = minetest.get_modpath("skins")
if mod_path then
local skin = skins.skins[name]
if skin then
if skin ~= skins.default() and skins.get_type(skin) == skins.type.MODEL then
return skin..".png"
end
end
end
return self.default_character_skin
end
armor_api.get_wielded_item_texture = function(self, player)
if not player then
return nil
end
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return nil
end
local texture = minetest.registered_items[item].inventory_image
if texture == "" then
if minetest.registered_items[item].tiles then
return minetest.registered_items[item].tiles[1]
end
end
return texture
end
armor_api.set_player_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local texture = "3d_armor_character_bg.png^[combine:64x64:0,32="..self:get_player_skin(name)
local player_inv = player:get_inventory()
local wielded_item_texture = self:get_wielded_item_texture(player)
if wielded_item_texture then
texture = texture.."^[combine:64x64:0,0="..wielded_item_texture
end
local armor = {head, torso, legs, shield}
for _,v in ipairs({"head", "torso", "legs"}) do
local stack = player_inv:get_stack("armor_"..v, 1)
armor[v] = stack:get_definition().groups["armor_"..v] or 0
if armor[v] > 0 then
item = stack:get_name()
texture = texture.."^[combine:64x64:0,32="..item:gsub("%:", "_")..".png"
end
end
local stack = player_inv:get_stack("armor_shield", 1)
armor["shield"] = stack:get_definition().groups["armor_shield"] or 0
if armor["shield"] > 0 then
item = stack:get_name()
texture = texture.."^[combine:16x16:16,0="..minetest.registered_items[item].inventory_image
end
local armor_level = math.floor(
(.2*armor["head"]) +
(.3*armor["torso"]) +
(.2*armor["legs"]) +
(.3*armor["shield"])
)
local level = (armor_level / 2) + 0.5
local fleshy = 3 - (armor_level / 2)
local armor_groups = {level=1, fleshy=3, snappy=1, choppy=1}
armor_groups.level = level
armor_groups.fleshy = fleshy
player:set_armor_groups(armor_groups)
player:set_properties({
visual = "mesh",
textures = {texture},
visual_size = {x=1, y=1},
})
end
armor_api.update_wielded_item = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return
end
if self.wielded_items[name] then
if self.wielded_items[name] == item then
return
end
self:set_player_armor(player)
end
self.wielded_items[name] = item
end
armor_api.update_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local hp = player:get_hp()
if hp == nil or hp == self.player_hp[name] then
return
end
if self.player_hp[name] > hp then
local player_inv = player:get_inventory()
local armor_inv = minetest.get_inventory({type="detached", name=name.."_outfit"})
if armor_inv == nil then
return
end
local heal_max = 0
for _,v in ipairs({"head", "torso", "legs", "shield"}) do
local stack = armor_inv:get_stack("armor_"..v, 1)
local use = stack:get_definition().groups["armor_use"] or 0
local heal = stack:get_definition().groups["armor_heal"] or 0
stack:add_wear(use)
armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack)
if stack:get_count() == 0 then
self:set_player_armor(player)
end
heal_max = heal_max + heal
end
if heal_max > math.random(100) then
player:set_hp(self.player_hp[name])
return
end
end
self.player_hp[name] = hp
end

View File

@ -0,0 +1,84 @@
3D Armor -- Visible Player Armor
--------------------------------
Crafting Guide
--------------
S = Steel Ingot [default:steel_ingot], W = Wood [default:wood]
Steel Helmet [3d_armor:helmet_steel]
+---+---+---+
| S | S | S |
+---+---+---+
| S | | S |
+---+---+---+
| | | |
+---+---+---+
Steel Chestplate [3d_armor:chestplate_steel]
+---+---+---+
| S | | S |
+---+---+---+
| S | S | S |
+---+---+---+
| S | S | S |
+---+---+---+
Steel Leggings [3d_armor:leggings_steel]
+---+---+---+
| S | S | S |
+---+---+---+
| S | | S |
+---+---+---+
| S | | S |
+---+---+---+
Steel Shield [3d_armor:shield_steel]
+---+---+---+
| S | S | S |
+---+---+---+
| S | S | S |
+---+---+---+
| | S | |
+---+---+---+
Wooden Shield [3d_armor:shield_wood]
+---+---+---+
| W | W | W |
+---+---+---+
| w | W | W |
+---+---+---+
| | W | |
+---+---+---+
Enhanced Wooden Shield [3d_armor:shield_enhanced_wood]
+---+---+---+
| S | W | S |
+---+---+---+
| W | S | W |
+---+---+---+
| | W | |
+---+---+---+

View File

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

View File

@ -0,0 +1,180 @@
local time = 0
local update_time = tonumber(minetest.setting_get("3d_armor_update_time"))
if update_time == nil then
update_time = 2
minetest.setting_set("3d_armor_update_time", tostring(update_time))
end
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor_api.lua")
minetest.register_tool("3d_armor:helmet_steel", {
description = "Steel Helmet",
inventory_image = "3d_armor_inv_helmet_steel.png",
groups = {armor_head=3, armor_heal=15, armor_use=1000},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "3d_armor_inv_chestplate_steel.png",
groups = {armor_torso=3, armor_heal=20, armor_use=2500},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_steel", {
description = "Steel Leggings",
inventory_image = "3d_armor_inv_leggings_steel.png",
groups = {armor_legs=3, armor_heal=15, armor_use=1500},
wear = 0,
})
minetest.register_tool("3d_armor:shield_steel", {
description = "Steel Shield",
inventory_image = "3d_armor_inv_shield_steel.png",
groups = {armor_shield=3, armor_heal=20, armor_use=1500},
wear = 0,
})
minetest.register_tool("3d_armor:shield_wood", {
description = "Wooden Shield",
inventory_image = "3d_armor_inv_shield_wood.png",
groups = {armor_shield=2, armor_heal=10, armor_use=10000},
wear = 0,
})
minetest.register_tool("3d_armor:shield_enhanced_wood", {
description = "Enhanced Wooden Shield",
inventory_image = "3d_armor_inv_shield_enhanced_wood.png",
groups = {armor_shield=2, armor_heal=15, armor_use=3000},
wear = 0,
})
minetest.register_craft({
output = "3d_armor:helmet_steel",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "", "default:steel_ingot"},
{"", "", ""},
},
})
minetest.register_craft({
output = "3d_armor:chestplate_steel",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
},
})
minetest.register_craft({
output = "3d_armor:leggings_steel",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "", "default:steel_ingot"},
},
})
minetest.register_craft({
output = "3d_armor:shield_steel",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
},
})
minetest.register_craft({
output = "3d_armor:shield_wood",
recipe = {
{"default:wood", "default:wood", "default:wood"},
{"default:wood", "default:wood", "default:wood"},
{"", "default:wood", ""},
},
})
minetest.register_craft({
output = "3d_armor:shield_enhanced_wood",
recipe = {
{"default:steel_ingot", "default:wood", "default:steel_ingot"},
{"default:wood", "default:steel_ingot", "default:wood"},
{"", "default:wood", ""},
},
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if fields.outfit then
inventory_plus.set_inventory_formspec(player, "size[8,7.5]"
.."button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,3.5;8,4;]"
.."list[detached:"..name.."_outfit;armor_head;3,0;1,1;]"
.."list[detached:"..name.."_outfit;armor_torso;3,1;1,1;]"
.."list[detached:"..name.."_outfit;armor_legs;3,2;1,1;]"
.."list[detached:"..name.."_outfit;armor_shield;4,1;1,1;]")
return
end
for field, _ in pairs(fields) do
if string.sub(field,0,string.len("skins_set_")) == "skins_set_" then
minetest.after(1, function(player)
armor_api:set_player_armor(player)
end, player)
end
end
end)
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"outfit", "Outfit")
local player_inv = player:get_inventory()
local name = player:get_player_name()
local armor_inv = minetest.create_detached_inventory(name.."_outfit",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
armor_api:set_player_armor(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
armor_api:set_player_armor(player)
end,
allow_put = function(inv, listname, index, stack, player)
if inv:is_empty(listname) then
return 1
end
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
})
for _,v in ipairs({"head", "torso", "legs", "shield"}) do
local armor = "armor_"..v
player_inv:set_size(armor, 1)
armor_inv:set_size(armor, 1)
armor_inv:set_stack(armor, 1, player_inv:get_stack(armor, 1))
end
armor_api.player_hp[name] = 0
local texture = armor_api:get_player_skin(name)
player:set_properties({
visual = "mesh",
mesh = "3d_armor_character.x",
textures = {texture},
visual_size = {x=1, y=1},
})
minetest.after(1, function(player)
armor_api:set_player_armor(player)
end, player)
end)
minetest.register_globalstep(function(dtime)
time = time + dtime
if time > update_time then
for _,player in ipairs(minetest.get_connected_players()) do
armor_api:update_wielded_item(player)
armor_api:update_armor(player)
end
time = 0
end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

View File

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

View File

@ -0,0 +1,103 @@
-- Minetest 0.4 mod: bucket
-- See README.txt for licensing and other information.
minetest.register_alias("bucket", "bucket:bucket_empty")
minetest.register_alias("bucket_water", "bucket:bucket_water")
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
minetest.register_craft({
output = 'bucket:bucket_empty 1',
recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'},
{'', 'default:steel_ingot', ''},
}
})
bucket = {}
bucket.liquids = {}
-- Register a new liquid
-- source = name of the source node
-- flowing = name of the flowing node
-- 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)
-- This function can be called from any mod (that depends on bucket).
function bucket.register_liquid(source, flowing, itemname, inventory_image)
bucket.liquids[source] = {
source = source,
flowing = flowing,
itemname = itemname,
}
bucket.liquids[flowing] = bucket.liquids[source]
if itemname ~= nil then
minetest.register_craftitem(itemname, {
inventory_image = inventory_image,
stack_max = 1,
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Check if pointing to a buildable node
n = minetest.env:get_node(pointed_thing.under)
if minetest.registered_nodes[n.name].buildable_to then
-- buildable; replace the node
minetest.env:add_node(pointed_thing.under, {name=source})
else
-- not buildable to; place the liquid above
-- check if the node above can be replaced
n = minetest.env:get_node(pointed_thing.above)
if minetest.registered_nodes[n.name].buildable_to then
minetest.env:add_node(pointed_thing.above,{name=source})
else
-- do not remove the bucket with the liquid
return
end
end
return {name="bucket:bucket_empty"}
end
})
end
end
minetest.register_craftitem("bucket:bucket_empty", {
description = "Empty Bucket",
inventory_image = "bucket.png",
stack_max = 1,
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Check if pointing to a liquid source
n = minetest.env:get_node(pointed_thing.under)
liquiddef = bucket.liquids[n.name]
if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
minetest.env:add_node(pointed_thing.under, {name="air"})
return {name=liquiddef.itemname}
end
end,
})
bucket.register_liquid(
"default:water_source",
"default:water_flowing",
"bucket:bucket_water",
"bucket_water.png"
)
bucket.register_liquid(
"default:lava_source",
"default:lava_flowing",
"bucket:bucket_lava",
"bucket_lava.png"
)
minetest.register_craft({
type = "fuel",
recipe = "bucket:bucket_lava",
burntime = 60,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -0,0 +1,182 @@
minetest.register_entity(":__builtin:item", {
initial_properties = {
hp_max = 1,
physical = true,
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
visual = "sprite",
visual_size = {x=0.5, y=0.5},
textures = {""},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = false,
timer = 0,
},
itemstring = '',
physical_state = true,
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
local itemtable = stack:to_table()
local itemname = nil
if itemtable then
itemname = stack:to_table().name
end
local item_texture = nil
local item_type = ""
if minetest.registered_items[itemname] then
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
is_visible = true,
visual = "sprite",
textures = {"unknown_item.png"}
}
if item_texture and item_texture ~= "" then
prop.visual = "sprite"
prop.textures = {item_texture}
prop.visual_size = {x=0.50, y=0.50}
else
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.20, y=0.20}
prop.automatic_rotate = math.pi * 0.25
end
self.object:set_properties(prop)
end,
get_staticdata = function(self)
--return self.itemstring
return minetest.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
timer = self.timer,
})
end,
on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
self.timer = data.timer
if not self.timer then
self.timer = 0
end
self.timer = self.timer+dtime_s
end
else
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal=1})
self.object:setvelocity({x=0, y=2, z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring)
end,
on_step = function(self, dtime)
local time = minetest.setting_get("remove_items")
if not time then
time = 300
end
if not self.timer then
self.timer = 0
end
self.timer = self.timer + dtime
if time ~= 0 and (self.timer > time) then
self.object:remove()
end
local p = self.object:getpos()
local name = minetest.env:get_node(p).name
if name == "default:lava_flowing" or name == "default:lava_source" then
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos()})
self.object:remove()
return
end
if minetest.registered_nodes[name].liquidtype == "flowing" then
get_flowing_dir = function(self)
local pos = self.object:getpos()
local param2 = minetest.env:get_node(pos).param2
for i,d in ipairs({-1, 1, -1, 1}) do
if i<3 then
pos.x = pos.x+d
else
pos.z = pos.z+d
end
local name = minetest.env:get_node(pos).name
local par2 = minetest.env:get_node(pos).param2
if name == "default:water_flowing" and par2 < param2 then
return pos
end
if i<3 then
pos.x = pos.x-d
else
pos.z = pos.z-d
end
end
end
local vec = get_flowing_dir(self)
if vec then
local v = self.object:getvelocity()
if vec and vec.x-p.x > 0 then
self.object:setvelocity({x=0.5,y=v.y,z=0})
elseif vec and vec.x-p.x < 0 then
self.object:setvelocity({x=-0.5,y=v.y,z=0})
elseif vec and vec.z-p.z > 0 then
self.object:setvelocity({x=0,y=v.y,z=0.5})
elseif vec and vec.z-p.z < 0 then
self.object:setvelocity({x=0,y=v.y,z=-0.5})
end
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
return
end
end
p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name
-- If node is not registered or node is walkably solid
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.physical_state = false
self.object:set_properties({
physical = false
})
end
else
if not self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
end
end
end,
on_punch = function(self, hitter)
if self.itemstring ~= '' then
hitter:get_inventory():add_item("main", self.itemstring)
end
self.object:remove()
end,
})
if minetest.setting_get("log_mods") then
minetest.log("action", "builtin_item loaded")
end

View File

@ -0,0 +1 @@
default

View File

@ -0,0 +1,158 @@
-- minetest/creative/init.lua
local creative_inventory = {}
creative_inventory.creative_inventory_size = 0
-- Create detached creative inventory after loading all mods
minetest.after(0, function()
local inv = minetest.create_detached_inventory("creative", {
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return count
end,
allow_put = function(inv, listname, index, stack, player)
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return -1
end,
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
end,
on_put = function(inv, listname, index, stack, player)
end,
on_take = function(inv, listname, index, stack, player)
print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
if stack then
print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
end
end,
})
local creative_list = {}
for name,def in pairs(minetest.registered_items) do
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
and def.description and def.description ~= "" then
table.insert(creative_list, name)
end
end
table.sort(creative_list)
inv:set_size("main", #creative_list)
for _,itemstring in ipairs(creative_list) do
inv:add_item("main", ItemStack(itemstring.." 99"))
end
creative_inventory.creative_inventory_size = #creative_list
print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
end)
-- Create the trash field
local trash = minetest.create_detached_inventory("creative_trash", {
-- Allow the stack to be placed and remove it in on_put()
-- This allows the creative inventory to restore the stack
allow_put = function(inv, listname, index, stack, player)
return stack:get_count()
end,
on_put = function(inv, listname, index, stack, player)
inv:set_stack(listname, index, "")
end,
})
trash:set_size("main", 1)
local get_formspec = function(player,start_i, pagenum)
if not minetest.get_player_privs(player:get_player_name()).hg_maker then
return
end
pagenum = math.floor(pagenum)
local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1)
return "size[13,7.5]"..
--"image[6,0.6;1,2;player.png]"..
"button[0,0;2,0.5;main;Back]"..
"list[current_player;main;5,3.5;8,4;]"..
"list[current_player;craft;8,0;3,3;]"..
"list[current_player;craftpreview;12,1;1,1;]"..
"list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]"..
"label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]"..
"button[0.3,6.5;1.6,1;hg_prev;<<]"..
"button[2.7,6.5;1.6,1;hg_next;>>]"..
"label[5,1.5;Trash:]"..
"list[detached:creative_trash;main;5,2;1,1;]"
end
minetest.register_on_joinplayer(function(player)
-- If in creative mode, modify player's inventory forms
if not minetest.get_player_privs(player:get_player_name()).hg_maker then
return
end
inventory_plus.register_button(player,"hgmaker","HG Maker")
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Figure out current page from formspec
local current_page = 0
local formspec = player:get_inventory_formspec()
local start_i = string.match(formspec, "list%[detached:creative;main;[%d.]+,[%d.]+;[%d.]+,[%d.]+;(%d+)%]")
start_i = tonumber(start_i) or 0
local function setformspec()
if start_i < 0 then
start_i = start_i + 4*6
end
if start_i >= creative_inventory.creative_inventory_size then
start_i = start_i - 4*6
end
if start_i < 0 or start_i >= creative_inventory.creative_inventory_size then
start_i = 0
end
inventory_plus.set_inventory_formspec(player, get_formspec(player, start_i, start_i / (6*4) + 1))
end
if fields.hg_prev then
start_i = start_i - 4*6
setformspec()
end
if fields.hg_next then
start_i = start_i + 4*6
setformspec()
end
if fields.hgmaker then
setformspec()
end
end)
if minetest.setting_getbool("creative_mode") then
minetest.register_item(":", {
type = "none",
wield_image = "wieldhand.png",
wield_scale = {x=1,y=1,z=2.5},
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
cracky = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
snappy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
choppy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
oddly_breakable_by_hand = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
}
}
})
function minetest.handle_node_drops(pos, drops, digger)
if not digger or not digger:is_player() then
return
end
local inv = digger:get_inventory()
if inv then
for _,item in ipairs(drops) do
item = ItemStack(item):get_name()
if not inv:contains_item("main", item) then
inv:add_item("main", item)
end
end
end
end
end

View File

@ -0,0 +1,23 @@
minetest.register_on_dieplayer(function(player)
local pos = player:getpos()
inv = player:get_inventory()
inventorylist = inv:get_list("main")
--Drop all players items
for i,v in pairs(inventorylist) do
obj = minetest.env:add_item({x=math.floor(pos.x)+math.random(), y=pos.y, z=math.floor(pos.z)+math.random()}, v)
if obj ~= nil then
obj:get_luaentity().collect = true
local x = math.random(1, 5)
if math.random(1,2) == 1 then
x = -x
end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
end
end
inv:set_list("main", {})
return
end)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
-- minetest/default/leafdecay.lua
-- To enable leaf decay for a node, add it to the "leafdecay" group.
--
-- The rating of the group determines how far from a node in the group "tree"
-- the node can be without decaying.
--
-- If param2 of the node is ~= 0, the node will always be preserved. Thus, if
-- the player places a node of that kind, you will want to set param2=1 or so.
default.leafdecay_trunk_cache = {}
default.leafdecay_enable_cache = true
-- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
minetest.register_abm({
nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"},
-- A low interval and a high inverse chance spreads the load
interval = 2,
chance = 5,
action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
local do_preserve = false
local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then
--print("not groups.leafdecay")
return
end
local n0 = minetest.env:get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
end
local p0_hash = nil
if default.leafdecay_enable_cache then
p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then
local n = minetest.env:get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing 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")
return
end
--print("cached trunk is invalid")
-- Cache is invalid
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
end
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
return
end
default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing work at the border of the active area
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
--print("caching trunk")
-- Cache the trunk
default.leafdecay_trunk_cache[p0_hash] = p1
end
end
if not do_preserve then
-- Drop stuff other than the node itself
itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do
if itemname ~= n0.name then
local p_drop = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.env:add_item(p_drop, itemname)
end
end
-- Remove node
minetest.env:remove_node(p0)
nodeupdate(p0)
end
end
})

View File

@ -0,0 +1,304 @@
-- minetest/default/mapgen.lua
--
-- Aliases for map generator outputs
--
minetest.register_alias("mapgen_air", "air")
minetest.register_alias("mapgen_stone", "default:stone")
minetest.register_alias("mapgen_tree", "default:tree")
minetest.register_alias("mapgen_leaves", "default:leaves")
minetest.register_alias("mapgen_apple", "default:apple")
minetest.register_alias("mapgen_water_source", "default:water_source")
minetest.register_alias("mapgen_dirt", "default:dirt")
minetest.register_alias("mapgen_sand", "default:sand")
minetest.register_alias("mapgen_gravel", "default:gravel")
minetest.register_alias("mapgen_clay", "default:clay")
minetest.register_alias("mapgen_lava_source", "default:lava_source")
minetest.register_alias("mapgen_cobble", "default:cobble")
minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
minetest.register_alias("mapgen_mese", "default:mese")
minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
--
-- Ore generation
--
function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
if maxp.y < height_min or minp.y > height_max then
return
end
local y_min = math.max(minp.y, height_min)
local y_max = math.min(maxp.y, height_max)
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
local pr = PseudoRandom(seed)
local num_chunks = math.floor(chunks_per_volume * volume)
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
--print("generate_ore num_chunks: "..dump(num_chunks))
for i=1,num_chunks do
local y0 = pr:next(y_min, y_max-chunk_size+1)
if y0 >= height_min and y0 <= height_max then
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
local p0 = {x=x0, y=y0, z=z0}
for x1=0,chunk_size-1 do
for y1=0,chunk_size-1 do
for z1=0,chunk_size-1 do
if pr:next(1,inverse_chance) == 1 then
local x2 = x0+x1
local y2 = y0+y1
local z2 = z0+z1
local p2 = {x=x2, y=y2, z=z2}
if minetest.env:get_node(p2).name == wherein then
minetest.env:set_node(p2, {name=name})
end
end
end
end
end
end
end
--print("generate_ore done")
end
function default.make_papyrus(pos, size)
for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z}
local nn = minetest.env:get_node(p).name
if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then
minetest.env:set_node(p, {name="default:papyrus"})
else
return
end
end
end
function default.make_cactus(pos, size)
for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z}
local nn = minetest.env:get_node(p).name
if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then
minetest.env:set_node(p, {name="default:cactus"})
else
return
end
end
end
-- facedir: 0/1/2/3 (head node facedir value)
-- length: length of rainbow tail
function default.make_nyancat(pos, facedir, length)
local tailvec = {x=0, y=0, z=0}
if facedir == 0 then
tailvec.z = 1
elseif facedir == 1 then
tailvec.x = 1
elseif facedir == 2 then
tailvec.z = -1
elseif facedir == 3 then
tailvec.x = -1
else
print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
facedir = 0
tailvec.z = 1
end
local p = {x=pos.x, y=pos.y, z=pos.z}
minetest.env:set_node(p, {name="default:nyancat", param2=facedir})
for i=1,length do
p.x = p.x + tailvec.x
p.z = p.z + tailvec.z
minetest.env:set_node(p, {name="default:nyancat_rainbow"})
end
end
function generate_nyancats(seed, minp, maxp)
local height_min = -31000
local height_max = -32
if maxp.y < height_min or minp.y > height_max then
return
end
local y_min = math.max(minp.y, height_min)
local y_max = math.min(maxp.y, height_max)
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
local pr = PseudoRandom(seed + 9324342)
local max_num_nyancats = math.floor(volume / (16*16*16))
for i=1,max_num_nyancats do
if pr:next(0, 1000) == 0 then
local x0 = pr:next(minp.x, maxp.x)
local y0 = pr:next(minp.y, maxp.y)
local z0 = pr:next(minp.z, maxp.z)
local p0 = {x=x0, y=y0, z=z0}
default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
end
end
end
minetest.register_on_generated(function(minp, maxp, seed)
-- Generate regular ores
default.generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8, 3, 8, -31000, 64)
default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3, -15, 2)
default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9, 3, 5, -63, -16)
default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7, 3, 5, -31000, -64)
default.generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3, -127, -64)
default.generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+5, 1/9/9/9, 3, 5, -31000, -128)
default.generate_ore("default:mese", "default:stone", minp, maxp, seed+8, 1/16/16/16, 2, 3, -31000,-1024)
default.generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000, 0)
default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64)
if maxp.y >= 2 and minp.y <= 0 then
-- Generate clay
-- Assume X and Z lengths are equal
local divlen = 4
local divs = (maxp.x-minp.x)/divlen+1;
for divx=0+1,divs-1-1 do
for divz=0+1,divs-1-1 do
local cx = minp.x + math.floor((divx+0.5)*divlen)
local cz = minp.z + math.floor((divz+0.5)*divlen)
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
local is_shallow = true
local num_water_around = 0
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
num_water_around = num_water_around + 1 end
if num_water_around >= 2 then
is_shallow = false
end
if is_shallow then
for x1=-divlen,divlen do
for z1=-divlen,divlen do
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
end
end
end
end
end
end
end
-- Generate papyrus
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
-- Assume X and Z lengths are equal
local divlen = 8
local divs = (maxp.x-minp.x)/divlen+1;
for divx=0,divs-1 do
for divz=0,divs-1 do
local x0 = minp.x + math.floor((divx+0)*divlen)
local z0 = minp.z + math.floor((divz+0)*divlen)
local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine papyrus amount from perlin noise
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
-- Find random positions for papyrus based on this random
local pr = PseudoRandom(seed+1)
for i=0,papyrus_amount do
local x = pr:next(x0, x1)
local z = pr:next(z0, z1)
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
end
end
end
end
-- Generate cactuses
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
-- Assume X and Z lengths are equal
local divlen = 16
local divs = (maxp.x-minp.x)/divlen+1;
for divx=0,divs-1 do
for divz=0,divs-1 do
local x0 = minp.x + math.floor((divx+0)*divlen)
local z0 = minp.z + math.floor((divz+0)*divlen)
local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine cactus amount from perlin noise
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
-- Find random positions for cactus based on this random
local pr = PseudoRandom(seed+1)
for i=0,cactus_amount do
local x = pr:next(x0, x1)
local z = pr:next(z0, z1)
-- Find ground level (0...15)
local ground_y = nil
for y=30,0,-1 do
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
ground_y = y
break
end
end
-- If desert sand, make cactus
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
end
end
end
end
-- Generate grass
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
-- Assume X and Z lengths are equal
local divlen = 16
local divs = (maxp.x-minp.x)/divlen+1;
for divx=0,divs-1 do
for divz=0,divs-1 do
local x0 = minp.x + math.floor((divx+0)*divlen)
local z0 = minp.z + math.floor((divz+0)*divlen)
local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine grass amount from perlin noise
local grass_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0)
-- Find random positions for grass based on this random
local pr = PseudoRandom(seed+1)
for i=0,grass_amount do
local x = pr:next(x0, x1)
local z = pr:next(z0, z1)
-- Find ground level (0...15)
local ground_y = nil
for y=30,0,-1 do
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
ground_y = y
break
end
end
if ground_y then
local p = {x=x,y=ground_y+1,z=z}
local nn = minetest.env:get_node(p).name
-- Check if the node can be replaced
if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then
nn = minetest.env:get_node({x=x,y=ground_y,z=z}).name
-- If desert sand, make dry shrub
if nn == "default:desert_sand" then
minetest.env:set_node(p,{name="default:dry_shrub"})
-- If grass, make junglegrass
elseif nn == "default:dirt_with_grass" then
minetest.env:set_node(p,{name="default:junglegrass"})
end
end
end
end
end
end
end
-- Generate nyan cats
generate_nyancats(seed, minp, maxp)
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
-- Minetest 0.4 mod: player
-- See README.txt for licensing and other information.
--
-- Start of configuration area:
--
-- Player animation speed
animation_speed = 30
-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
animation_blend = 0
-- Default player appearance
default_model = "character.x"
default_textures = {"character.png", }
-- Frame ranges for each player model
function player_get_animations(model)
if model == "character.x" then
return {
stand_START = 0,
stand_END = 79,
sit_START = 81,
sit_END = 160,
lay_START = 162,
lay_END = 166,
walk_START = 168,
walk_END = 187,
mine_START = 189,
mine_END = 198,
walk_mine_START = 200,
walk_mine_END = 219
}
end
end
--
-- End of configuration area.
--
-- Player stats and animations
local player_model = {}
local player_anim = {}
local player_sneak = {}
local ANIM_STAND = 1
local ANIM_SIT = 2
local ANIM_LAY = 3
local ANIM_WALK = 4
local ANIM_WALK_MINE = 5
local ANIM_MINE = 6
-- Called when a player's appearance needs to be updated
function player_update_visuals(pl)
local name = pl:get_player_name()
player_model[name] = default_model
player_anim[name] = 0 -- Animation will be set further below immediately
player_sneak[name] = false
prop = {
mesh = default_model,
textures = default_textures,
visual = "mesh",
visual_size = {x=1, y=1},
}
pl:set_properties(prop)
end
-- Update appearance when the player joins
minetest.register_on_joinplayer(player_update_visuals)
-- Check each player and apply animations
function player_step(dtime)
for _, pl in pairs(minetest.get_connected_players()) do
local name = pl:get_player_name()
local anim = player_get_animations(player_model[name])
local controls = pl:get_player_control()
local walking = false
local animation_speed_mod = animation_speed
-- Determine if the player is walking
if controls.up or controls.down or controls.left or controls.right then
walking = true
end
-- Determine if the player is sneaking, and reduce animation speed if so
if controls.sneak and pl:get_hp() ~= 0 and (walking or controls.LMB) then
animation_speed_mod = animation_speed_mod / 2
-- Refresh player animation below if sneak state changed
if not player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = true
end
else
-- Refresh player animation below if sneak state changed
if player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = false
end
end
-- Apply animations based on what the player is doing
if pl:get_hp() == 0 then
if player_anim[name] ~= ANIM_LAY then
pl:set_animation({x=anim.lay_START, y=anim.lay_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_LAY
end
elseif walking and controls.LMB then
if player_anim[name] ~= ANIM_WALK_MINE then
pl:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK_MINE
end
elseif walking then
if player_anim[name] ~= ANIM_WALK then
pl:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK
end
elseif controls.LMB then
if player_anim[name] ~= ANIM_MINE then
pl:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_MINE
end
elseif player_anim[name] ~= ANIM_STAND then
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_STAND
end
end
end
minetest.register_globalstep(player_step)
-- END

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 962 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

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