Its a small world... help requested

Post Reply
MisterE
Member
Posts: 102
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Its a small world... help requested

by MisterE » Post

Hi, I m trying to revive this idea:
viewtopic.php?f=49&t=22602

I have scaled the player model, physics, the eyeheight, the collisionbox, prevented fall damage somewhat, etc

I would like help scaling other things. If you know a way to do any of these things, please post. And yes, as it says in the old forum, The goal is to increase node density in order to have more detail in the world.

I am calling the game that will be made from it, "Its a Small World"
----
Its my impression that most, if not all of these problems have a solution, the trick is finding and implementing.

I do not know how to add "reach" to the player's tools. Currently the player cannot touch his toes, (or the blocks under them). How do I give the player more reach?

I saw that in the default:creative mod,

Code: Select all

	minetest.override_item("", {
		range = 60,
		tool_capabilities = {
			full_punch_interval = 0.5,
			max_drop_level = 3,
			groupcaps = {
				crumbly = caps,
				cracky  = caps,
				snappy  = caps,
				choppy  = caps,
				oddly_breakable_by_hand = caps,
				-- dig_immediate group doesn't use value 1. Value 3 is instant dig
				dig_immediate =
					{times = {[2] = digtime, [3] = 0}, uses = 0, maxlevel = 256},
			},
			damage_groups = {fleshy = 10},
		}
	})
end
here, the hand is given a larger range

Unfortunately, overriding the hand doesnt seem to work. Here is my modified version of init.lua on the player api mod:

Code: Select all

-- player/init.lua

dofile(minetest.get_modpath("player_api") .. "/api.lua")

-- Default player appearance
player_api.register_model("character.b3d", {
	animation_speed = 30,
	textures = {"character.png", },
	animations = {
		-- Standard animations.
		stand     = {x = 0,   y = 79},
		lay       = {x = 162, y = 166},
		walk      = {x = 168, y = 187},
		mine      = {x = 189, y = 198},
		walk_mine = {x = 200, y = 219},
		sit       = {x = 81,  y = 160},
	},
	collisionbox = {-0.9, 0.0, -0.9, 0.9, 5.1, 0.9},
	stepheight = 1.8,
	eye_height = 4.5,
})

-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
	player_api.player_attached[player:get_player_name()] = false
	player_api.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_physics_override({
		jump = 1.8,
	})
end)


-------------------
-- decrease default fall damage for the increased physics
local fall_damage_scalar = 1/3

minetest.register_on_player_hpchange(function(player, hp_change, reason)
    if reason.type == "fall" then
			local hp = hp_change * fall_damage_scalar
      if hp < 1.4 then
        return 0
      else
        return hp
      end
		else
			return hp_change
		end

  end, true)

-- increase hand range
	minetest.override_item("", {
		range = 20,
	})
it doesnt seem to work though. Any suggestions?

Ok, another thing is trees. how do I make them taller, and wider. I don't have any experience there, so help is much appreciated.

User avatar
Krock
Developer
Posts: 4562
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Its a small world... help requested

by Krock » Post

The hand problem
Check whether there are any other places that override the hand, for example the "creative" mod. Override the hand inside an minetest.register_on_mods_loaded callback so that you don't need to modify more mods than needed.

Trees
You need to differentiate between mapgen-generated trees and sapling growth. Former defines schematics as mapgen decorations (see "default/mapgen.lua"), latter allows dynamic selection of width and height of the trees: trees.lua

You can either modify this function, or all its caller functions to increase sapling-grown tree sizes.
For mapgen-generated trees, you might want to use WorldEdit to export schematics or create them manually.

Further insights
AFAIK "moretrees" registers saplings as mapgen decoration which are then replaced by full trees afterwards. This method is less efficient but provides more freedom for tree generation. Possibly interesting Lua API entry: "L-system trees"
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

MisterE
Member
Posts: 102
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: Its a small world... help requested

by MisterE » Post

Thanks for this. The hand range problem is fixed. Now, the problem with getting hurt when falling.

I have this code in player_api/init.lua

Code: Select all

local fall_damage_scalar = 1/3
minetest.register_on_player_hpchange(function(player, hp_change, reason)
    if reason.type == "fall" then
			local hp = hp_change * fall_damage_scalar
      if hp < 1.4 then
        return 0
      else
        return hp
      end
		else
			return hp_change
		end

  end, true)

This makes it so that you don't get hurt from "falls" made from just jumping (x3), however the players still gets the red flash, even though their hitpoint change is 0. how can we disable the red flash for this? Preferable, we do not disable the red flash, but make the determination of whether to show the red flash based on the final calculation of damage, and if it is zero, then dont show it. Is there some type of callback

Code: Select all

register_before_player_hpchange
?

MisterE
Member
Posts: 102
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: Its a small world... help requested

by MisterE » Post

Edit: Fixed with:

Code: Select all



minetest.register_on_mods_loaded(
function()
	-- override hand range
	minetest.override_item("", {range = 20})
	-- make nodes not hurt so much when you fall on them
	for node,def in pairs(minetest.registered_nodes) do
		local node_groups = minetest.registered_nodes[node][groups] or {}-- get the groups entry from the node definition
		node_groups.fall_damage_add_percent = -66 -- add the fall damage percent group
		minetest.override_item(node,{groups = node_groups }) --change the node definition
	end
end
)
**double edit: oops that didnt work, now all the groups are gone and you cant dig anything :)

Now I have:

Code: Select all

local function get_nodedef_field(nodename, fieldname)
    if not minetest.registered_nodes[nodename] then
        return nil
    end
    return minetest.registered_nodes[nodename][fieldname]
end

minetest.register_on_mods_loaded(
function()
	-- override hand range
	minetest.override_item("", {range = 20})
	-- make nodes not hurt so much when you fall on them
	for node,def in pairs(minetest.registered_nodes) do
		local node_name = node.name
		local node_groups = get_nodedef_field(node_name,"groups") or {}
		node_groups.fall_damage_add_percent = -66 -- add the fall damage percent group
		minetest.override_item(node,{groups = node_groups }) --change the node definition
	end
end

)
but for some reason it still does not save the old info from each node's groups, so all original group data is erased. WHY!?


EDIT#3 GOT IT!!!

I was trying to pull the name field from the index in the registered_nodes table. Instead, I had to pull the name from the def info. So, here is the code that works:

Code: Select all

local function get_nodedef_field(nodename, fieldname)
    if not minetest.registered_nodes[nodename] then
        return nil
    end
    return minetest.registered_nodes[nodename][fieldname]
end

minetest.register_on_mods_loaded(
function()
	-- override hand range
	minetest.override_item("", {range = 20})
	-- make nodes not hurt so much when you fall on them
	for node,def in pairs(minetest.registered_nodes) do
		local node_name = def.name
		local node_groups = get_nodedef_field(node_name,"groups") or {}
		node_groups.fall_damage_add_percent = -66 -- add the fall damage percent group
		minetest.override_item(node_name,{groups = node_groups }) --change the node definition
	end

end


MisterE
Member
Posts: 102
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: Its a small world... help requested

by MisterE » Post

In case anyone is interested, here are my changes to player_api/init.lua
no changes are needed to minetest.conf

Code: Select all

-- player/init.lua

dofile(minetest.get_modpath("player_api") .. "/api.lua")

-- Default player appearance
player_api.register_model("character.b3d", {
	animation_speed = 30,
	textures = {"character.png", },
	animations = {
		-- Standard animations.
		stand     = {x = 0,   y = 79},
		lay       = {x = 162, y = 166},
		walk      = {x = 168, y = 187},
		mine      = {x = 189, y = 198},
		walk_mine = {x = 200, y = 219},
		sit       = {x = 81,  y = 160},
	},
	collisionbox = {-0.9, 0.0, -0.9, 0.9, 5.1, 0.9},
	stepheight = 1.8,
	eye_height = 4.5,
})

-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
	player_api.player_attached[player:get_player_name()] = false
	player_api.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_physics_override({
		jump = 3,
		gravity = 3,
	})
end)

local function get_nodedef_field(nodename, fieldname)
    if not minetest.registered_nodes[nodename] then
        return nil
    end
    return minetest.registered_nodes[nodename][fieldname]
end

minetest.register_on_mods_loaded(
function()
	-- override hand range
	minetest.override_item("", {range = 20})
	-- make nodes not hurt so much when you fall on them
	for node,def in pairs(minetest.registered_nodes) do
		local node_name = def.name
		local node_groups = get_nodedef_field(node_name,"groups") or {}
		node_groups.fall_damage_add_percent = -66 -- add the fall damage percent group
		minetest.override_item(node_name,{groups = node_groups }) --change the node definition
	end

end

)


you do still have to scale the player model and hitbox. I will post the game as soon as I have something worthwhile to show. Now I will look at the trees.

MisterE
Member
Posts: 102
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: Its a small world... help requested

by MisterE » Post

I made a item that shrinks you when you drink it (Drink me) and another that enlarges you again (eat me). The normal size is still 3x larger but you can get small again, temporarily :) I may add smaller and larger sizes, but the world is set up for 3x scale

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests