alpha 3.2: mushrooms
|
@ -3,6 +3,11 @@
|
|||
- The engine to use with this game is Minetest.
|
||||
- Site: http://www.minetest.net
|
||||
|
||||
## Devtest
|
||||
|
||||
- The Samz game is based on the "Devtest" game, Minetest's default game for testing purposes.
|
||||
- The same license as for Minetest applies.
|
||||
|
||||
## License of Minetest textures and sounds
|
||||
|
||||
This applies to textures and sounds contained in the games/devtest Minetest
|
||||
|
|
|
@ -72,10 +72,7 @@ farmz.hoe_use = function(itemstack, user, pointed_thing)
|
|||
|
||||
-- put the above node into soil and play sound
|
||||
minetest.set_node(pos_above, {name = "farmz:plow"})
|
||||
minetest.sound_play("default_dig_crumbly", {
|
||||
pos = pointed_thing.under,
|
||||
gain = 0.5,
|
||||
}, true)
|
||||
sound.play("pos", pos_above, "sound_dig_crumbly", 7, 0.3)
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
S, modname = ...
|
||||
|
||||
--Constants
|
||||
mushroom_spread_time = 5
|
||||
|
||||
-- Flower registration
|
||||
|
||||
local function register_flower_deco(name, deco)
|
||||
|
||||
if not(deco.noise_params) then
|
||||
deco.noise_params = {
|
||||
scale = 0.04
|
||||
}
|
||||
deco.noise_params = {}
|
||||
end
|
||||
|
||||
local flower_name = modname..":"..name
|
||||
|
@ -19,7 +20,7 @@ local function register_flower_deco(name, deco)
|
|||
place_on = deco.place_on,
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.02,
|
||||
offset = deco.noise_params.offset or -0.02,
|
||||
scale = deco.noise_params.scale or 0.04,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = deco.seed,
|
||||
|
@ -36,7 +37,7 @@ local function register_flower_deco(name, deco)
|
|||
end
|
||||
|
||||
function flowerz.register_flower(name, def)
|
||||
-- Common flowers' groups
|
||||
-- Common flowers groups
|
||||
def.groups.snappy = 3
|
||||
def.groups.flower = 1
|
||||
def.groups.flora = 1
|
||||
|
@ -71,6 +72,85 @@ function flowerz.register_flower(name, def)
|
|||
end
|
||||
end
|
||||
|
||||
--Mushrooms
|
||||
|
||||
local function spread_mushroom(pos, mushroom_name)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not(node) or not(node.name == mushroom_name) then
|
||||
return
|
||||
end
|
||||
--check for an empty node to spread
|
||||
local cells = {{x=0, y=0, z=-1}, {x=-1, y=0, z=0}, {x=-1, y=0, z=-1}, {x=0, y=0, z=1},
|
||||
{x=1, y=0, z=0}, {x=1, y=0, z=1}}
|
||||
_cells = helper.table.shuffle(cells)
|
||||
local new_pos = vector.add(pos, _cells[1])
|
||||
local under_pos = vector.add(new_pos, {x=0, y=-1, z=0})
|
||||
if helper.node_is_buildable(new_pos) and helper.node_is_soil(under_pos) then
|
||||
minetest.swap_node(new_pos, {name = mushroom_name, param2 = 1})
|
||||
minetest.get_node_timer(new_pos):start(mushroom_spread_time)
|
||||
end
|
||||
end
|
||||
|
||||
function flowerz.register_mushroom(name, def)
|
||||
-- Common mushroom groups
|
||||
def.groups.snappy = 3
|
||||
def.groups.mushroom = 1
|
||||
def.groups.flora = 1
|
||||
def.groups.food = 1
|
||||
def.groups.attached_node = 1
|
||||
|
||||
local mushroom_name = modname..":" .. name
|
||||
|
||||
local inventory_image, tiles
|
||||
tiles = modname.."_mushroom_" .. name .. ".png"
|
||||
if def.inv_img then
|
||||
inventory_image = modname.."_mushroom_" .. name .."_inv.png"
|
||||
else
|
||||
inventory_image = tiles
|
||||
end
|
||||
|
||||
minetest.register_node(mushroom_name, {
|
||||
description = S(def.desc),
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
tiles = {tiles},
|
||||
inventory_image = inventory_image,
|
||||
wield_image = def.wield_image or inventory_image,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
place_param2 = 1,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = def.groups,
|
||||
sounds = sound.leaves(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = def.box
|
||||
},
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
eatz.item_eat(itemstack, user, mushroom_name, def.hp or 1, def.hunger or 2)
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
minetest.get_node_timer(pos):start(mushroom_spread_time)
|
||||
end,
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
spread_mushroom(pos, mushroom_name)
|
||||
return false
|
||||
end
|
||||
})
|
||||
|
||||
if def.deco then
|
||||
register_flower_deco(name, def.deco)
|
||||
end
|
||||
end
|
||||
|
||||
--Tall Flower
|
||||
|
||||
function flowerz.register_tall_flower(name, def)
|
||||
|
||||
local flower_name = modname .. ":" .. name
|
||||
|
@ -82,7 +162,7 @@ function flowerz.register_tall_flower(name, def)
|
|||
def.groups.flora = 1
|
||||
def.groups.attached_node = 1
|
||||
|
||||
local groups_top = helper.table_shallowcopy(def.groups)
|
||||
local groups_top = helper.table.shallowcopy(def.groups)
|
||||
groups_top.not_in_creative_inventory = 1
|
||||
|
||||
minetest.register_node(flower_name_top, {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
flowerz.list = {
|
||||
flowerz.flowers_list = {
|
||||
{
|
||||
name = "calla",
|
||||
def = {
|
||||
|
@ -186,7 +186,7 @@ flowerz.list = {
|
|||
}
|
||||
}
|
||||
|
||||
for _, item in pairs(flowerz.list) do
|
||||
for _, item in pairs(flowerz.flowers_list) do
|
||||
flowerz.register_flower(item.name, item.def)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,3 +6,4 @@ local S = minetest.get_translator(modname)
|
|||
|
||||
assert(loadfile(modpath .. "/api.lua"))(S, modname)
|
||||
assert(loadfile(modpath .. "/flowers.lua"))()
|
||||
assert(loadfile(modpath .. "/mushrooms.lua"))()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# textdomain: flowerz
|
||||
Amanita=Amanita
|
||||
Calla=Calla
|
||||
Champignon=Champiñón
|
||||
Dahlia=Dalia
|
||||
Daisy=Margarita
|
||||
Gerbera Daisy=Margarita Gerbera
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
--Mushrooms
|
||||
|
||||
flowerz.mushrooms_list = {
|
||||
{
|
||||
name = "amanita",
|
||||
def = {
|
||||
desc = "Amanita",
|
||||
hp = -10,
|
||||
hunger = 0,
|
||||
box = {-2/16, -8/16, -2/16, 2/16, 2/16, 2/16},
|
||||
groups = {color_red = 1, flammable = 1},
|
||||
inv_img = false,
|
||||
deco = {
|
||||
type = "simple",
|
||||
place_on = "nodez:dirt_with_grass",
|
||||
seed = 345,
|
||||
noise_params = {
|
||||
scale = 0.0001,
|
||||
offset = 0.0001,
|
||||
},
|
||||
biomes = {"forest"},
|
||||
height = {y_max = 65, y_min = 1}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "champignon",
|
||||
def = {
|
||||
desc = "Champignon",
|
||||
hp = 5,
|
||||
hunger = 4,
|
||||
box = {-2/16, -8/16, -2/16, 2/16, 2/16, 2/16},
|
||||
groups = {color_white = 1, flammable = 1},
|
||||
inv_img = true,
|
||||
deco = {
|
||||
type = "simple",
|
||||
place_on = "nodez:dirt_with_grass",
|
||||
seed = 238,
|
||||
noise_params = {
|
||||
scale = 0.0001,
|
||||
offset = 0.0001,
|
||||
},
|
||||
biomes = {"forest"},
|
||||
height = {y_max = 65, y_min = 1}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
for _, item in pairs(flowerz.mushrooms_list) do
|
||||
flowerz.register_mushroom(item.name, item.def)
|
||||
end
|
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 660 B |
|
@ -60,6 +60,24 @@ function helper.node_is_air(pos, offset)
|
|||
end
|
||||
end
|
||||
|
||||
function helper.node_is_buildable(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node and (helper.node_is_air(pos) or node.buildable_to) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function helper.node_is_soil(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node and minetest.get_item_group(node.name, "soil") >= 1 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function helper.node_is_water(pos, offset)
|
||||
if offset then
|
||||
if offset == "above" then
|
||||
|
@ -132,7 +150,7 @@ helper.nodebox.plant = {
|
|||
|
||||
--Tables
|
||||
|
||||
function helper.table_shallowcopy(original)
|
||||
function helper.table.shallowcopy(original)
|
||||
local copy = {}
|
||||
for key, value in pairs(original) do
|
||||
copy[key] = value
|
||||
|
@ -140,13 +158,13 @@ function helper.table_shallowcopy(original)
|
|||
return copy
|
||||
end
|
||||
|
||||
function helper.table_deepcopy(t) -- deep-copy a table
|
||||
function helper.table.deepcopy(t) -- deep-copy a table
|
||||
if type(t) ~= "table" then return t end
|
||||
local meta = getmetatable(t)
|
||||
local target = {}
|
||||
for k, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
target[k] = helper.table_deepcopy(v)
|
||||
target[k] = helper.table.deepcopy(v)
|
||||
else
|
||||
target[k] = v
|
||||
end
|
||||
|
@ -155,6 +173,16 @@ function helper.table_deepcopy(t) -- deep-copy a table
|
|||
return target
|
||||
end
|
||||
|
||||
function helper.table.shuffle(t) -- suffles numeric indices
|
||||
local len, random = #t, math.random
|
||||
for i = len, 2, -1 do
|
||||
local j = random(1, i)
|
||||
t[i], t[j] = t[j], t[i]
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
--Strings
|
||||
|
||||
function helper.string.split(inputstr, sep)
|
||||
|
|
After Width: | Height: | Size: 649 B |
After Width: | Height: | Size: 643 B |
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 580 B |
|
@ -6,7 +6,7 @@ sound = {}
|
|||
|
||||
local DEFAULT_MAX_HEAR_DISTANCE = 5
|
||||
|
||||
function sound.play(dest_type, dest, soundfile, max_hear_distance)
|
||||
function sound.play(dest_type, dest, soundfile, max_hear_distance, gain)
|
||||
if dest_type == "object" then
|
||||
minetest.sound_play(soundfile, {object = dest, gain = 0.5, max_hear_distance = max_hear_distance or DEFAULT_MAX_HEAR_DISTANCE,})
|
||||
elseif dest_type == "player" then
|
||||
|
@ -14,7 +14,7 @@ function sound.play(dest_type, dest, soundfile, max_hear_distance)
|
|||
--minetest.chat_send_player("singleplayer", player_name..tostring(max_hear_distance))
|
||||
minetest.sound_play(soundfile, {to_player = player_name, gain = 0.5})
|
||||
elseif dest_type == "pos" then
|
||||
minetest.sound_play(soundfile, {pos = dest, gain = 0.5, max_hear_distance = max_hear_distance or DEFAULT_MAX_HEAR_DISTANCE,})
|
||||
minetest.sound_play(soundfile, {pos = dest, gain = gain or 0.5, max_hear_distance = max_hear_distance or DEFAULT_MAX_HEAR_DISTANCE,})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ function treez.register_tree(name, def)
|
|||
},
|
||||
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 1,
|
||||
is_ground_content = false,
|
||||
sounds = sound.wood(),
|
||||
on_place = minetest.rotate_node,
|
||||
|
@ -140,7 +141,7 @@ function treez.register_tree(name, def)
|
|||
description = S("@1 Wood", S(def.description)),
|
||||
tiles = {"treez_"..name.."_wood.png"},
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
place_param2 = 1,
|
||||
is_ground_content = false,
|
||||
groups = {wood = 1, planks = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 3, build=1},
|
||||
sounds = sound.wood(),
|
||||
|
@ -152,6 +153,7 @@ function treez.register_tree(name, def)
|
|||
drawtype = "allfaces_optional",
|
||||
tiles = {"treez_"..name.."_leaves.png"},
|
||||
paramtype = "light",
|
||||
place_param2 = 1,
|
||||
walkable = true,
|
||||
waving = 1,
|
||||
groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2},
|
||||
|
|
After Width: | Height: | Size: 700 B |
|
@ -1,4 +1,4 @@
|
|||
wwikiz = {}
|
||||
wikiz = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(modname)
|
||||
|
@ -200,7 +200,8 @@ local function create_form(player)
|
|||
return [[
|
||||
image_button[0,0;1,1;;btn_build;]]..S("Build")..[[;;]
|
||||
image_button[1,0;1,1;;btn_deco;]]..S("Deco")..[[;;]
|
||||
image_button[2,0;1,1;;btn_food;]]..S("Food")..[[;;]
|
||||
image_button[2,0;1,0.5;;btn_food;]]..S("Food")..[[;;]
|
||||
image_button[2,0.5;1,0.5;;btn_farming;]]..S("Farming")..[[;;]
|
||||
image_button[3,0;1,1;;btn_ore;]]..S("Ores")..[[;;]
|
||||
image_button[4,0;1,1;;btn_pottery;]]..S("Pottery")..[[;;]
|
||||
image_button[5,0;1,1;;btn_tool;]]..S("Tools")..[[;;]
|
||||
|
@ -208,6 +209,7 @@ local function create_form(player)
|
|||
image_button[7,0;1,1;;btn_weapon;]]..S("Weapons")..[[;;]
|
||||
]]..(context.recipes or "")..[[
|
||||
]]..(context.crafts or "")..[[
|
||||
]]..(context.info or "")..[[
|
||||
]]
|
||||
end
|
||||
|
||||
|
@ -223,6 +225,30 @@ local function get_crafts(group)
|
|||
return crafts
|
||||
end
|
||||
|
||||
local function compose_info(lines)
|
||||
local text = ""
|
||||
for _, line in ipairs(lines) do
|
||||
text = text.."-".." "..S(line).."\n"
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
local info = {
|
||||
farming = compose_info({
|
||||
"Plow the soil with a hoe.",
|
||||
"Plant seeds.",
|
||||
"Seeds are obtained by collecting grass or sunflower seeds.",
|
||||
"Wait for them to grow.",
|
||||
"Mushrooms also spread if you plant them."
|
||||
})
|
||||
}
|
||||
|
||||
local function get_info(group)
|
||||
return [[
|
||||
textarea[0.5,2;8,5;;;]]..info[group]..[[]
|
||||
]]
|
||||
end
|
||||
|
||||
local crafts_cache = {}
|
||||
|
||||
sfinv.register_page("wiki", {
|
||||
|
@ -256,7 +282,7 @@ sfinv.register_page("wiki", {
|
|||
end
|
||||
_context.recipes = render_recipes(_context.item_name, _context.recipe_no)
|
||||
else
|
||||
local group
|
||||
local group, crafts
|
||||
if not _context.craft_page then
|
||||
_context.craft_page = 1
|
||||
end
|
||||
|
@ -267,12 +293,22 @@ sfinv.register_page("wiki", {
|
|||
_context.craft_page = _context.craft_page + 1
|
||||
end
|
||||
group = _context.group
|
||||
crafts = true
|
||||
else
|
||||
group = string.sub(key, 5, string.len(key))
|
||||
if group == "farming" then
|
||||
_context.info = get_info(group)
|
||||
_context.crafts = ""
|
||||
_context.recipes = ""
|
||||
crafts = false
|
||||
else
|
||||
_context.group = group
|
||||
_context.craft_page = 1
|
||||
crafts = true
|
||||
end
|
||||
local crafts
|
||||
end
|
||||
if crafts then
|
||||
_context.info = ""
|
||||
if crafts_cache[group] then
|
||||
crafts = crafts_cache[group]
|
||||
else
|
||||
|
@ -284,6 +320,7 @@ sfinv.register_page("wiki", {
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--minetest.chat_send_all(tostring(_context.craft_page))
|
||||
sfinv.set_context(player, _context)
|
||||
sfinv.set_page(player, "wiki")
|
||||
|
|
|
@ -4,6 +4,7 @@ cooking=hornear
|
|||
Deco=Deco
|
||||
dirt=tierra
|
||||
empty=vacío
|
||||
Farming=Cultivo
|
||||
Food=Comida
|
||||
group:=grupo:
|
||||
ordered=ordenado
|
||||
|
@ -18,3 +19,9 @@ unordered=desordenado
|
|||
Vessels=Envases
|
||||
water=agua
|
||||
Weapons=Armas
|
||||
#Info Farming
|
||||
Plow the soil with a hoe.=Ara la tierra con una azada.
|
||||
Plant seeds.=Planta semillas.
|
||||
Seeds are obtained by collecting grass or sunflower seeds.=Obtén semillas recolectando hierba o de los girasoles.
|
||||
Wait for them to grow.=Espera a que crezcan.
|
||||
Mushrooms also spread if you plant them.=Los hongos también se expanden si los plantas.
|
||||
|
|