Re: Post your modding questions here
Posted: Mon Jan 25, 2016 15:13
Is there a tutorial for creating textures for mods? What program is used usually, gimp?
The official Minetest discussion board
https://forum.minetest.net/
the original furnace is bad, it doesn't work when the chunk isn't loaded, same for farmingeveramzah wrote:The original furnace does not use a node timer, so why should Dragonop's claycrafter? I'd like to also point out that in minetest_game there are only two nodes which use node timers: Bones, and TNT. In my experience they are not always reliable.
I'm not an expert on animation - but I've been playing around with the mob code for some time - so I think I can explain it:Merlin wrote:Hi,
I would like to add more animations to the animation table of PilzAdam's Simple Mobs (like the walk and stand animations).
I looked into the code of the API, but as it is not commented I have difficulties understanding what's going on.
Can anyone explain to me how I would go about adding new animations?
Code: Select all
mob.animation = {
[animation_name]_start = [number],
[animation_name]_end = [number],
[animation_name]_speed = [number],
}
Code: Select all
if self.state == "walk" then
--do walking stuff
self:set_animation("walk")
elseif self.state == "running" then
--do running stuff
self:set_animation("running")
elseif self.state == "multiple_actions" then
if [action 1 happening] then
--do action 1 stuff
self:set_animation("action1")
elseif [action 2 happening] then
--do action 2 stuff
self:set_animation("action2")
end
end
Code: Select all
self.set_animaition = function(self,type)
--if no animations defined return
if not self.animations then
return
end
--if no current animation is set, this is probably an error - so set a place holder value
if not self.animation.current then
self.animation.current = ""
end
--set the animation
--check the current animation is not the same
if self.animation.current ~= type then
--check that all values required to set animation exist
if
self.animation[ type .. "_start"]
and self.animation[ type .. "_end"]
and self.animation[ type .. "speed"]
then
--set the animation - this is the Minetest API Objectref method :set_animation
self.object:set_animation(
{x=self.animation[type .. "_start"] , y=self.animation[type .. "_end"]},
self.animation[type .. "_speed"],
0 --animation blend value is hard-coded to 0 - IDK why, ask pilzadam
)
--set current animation tracking variable to this animation name
self.animation.current = type
end
end
end
Code: Select all
if self.state = [state] then
--some boring default stuff
if my_condition then
--do my awesome stuff
self:set_animation("awesome_animation")
else
--do more boring default stuff
self:set_animation("walk")
end
end
Code: Select all
elseif type == "pick" and self.animation.current ~= "pick" then
if
self.animation.pick_start
and self.animation.pick_end
and self.animation.speed_normal
then
self.object:set_animation(
{x=self.animation.pick_start,y=self.animation.pick_end},
self.animation.speed_normal, 0
)
self.animation.current = "pick"
end
Code: Select all
if self.state == "stand" then
if math.random(1, 4) == 1 then
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
end
self.set_velocity(self, 0)
self.set_animation(self, "stand")
if math.random(1, 100) <= 50 then
self.set_velocity(self, self.walk_velocity)
self.state = "walk"
self.set_animation(self, "walk")
elseif math.random(1, 100) >= 60 then
self.set_velocity(self, 0)
self.state = "pick"
self.set_animation(self, "pick")
end
Code: Select all
elseif self.state == "pick" then
if math.random(1, 100) <= 30 then
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi))
end
self:set_animation("pick")
self.set_velocity(self, 0)
if math.random(1, 100) >= 10 then
self.set_velocity(self, 0)
self.state = "stand"
self:set_animation("stand")
end
Code: Select all
animation = {
speed_normal = 15,
stand_start = 0,
stand_end = 33,
walk_start = 50,
walk_end = 62,
pick_start = 34,
pick_end = 42,
}
Code: Select all
minetest.setting_set("name", "value")
Code: Select all
waypoint = {
hud_elem_type = "waypoint",
name = "My pos",
number = "0x000000",
world_pos = {x=0,y=0,z=0}
}
player:hud_add(waypoint)
...
player:hud_remove(waypoint)
The hud_add method returns an HUD id. So you can doBrunoMine wrote:About method:He did not keep the values set after a server shutdown.Code: Select all
minetest.setting_set("name", "value")
What the correct way to remove an element HUD?The above example does not remove the HUD of the waypoint.Code: Select all
waypoint = { hud_elem_type = "waypoint", name = "My pos", number = "0x000000", world_pos = {x=0,y=0,z=0} } player:hud_add(waypoint) ... player:hud_remove(waypoint)
Another question: how to know the id of an element of HUD?
Code: Select all
local id = player:hud_add(hud_def)
...
player:hud_remove(id)
Code: Select all
hit_node = function(self, pos, node)
local num = math.random(1, 10)
if num == 1 then
pos.y = pos.y + 1
local nod = minetest.get_node_or_nil(pos)
if not nod
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
local mob = minetest.add_entity(pos, "mobs:chicken")
local ent2 = mob:get_luaentity()
mob:set_properties({
textures = ent2.child_texture[1],
visual_size = {
x = ent2.base_size.x / 2,
y = ent2.base_size.y / 2
},
collisionbox = {
ent2.base_colbox[1] / 2,
ent2.base_colbox[2] / 2,
ent2.base_colbox[3] / 2,
ent2.base_colbox[4] / 2,
ent2.base_colbox[5] / 2,
ent2.base_colbox[6] / 2
},
})
ent2.child = true
ent2.tamed = true
ent2.owner = self.playername
end
Code: Select all
minetest.setting_set("name", "value")
l'd prefer a minetest.save_settings().TenPlus1 wrote:using /set -n <name> <value> does the same sadly, would be handy to have a -f in there to FORCE the setting and save to minetest.conf
Code: Select all
minetest.register_decoration({
deco_type = "simple",
decoration = "huntandgather:rock",
place_on = {
"default:stone",
},
y_min = -32000,
y_max = 32000
})
Code: Select all
minetest.register_decoration({
deco_type = "simple",
decoration = "default:stick",
place_on = {
"default:dirt",
"default:dirt_with_grass",
"default:dirt_with_grass_footsteps",
"default:dirt_with_dry_grass",
"default:dirt_with_snow",
},
biomes = {
"coniferous_forest",
"deciduous_forest",
"rainforest",
"rainforest_swamp",
"savanna",
"taiga"
}
})
Code: Select all
minetest.register_on_generated(function(minp, maxp)
-- place stones between -30 and -3000
if minp.y > -30 or maxp.y < -3000 then
return
end
-- place them on top of coal blocks
local coal = minetest.find_nodes_in_area_under_air(minp, maxp, "default:stone_with_coal")
local bpos
for n = 1, #coal do
bpos = {x = coal[n].x, y = coal[n].y + 1, z = coal[n].z }
-- not on all coal blocks, only 1 in every 8
if math.random(1, 8) == 1 then
minetest.set_node(bpos, {name = "yourmod:stone"})
end
end
end)