master
root 2021-03-26 21:04:00 +01:00
parent 58d4052b2a
commit 33229d7922
14 changed files with 311 additions and 144 deletions

View File

@ -16,3 +16,12 @@ Author: elmoustachio
https://freesound.org/people/elmoustachio/sounds/476735/
License: This work is licensed under the Creative Commons 0 License.
# Mentions
- I take some code from the Weather Mod by theFox6:
https://forum.minetest.net/viewtopic.php?t=5245
https://github.com/theFox6/minetest_mod_weather
- I take some ideas from the mod:
Regional Weather Bundle by TestificateMods
https://forum.minetest.net/viewtopic.php?t=24569

View File

@ -22,4 +22,3 @@ lightning_chance = 300
thunder_sound = true
##Dust Screen Effect for Sandstorms
dust_effect = true

View File

@ -60,15 +60,17 @@ local function player_inside_climate(player_pos)
--This function returns the climate_id if inside and true/false if the climate is enabled or not
--check altitude
if (player_pos.y < climatez.settings.climate_min_height) or (player_pos.y > climate_max_height) then
return false, nil
return false, nil, nil
end
--check if on water
player_pos.y = player_pos.y + 1
local node_name = minetest.get_node(player_pos).name
if minetest.registered_nodes[node_name] and (
minetest.registered_nodes[node_name]["liquidtype"] == "source" or
minetest.registered_nodes[node_name]["liquidtype"] == "flowing") then
return false, false
return false, nil, true
end
player_pos.y = player_pos.y - 1
--If sphere's centre coordinates is (cx,cy,cz) and its radius is r,
--then point (x,y,z) is in the sphere if (xcx)2+(ycy)2+(zcz)2<r2.
for i, _climate in ipairs(climatez.climates) do
@ -78,13 +80,13 @@ local function player_inside_climate(player_pos)
(player_pos.z - climate_center.z)^2
) then
if climatez.climates[i].disabled then
return i, true
return i, true, false
else
return i, false
return i, false, false
end
end
end
return false, false
return false, false, false
end
local function has_light(minp, maxp)
@ -537,10 +539,12 @@ minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do
local player_name = player:get_player_name()
local player_pos = player:get_pos()
local climate_id, climate_disabled = player_inside_climate(player_pos)
local climate_id, climate_disabled, on_water = player_inside_climate(player_pos)
--minetest.chat_send_all(player_name .. " in climate "..tostring(climate_id))
local _climate = climatez.players[player_name]
if climate_id and not(climate_disabled) and _climate then
if _climate and on_water then
remove_climate_player(player_name)
elseif climate_id and not(climate_disabled) and _climate then
local _climate_id = _climate.climate_id --check if player still inside the climate
if not(climate_id == _climate_id) then
remove_climate_player(player_name)
@ -568,7 +572,9 @@ minetest.register_globalstep(function(dtime)
local player = minetest.get_player_by_name(_player_name)
if player and _climate then
if not(_climate.disabled) then
climatez.climates[_climate.climate_id]:apply(_player_name)
if climatez.climates[_climate.climate_id] then
climatez.climates[_climate.climate_id]:apply(_player_name)
end
end
end
end

View File

@ -1,3 +1,4 @@
## Generic ignorable patterns and files
*.obj
*.blend1
*.blend1
user.conf

View File

@ -174,9 +174,16 @@ petz.create_form = function(player_name, buy)
form_size.h = form_size.h + 2
buttonexit_pos.x = buttonexit_pos.x + 1
buttonexit_pos.y = buttonexit_pos.y - 2
local item_description = petz.settings.selling_exchange_items_list[pet.exchange_item_index].description or ""
local item_description
local item_inventory_image
if petz.settings.selling_exchange_items_list[pet.exchange_item_index] then
item_description = petz.settings.selling_exchange_items_list[pet.exchange_item_index].description or ""
item_inventory_image = petz.settings.selling_exchange_items_list[pet.exchange_item_index].inventory_image or ""
else
item_description = ""
item_inventory_image = ""
end
local item_amount = pet.exchange_item_amount or 1
local item_inventory_image = petz.settings.selling_exchange_items_list[pet.exchange_item_index].inventory_image or ""
tab_form = tab_form ..
"label[0.375,1.85;"..S("Cost")..": ]"..
"label[2,1.85;"..item_description.."]"..

View File

@ -2,9 +2,20 @@ petz.update_nametag = function(self)
local name_tag
if self.show_tag and self.tag and not(self.tag == "") then
name_tag = self.tag
self.object:set_nametag_attributes({text = name_tag ..""..tostring(self.hp).."/"..tostring(self.max_hp),})
local _bgcolor
if not petz.settings["tag_background"] then
_bgcolor = "#FFFFFF00"
else
_bgcolor = false
end
self.object:set_nametag_attributes({
text = name_tag ..""..tostring(self.hp).."/"..tostring(self.max_hp),
bgcolor = _bgcolor,
})
else
self.object:set_nametag_attributes({text = "",})
self.object:set_nametag_attributes({
text = "",
})
end
end

View File

@ -12,9 +12,11 @@ petz.on_step = function(self, dtime)
if self.gallop then
petz.gallop(self, on_step_time)
end
--DELETE WHEN UPDATING TO 5.4-->
if not(self.on_deactivate) then
petz.dreamcatcher_save_metadata(self)
end
--<
local lifetime = petz.check_lifetime(self)
if lifetime then
petz.lifetime_timer(self, lifetime, on_step_time)

View File

@ -68,7 +68,7 @@ petz.milk_refill = function(self)
end
petz.milk_milk = function(self, clicker)
if not self.is_male then
if self.is_male then
minetest.chat_send_player(clicker:get_player_name(), S("Milk only female animals!"))
return
end

View File

@ -59,4 +59,46 @@ if minetest.get_modpath("hunger_ng") ~= nil then
hunger_ng.add_hunger_data('petz:candy_cane', {
satiates = 6.0,
})
hunger_ng.add_hunger_data('petz:beef', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:roasted_ducky', {
satiates = 3.0,
})
hunger_ng.add_hunger_data('petz:roasted_rabbit', {
satiates = 3.0,
})
hunger_ng.add_hunger_data('petz:roasted_goat_meat', {
satiates = 4.0,
})
hunger_ng.add_hunger_data('petz:raw_rabbit', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:frog_leg', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:honey_bottle', {
satiates = 7.0,
})
hunger_ng.add_hunger_data('petz:mini_lamb_chop', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:raw_chicken', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:raw_ducky', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:raw_goat', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:raw_parrot', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:raw_porkchop', {
satiates = 1.0,
})
hunger_ng.add_hunger_data('petz:chicken_legs', {
satiates = 1.0,
})
end

View File

@ -504,7 +504,24 @@ minetest.register_craft({
--Halloween Update
minetest.register_node("petz:jack_o_lantern", {
if minetest.get_modpath("farming") ~= nil and farming.mod == "redo" then
minetest.register_alias("petz:jack_o_lantern", "farming:jackolantern")
minetest.register_craft({
type = "shapeless",
output = "petz:jack_o_lantern",
recipe = {"farming:pumpkin", "petz:beeswax_candle"},
})
minetest.register_craft({
type = "shapeless",
output = "petz:jack_o_lantern",
recipe = {"farming:pumpkin", "default:torch"},
})
else
minetest.register_node("petz:jack_o_lantern", {
description = S("Jack-o'-lantern"),
groups = { snappy=3, flammable=3, oddly_breakable_by_hand=2 },
sounds = default.node_sound_wood_defaults({
@ -520,19 +537,8 @@ minetest.register_node("petz:jack_o_lantern", {
"petz_jackolantern_right.png", "petz_jackolantern_left.png",
"petz_jackolantern_back.png", "petz_jackolantern_front.png"
},
})
if minetest.get_modpath("farming") ~= nil and farming.mod == "redo" then
minetest.register_craft({
type = "shapeless",
output = "petz:jack_o_lantern",
recipe = {"farming:pumpkin", "petz:beeswax_candle"},
})
minetest.register_craft({
type = "shapeless",
output = "petz:jack_o_lantern",
recipe = {"farming:pumpkin", "default:torch"},
})
})
end
if minetest.get_modpath("crops") ~= nil then

View File

@ -91,6 +91,9 @@ blood = false
colorize_punch = true
punch_color = #FF0000
##Tag Background
tag_background = false
##Smoke particles when die
death_effect = true

View File

@ -84,6 +84,12 @@ local settings_def = {
type = "number",
default = 1,
},
--Nametag Background
{
name = "tag_background",
type = "boolean",
default = false,
},
--Capture Mobs
{
name = "lasso",

View File

@ -1,8 +1,13 @@
-- internationalization boilerplate
local S = minetest.get_translator(minetest.get_current_modname())
local translator = minetest.get_translator
local S = translator and translator("signs") or function(s) return s end
local vadd = vector.add
local floor, pi = math.floor, math.pi
local vadd = vector.add
local objects_inside_radius = minetest.get_objects_inside_radius
local b = "blank.png"
-- Cyrillic transliteration library
local slugify = dofile(minetest.get_modpath("signs") .. "/slugify.lua")
local sign_positions = {
[0] = {{x = 0, y = 0.18, z = -0.07}, pi},
@ -18,7 +23,6 @@ local wall_sign_positions = {
[3] = {{x = 0, y = -0.005, z = -0.43}, 0}
}
local function generate_sign_line_texture(str, row)
local leftover = floor((20 - #str) * 16 / 2) or 0
local texture = ""
@ -51,17 +55,19 @@ local function find_any(str, pair, start)
end
end
end
return ret
end
local disposable_chars = {["\n"] = true, ["\r"] = true, ["\t"] = true, [" "] = true}
local wrap_chars = {"\n", "\r", "\t", " ", "-", "/", ";", ":", ","}
local slugify = dofile(minetest.get_modpath("signs") .. "/slugify.lua")
local disposable_chars = {
["\n"] = true, ["\r"] = true, ["\t"] = true, [" "] = true
}
local wrap_chars = {
"\n", "\r", "\t", " ", "-", "/", ";", ":", ",", ".", "?", "!"
}
local function generate_sign_texture(str)
if not str then
return "blank.png"
end
local row = 0
local texture = "[combine:" .. 16 * 20 .. "x100"
local result = {}
@ -98,7 +104,8 @@ local function generate_sign_texture(str)
end
if not disposable_chars[str:sub(wrap_i, wrap_i)] then
keep_i = wrap_i
elseif wrap_i > 1 and not disposable_chars[str:sub(wrap_i - 1, wrap_i - 1)] then
elseif wrap_i > 1 and
not disposable_chars[str:sub(wrap_i - 1, wrap_i - 1)] then
keep_i = wrap_i - 1
end
end
@ -137,44 +144,105 @@ end
minetest.register_entity("signs:sign_text", {
visual = "upright_sprite",
textures = {"blank.png", "blank.png"},
visual_size = {x = 0.7, y = 0.6},
collisionbox = {0},
pointable = false,
on_activate = function(self, staticdata)
on_activate = function(self)
local ent = self.object
local pos = ent:get_pos()
-- remove entity for missing sign
local node = minetest.get_node_or_nil(ent:get_pos())
if not node or not (node.name == "signs:sign" or node.name == "signs:wall_sign") then
local node_name = minetest.get_node(pos).name
if node_name ~= "signs:sign" and
node_name ~= "signs:wall_sign" then
ent:remove()
return
end
local meta = minetest.get_meta(pos)
local meta_texture = meta:get_string("sign_texture")
local texture
if meta_texture and meta_texture ~= "" then
texture = meta_texture
else
local meta_text = meta:get_string("sign_text")
if meta_text and meta_text ~= "" then
texture = generate_sign_texture(meta_text)
else
texture = b
end
meta:set_string("sign_texture", texture)
end
ent:set_properties({
textures = {generate_sign_texture(staticdata), "blank.png"}
textures = {texture, b}
})
end,
get_staticdata = function(self)
local meta = minetest.get_meta(self.object:get_pos())
local text = meta:get_string("sign_text") or ""
return text
end
})
local function place(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local under = pointed_thing.under
local node = minetest.get_node(under)
local node_def = minetest.registered_nodes[node.name]
if node_def and node_def.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return node_def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local undery = pointed_thing.under.y
local posy = pointed_thing.above.y
local _, result
if undery < posy then -- Floor sign
itemstack, result = minetest.item_place(itemstack,
placer, pointed_thing)
elseif undery == posy then -- Wall sign
_, result = minetest.item_place(ItemStack("signs:wall_sign"),
placer, pointed_thing)
if result and not
minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
end
if result then
minetest.sound_play({name = "default_place_node_hard"},
{pos = pointed_thing.above})
end
end
return itemstack
end
local function destruct(pos)
for _, obj in pairs(objects_inside_radius(pos, 0.5)) do
local ent = obj:get_luaentity()
if ent and ent.name == "signs:sign_text" then
obj:remove()
end
end
end
local function check_text(pos)
local meta = minetest.get_meta(pos)
local text = meta:get_string("sign_text")
local objects = objects_inside_radius(pos, 0.5)
if text and text ~= "" then
local found = false
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
local count = 0
for _, obj in pairs(objects) do
local ent = obj:get_luaentity()
if ent and ent.name == "signs:sign_text" then
found = true
break
count = count + 1
if count > 1 then
obj:remove()
end
end
end
if not found then
if count == 0 then
local node = minetest.get_node(pos)
local p2 = node.param2 or -1
local sign_pos = sign_positions
@ -183,54 +251,74 @@ local function check_text(pos)
sign_pos = wall_sign_positions
end
if p2 > 3 or p2 < 0 then return end
local obj = minetest.add_entity(vadd(pos,
sign_pos[p2][1]), "signs:sign_text")
obj:set_properties({
textures = {generate_sign_texture(text), "blank.png"}
})
local obj = minetest.add_entity(
vadd(pos, sign_pos[p2][1]), "signs:sign_text")
obj:set_yaw(sign_pos[p2][2])
end
end
end
minetest.register_lbm({
label = "Check for sign text",
name = "signs:sign_text",
nodenames = {"signs:sign", "signs:wall_sign"},
run_at_every_load = true,
action = check_text
})
local function construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[5,3]" ..
"textarea[1.35,0.5;2.9,1.5;Dtext;" .. S("Enter your text")..":" .. ";${sign_text}]" ..
"button_exit[1.06,1.65;2.9,1;;" .. S("Save") .. "]")
end
local function destruct(pos)
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
local ent = obj:get_luaentity()
if ent and ent.name == "signs:sign_text" then
obj:remove()
else
for _, obj in pairs(objects) do
local ent = obj:get_luaentity()
if ent and ent.name == "signs:sign_text" then
obj:remove()
end
end
end
-- Remove old on_construct fs
local fs = meta:get_string("formspec")
if fs and fs ~= "" then
meta:set_string("")
end
end
local function receive_fields(pos, _, fields, sender, wall)
if not fields.Dtext then return end
if minetest.is_protected(pos, sender:get_player_name()) then
local function edit_text(pos, _, clicker)
local player_name = clicker:get_player_name()
if minetest.is_protected(pos, player_name) then
return
end
local p2 = minetest.get_node(pos).param2
local text = minetest.get_meta(pos):get_string("sign_text")
local edit_fs = "size[5,3]" ..
"textarea[1.15,0.3;3.3,2;Dtext;" .. S("Enter your text:") ..
";" .. text .. "]" ..
"button_exit[0.85,2;3.3,1;;" .. S("Save") .. "]" ..
"field[0,0;0,0;spos;;" .. minetest.pos_to_string(pos) .. "]"
minetest.show_formspec(player_name, "signs:edit_text", edit_fs)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "signs:edit_text" then
return
end
local text = fields.Dtext
local pos = fields.spos and minetest.string_to_pos(fields.spos)
if not text or not pos then
return
end
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local node = minetest.get_node(pos)
local p2 = node.param2
local sign_pos = sign_positions
if wall then
if node.name:find("wall") then
p2 = p2 - 2
sign_pos = wall_sign_positions
end
if not p2 or p2 > 3 or p2 < 0 then return end
if not p2 or p2 > 3 or p2 < 0 then
return
end
local sign
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
for _, obj in pairs(objects_inside_radius(pos, 0.5)) do
local ent = obj:get_luaentity()
if ent and ent.name == "signs:sign_text" then
sign = obj
@ -238,22 +326,39 @@ local function receive_fields(pos, _, fields, sender, wall)
end
end
if not sign then
sign = minetest.add_entity(vadd(pos,
sign_pos[p2][1]), "signs:sign_text")
sign = minetest.add_entity(
vadd(pos, sign_pos[p2][1]), "signs:sign_text")
else
sign:set_pos(vadd(pos, sign_pos[p2][1]))
end
sign:set_properties({
textures = {generate_sign_texture(fields.Dtext), "blank.png"}
})
sign:set_yaw(sign_pos[p2][2])
local meta = minetest.get_meta(pos)
meta:set_string("sign_text", fields.Dtext)
meta:set_string("infotext", fields.Dtext)
end
if not sign then
return
end
local texture = b
if text ~= "" then
-- Serialization longer values may cause a crash
-- because we are serializing the texture too
text = text:sub(1, 256)
texture = generate_sign_texture(text)
sign:set_properties({
textures = {texture, b}
})
end
sign:set_yaw(sign_pos[p2][2])
local meta = minetest.get_meta(pos)
meta:set_string("sign_text", text)
meta:set_string("sign_texture", texture)
meta:set_string("infotext", text)
end)
-- Sign nodes
minetest.register_node("signs:sign", {
description = S("Sign"),
description = S"Sign",
tiles = {"signs_wood.png"},
drawtype = "nodebox",
paramtype = "light",
@ -269,46 +374,10 @@ minetest.register_node("signs:sign", {
},
groups = {oddly_breakable_by_hand = 1, choppy = 3, attached_node = 1},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local under = pointed_thing.under
local node = minetest.get_node(under)
local node_def = minetest.registered_nodes[node.name]
if node_def and node_def.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return node_def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local undery = pointed_thing.under.y
local posy = pointed_thing.above.y
local _, result
if undery < posy then -- Floor sign
itemstack, result = minetest.item_place(itemstack,
placer, pointed_thing)
elseif undery == posy then -- Wall sign
_, result = minetest.item_place(ItemStack("signs:wall_sign"),
placer, pointed_thing)
if result and not (creative and creative.is_enabled_for and
creative.is_enabled_for(placer)) then
itemstack:take_item()
end
end
if result then
minetest.sound_play({name = "default_place_node_hard", gain = 1},
{pos = pointed_thing.above})
end
end
return itemstack
end,
on_construct = construct,
on_place = place,
on_destruct = destruct,
on_punch = check_text,
on_receive_fields = receive_fields
on_rightclick = edit_text
})
minetest.register_node("signs:wall_sign", {
@ -325,15 +394,12 @@ minetest.register_node("signs:wall_sign", {
groups = {oddly_breakable_by_hand = 1, choppy = 3,
not_in_creative_inventory = 1, attached_node = 1},
on_construct = construct,
on_destruct = destruct,
on_punch = check_text,
on_receive_fields = function(pos, _, fields, sender)
receive_fields(pos, _, fields, sender, true)
end
on_rightclick = edit_text
})
-- Craft
minetest.register_craft({
output = "signs:sign 3",
recipe = {
@ -348,3 +414,12 @@ minetest.register_craft({
recipe = "signs:sign",
burntime = 10
})
-- LBM for restoring text
minetest.register_lbm({
label = "Check for sign text",
name = "signs:sign_text",
nodenames = {"signs:sign", "signs:wall_sign"},
run_at_every_load = true,
action = check_text
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B