Somehow forgot to split everything into smaller commits.

This commit is contained in:
IamPyu 2024-12-24 17:56:48 -06:00
parent 3d1c5b947a
commit 1dc7e818df
23 changed files with 87 additions and 36 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## [Dec 23rd - STILL UNDER DEVELOPMENT] So far unnamed update
Game Changes:
- Hunger timer is now reset when food is eaten and hunger is set to 20.
## [Dec 22nd] Unnamed Minor Update
Game Changes:

View File

@ -126,7 +126,7 @@ core.register_on_dieplayer(function(player, reason)
elseif newreason.type == "starvation" then
message = string.format("%s starved to death", playername)
elseif newreason.type == "shot" then
message = string.format("%s was shot by %s", newreason.objname)
message = string.format("%s was shot by %s", playername, newreason.objname)
end
elseif reason.type == "node_damage" then
local desc = core.registered_nodes[reason.node].description or "a block"

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -48,6 +48,7 @@ PyuTest.get_nearest_entity = function(entity, pos, range, only_player, dont_igno
end
local class = {
_name = "Entity",
_last_hp = 0,
_heal_timer = 0,
_attack_timer = 0,
@ -211,7 +212,7 @@ function class:on_step(dtime, moveresult)
self._last_hp = self.object:get_hp()
end
PyuTest.make_mob = function(name, properties, options)
PyuTest.make_mob = function(id, name, properties, options)
local default_options = {
max_jump = 1,
max_drop = 8,
@ -249,7 +250,7 @@ PyuTest.make_mob = function(name, properties, options)
local collisionbox = properties.collisionbox or PyuTest.HUMAN_LIKE_CBOX
core.register_entity(name, setmetatable({
core.register_entity(id, setmetatable({
initial_properties = PyuTest.util.tableconcat(properties, {
hp_max = properties.hp_max or 20,
physical = true,
@ -260,5 +261,6 @@ PyuTest.make_mob = function(name, properties, options)
infotext = "",
}),
_options = cfg,
_name = name,
}, { __index = class }))
end

View File

@ -1,14 +1,13 @@
local modpath = core.get_modpath("pyutest_entities")
dofile(modpath .. "/api.lua")
PyuTest.make_mob("pyutest_entities:test_follower", {
PyuTest.make_mob("pyutest_entities:test_follower", "Test Follower", {
visual = "upright_sprite",
visual_size = { x = 1, y = 2 },
makes_footstep_sound = true,
textures = {
"pyutest-monster.png", "pyutest-monster_back.png"
},
nametag = "Test Follower",
}, {
follow_player = true,
max_jump = 1,
@ -20,14 +19,13 @@ PyuTest.make_mob("pyutest_entities:test_follower", {
}
})
PyuTest.make_mob("pyutest_entities:monster", {
PyuTest.make_mob("pyutest_entities:monster", "Monster", {
visual = "upright_sprite",
visual_size = { x = 1, y = 2 },
makes_footstep_sound = true,
textures = {
"pyutest-monster.png", "pyutest-monster_back.png"
},
nametag = "Monster",
}, {
follow_player = true,
hit_damage = 3,
@ -45,14 +43,13 @@ PyuTest.make_mob("pyutest_entities:monster", {
attack_type = "melee",
})
PyuTest.make_mob("pyutest_entities:dummy", {
PyuTest.make_mob("pyutest_entities:dummy", "Dummy", {
visual = "upright_sprite",
visual_size = { x = 1, y = 2 },
makes_footstep_sound = true,
textures = {
"player.png", "player_back.png"
},
nametag = "Dummy",
}, {
drops = {
"pyutest_tools:apple 3",
@ -62,14 +59,13 @@ PyuTest.make_mob("pyutest_entities:dummy", {
}
})
PyuTest.make_mob("pyutest_entities:item_follower", {
PyuTest.make_mob("pyutest_entities:item_follower", "Item Follower", {
visual = "upright_sprite",
visual_size = { x = 1, y = 2 },
makes_footstep_sound = true,
textures = {
"player.png^[brighten", "player_back.png^[brighten"
},
nametag = "Item Follower",
}, {
drops = {},
follow_items = {
@ -77,12 +73,11 @@ PyuTest.make_mob("pyutest_entities:item_follower", {
}
})
PyuTest.make_mob("pyutest_entities:pig", {
PyuTest.make_mob("pyutest_entities:pig", "Pig", {
hp_max = 10,
visual = "upright_sprite",
visual_size = {x = 1, y = 1},
textures = {"pyutest-pig.png", "pyutest-pig-back.png"},
nametag = "Pig",
collisionbox = PyuTest.SMALL_ANIMAL_CBOX,
}, {
drops = {

View File

@ -16,7 +16,6 @@ mobs:register_arrow("pyutest_mobs:arrow_necroball", {
local num_minions = math.random(2, 3)
local minions = {
"pyutest_mobs:monster",
"pyutest_mobs:mimic"
}
local m = minions[math.random(#minions)]
@ -39,8 +38,8 @@ mobs:register_arrow("pyutest_mobs:arrow_necroball", {
mobs:register_mob("pyutest_mobs:necromancer", {
type = "monster",
hp_max = 125,
hp_min = 125,
hp_max = 925,
hp_min = 925,
walk_velocity = 2,
run_velocity = 4,
armor = 100,

View File

@ -22,8 +22,8 @@ mobs:register_arrow("pyutest_mobs:arrow_snowball", {
mobs:register_mob("pyutest_mobs:snowman", {
type = "monster",
hp_max = 150,
hp_min = 150,
hp_max = 1500,
hp_min = 1500,
walk_velocity = 1,
run_velocity = 4,
armor = 100,

View File

@ -25,8 +25,8 @@ mobs:register_arrow("pyutest_mobs:arrow_windball", {
mobs:register_mob("pyutest_mobs:wind_warrior", {
type = "monster",
hp_max = 120,
hp_min = 120,
hp_max = 1250,
hp_min = 1250,
walk_velocity = 1,
run_velocity = 4,
armor = 100,

View File

@ -68,7 +68,7 @@ PyuTest.shoot_projectile_from_object = function(name, object, velocity)
local projectile = core.add_entity(pos, name)
projectile:set_velocity(vector.multiply(dir, pvel))
projectile:set_rotation(dir)
projectile:set_rotation(object:get_look_dir())
projectile:get_luaentity()._owner = object
return projectile

View File

@ -13,6 +13,7 @@ PyuTest.make_stairs = function(name, desc, craftitem, texture, groups, extra)
sounds = PyuTest.make_node_sounds(),
paramtype = "light",
paramtype2 = "colorfacedir",
drop = ItemStack(name):to_string(),
drawtype = "nodebox",
node_box = PyuTest.NODE_BOXES.STAIRS,
@ -29,6 +30,7 @@ PyuTest.make_stairs = function(name, desc, craftitem, texture, groups, extra)
sounds = PyuTest.make_node_sounds(),
paramtype = "light",
paramtype2 = "colorfacedir",
drop = ItemStack(id_inner):to_string(),
drawtype = "nodebox",
node_box = {
@ -52,6 +54,7 @@ PyuTest.make_stairs = function(name, desc, craftitem, texture, groups, extra)
sounds = PyuTest.make_node_sounds(),
paramtype = "light",
paramtype2 = "colorfacedir",
drop = ItemStack(id_outer):to_string(),
drawtype = "nodebox",
node_box = {

View File

@ -42,7 +42,8 @@ PyuTest.make_node("pyutest_blocks:grass", "Grass", {
tiles = {"pyutest-grass-top.png", {name = "pyutest-dirt.png", color = "white"}},
overlay_tiles = {"pyutest-grass-top.png", "blank.png", "pyutest-grass-side.png"},
is_ground_content = true,
on_construct = on_construct("pyutest_blocks:grass")
on_construct = on_construct("pyutest_blocks:grass"),
drop = ItemStack("pyutest_blocks:grass"):to_string(),
})
local function make_plant_drops(name)
@ -53,7 +54,14 @@ local function make_plant_drops(name)
tool_groups = {
"shears"
},
items = { name }
items = { ItemStack(name):to_string() }
},
{
rarity = 3,
items = {
"pyutest_farming:wheat_seeds"
}
}
}
}

View File

@ -25,6 +25,33 @@ PyuTest.make_item("pyutest_farming:hoe", "Hoe", {
end
})
local function water_nearby(pos)
local range = 5
local function is_water(name)
return core.get_item_group(name, "water") ~= 0
end
local result = false
for x = -range, range do
for z = -range, range do
local p1 = vector.new(pos.x + x, pos.y, pos.z + z)
local p2 = vector.new(pos.x + x, pos.y - 1, pos.z + z)
local n1 = core.get_node(p1).name
local n2 = core.get_node(p2).name
if is_water(n1) or is_water(n2) then
result = true
break
end
end
end
return result
end
PyuTest.make_crop = function(name, desc, output, growtime, water_multiplier, textures, grow_into)
local t = textures or {}
@ -47,7 +74,7 @@ PyuTest.make_crop = function(name, desc, output, growtime, water_multiplier, tex
on_construct = function(pos)
local time = growtime
if PyuTest.node_beside_group(pos - vector.new(0, 1, 0), "water") then
if water_nearby(pos) then
time = time * (water_multiplier or 0.5)
end

View File

@ -91,6 +91,7 @@ PyuTest.make_node("pyutest_flowers:lilypad", "Lily Pad", {
PyuTest.make_node("pyutest_flowers:sugarcane", "Sugarcane", {
oddly_breakable_by_hand = PyuTest.BLOCK_FAST,
snappy = PyuTest.BLOCK_FAST,
dig_immediate = 1,
}, { "pyutest-sugarcane.png" }, {
drawtype = "plantlike",

View File

@ -76,9 +76,7 @@ local function on_receive_fields(pos, formname, fields, player)
inv:add_item("dst", output)
src:take_item()
fuel:take_item()
inv:set_stack("src", 1, src)
inv:set_stack("fuel", 1, fuel)
end
end

View File

@ -27,7 +27,7 @@ PyuTest.make_potion("pyutest_potions:low_gravity", "Low Gravity Potion", {
effect = "low_gravity",
multiplier = 0.25,
length = 30,
craft = "pyutest_tools:snowball"
craft = "pyutest_magic:windball"
})
PyuTest.make_potion("pyutest_potions:instant_damage", "Instant Damage Potion", {
@ -38,7 +38,7 @@ PyuTest.make_potion("pyutest_potions:instant_damage", "Instant Damage Potion", {
action_splash = function (object)
PyuTest.deal_damage(object, 6, PyuTest.DAMAGE_TYPES.magic())
end,
craft = "pyutest_tools:stone_sword"
craft = "pyutest_tools:bone"
})
PyuTest.make_potion("pyutest_potions:instant_health", "Instant Health Potion", {
@ -48,5 +48,6 @@ PyuTest.make_potion("pyutest_potions:instant_health", "Instant Health Potion", {
end,
action_splash = function (object)
PyuTest.deal_damage(object, -6, PyuTest.DAMAGE_TYPES.magic())
end
end,
craft = "pyutest_tools:golden_apple"
})

View File

@ -64,8 +64,7 @@ core.register_chatcommand("teleport", {
description = "Teleport <player> to <x> <y> <z>",
privs = {teleport = true},
func = function(name, param)
local found, _, player, x, y, z = PyuTest.parse_command_functions(name, param)
:find("^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+([^%s]+)$")
local found, _, player, x, y, z = param:find("^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+([^%s]+)$")
if found == nil then
core.chat_send_player(name, "Invalid usage: " .. param)

View File

@ -82,13 +82,12 @@ end)
core.register_chatcommand("effect", {
params = "add|remove <player> <effect> <time> <multiplier>",
description = "Add or Remove <effect> from <player>",
privs = {give = 1},
func = function (name, param)
local split = param:split(" ")
core.log(#split)
if #split < 3 then
core.chat_send_player(name, "Invalid syntax: " .. param)
return
return false, "Invalid syntax: " .. param
end
local option = split[1]

View File

@ -3,6 +3,7 @@ PyuTest.HUNGER_RUNOUT = 200
local storage = core.get_mod_storage()
local hungers = core.deserialize(storage:get("player_hungers")) or {}
local timers = {}
PyuTest.hunger_multiplier = function(player, x)
hungers[player].multiplier = x
@ -26,8 +27,11 @@ PyuTest.hunger_add = function (player, points)
end
local p = hungers[player].hunger + points
if p > PyuTest.HUNGER_MAX then
if p >= PyuTest.HUNGER_MAX then
p = PyuTest.HUNGER_MAX
-- set to -50 to mimic saturation, player wont get hunger for a while.
timers[player].hunger = -50
end
hungers[player].hunger = p
@ -63,7 +67,6 @@ if not core.settings:get_bool("enable_damage", true) then
return
end
local timers = {}
core.register_globalstep(function (dtime)
for i, p in pairs(core.get_connected_players()) do
local name = p:get_player_name()

View File

@ -23,6 +23,15 @@ core.register_on_joinplayer(function(player)
},
})
player:set_properties({
mesh = "character.b3d",
textures = {"character.png"},
visual = "mesh",
visual_size = {x = 1, y = 1, z = 1},
stepheight = 0.6,
eye_height = 1.47
})
-- creative mode privs
if core.is_creative_enabled(name) then
core.set_player_privs(name, PyuTest.util.tableconcat({