Post your modding questions here
- Glorfindel
- Member
- Posts: 137
- Joined: Tue Jul 07, 2015 20:05
- GitHub: the1glorfindel
- IRC: Glorfindel DoomWeaver
- In-game: Glorfindel
Re: Post your modding questions here
Is there a tutorial for creating textures for mods? What program is used usually, gimp?
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
- Hybrid Dog
- Member
- Posts: 2836
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
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.
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
Hybrid Dog: I will try but I don't think I want to do everything again.
Any suggestion when using timers? An example would help too, thanks btw.
Any suggestion when using timers? An example would help too, thanks btw.
- Hybrid Dog
- Member
- Posts: 2836
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
The conveyor_belt mod uses them: viewtopic.php?id=7350
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
Ah, I see, thanks Hybrid Dog. I'm in my way to rewrite my mod completely to make it "better", this will help.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
Does hp_max in the object properties table have any effect on players?
Every time a mod API is left undocumented, a koala dies.
Re: Post your modding questions here
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?
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?
- Hybrid Dog
- Member
- Posts: 2836
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
as far as l know the animations are in the model file
- qwertymine3
- Member
- Posts: 202
- Joined: Wed Jun 03, 2015 14:33
- GitHub: Qwertymine
- In-game: qwertymine3
Re: Post your modding questions here
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?
Spoiler
When registering a mob, you fill in the animation table:
These are the {x=[start],y=[end]} frame_speed=[speed] from the Objectref method :set_animation()
Code: Select all
mob.animation = {
[animation_name]_start = [number],
[animation_name]_end = [number],
[animation_name]_speed = [number],
}
Spoiler
Throughout the code Pilzadam uses a single function to set all of the animations. This is the set_animation() method which he adds to the mob def @ line 57.
This method is generally called in the code in this style (this is massively simplified though):
The method itself seems long - but this is just because it uses a set of hard-coded names for the possible animations. All it does is a check that the animation is not the currently playing one - and if this is a different animation, it finds the animation values defined by the user (it checks to see if the animation has been defined - to avoid errors).
Here is a generalised version
This method is generally called in the code in this style (this is massively simplified though):
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
Here is a generalised version
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
Spoiler
This all assumes you know how animations work in Minetest - they are all stored in the model file as time sections of the long single animation the model can have (AFAIK - I can't model so can't help you with this).
You can't really add meaningful animations without adding some new ones to the model - unless you wish to use a pre-defined animation and change the animation speed. e.g. run v walk
Currently every state or action a mob can take has an animation - if you want to add more animations to the code, you will need to add checks to make sure only one animation can be set at any given state.e.g.
To add the animation to mob.set_animation() you can copy the code from any of the elseif statements - changing every instance of the type name to your new animation.
You can't really add meaningful animations without adding some new ones to the model - unless you wish to use a pre-defined animation and change the animation speed. e.g. run v walk
Currently every state or action a mob can take has an animation - if you want to add more animations to the code, you will need to add checks to make sure only one animation can be set at any given state.e.g.
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
Avatar by :devnko-ennekappao:
Re: Post your modding questions here
That sounds good, I'll try playing around with it and come back if any more questions occur.
I can model and already adapted my own chicken model to the code which is already there, I just wish for more diversity.
I can model and already adapted my own chicken model to the code which is already there, I just wish for more diversity.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
When attaching an entity to another, how is the rotation argument formatted? Is it something like roll/pitch/yaw, or is it a direction vector?
Every time a mod API is left undocumented, a koala dies.
Re: Post your modding questions here
Hey, I tried out what qwertymine3 had suggested, and it worked (thanks a bunch!), I just have one last bug:
The animation (pick) I added plays two times in a row instead of just one, the bug does not exist in the model and therefor must be caused by the code.
Here are the snippets I changed:
I know that it can happen that, due to the math.random in the code above, the animation is executed two times (or more), which is fine by me, problem is, even when I set it to math.random(1, 100) >= 0 (which is always true), the animation plays two times.
The animation (pick) I added plays two times in a row instead of just one, the bug does not exist in the model and therefor must be caused by the code.
Here are the snippets I changed:
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,
}
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
I have two questions.
About method:
He did not keep the values set after a server shutdown.
What the correct way to remove an element HUD?
The above example does not remove the HUD of the waypoint.
Another question: how to know the id of an element of HUD?
Code: Select all
minetest.setting_set("name", "value")
What the correct way to remove an element HUD?
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?
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: I have two questions.
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)
Every time a mod API is left undocumented, a koala dies.
Re: Post your modding questions here
How do I make a mob randomly drop something (while the mob is still alive), or rather, how do I make a chicken lay an egg?
Re: Post your modding questions here
I don't quite get what this chunk of code does:
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
Re: Post your modding questions here
That piece of code is for throwing eggs, it picks a number from 1 to 10, if it's 1 then it checks the node above to see if it's free (air, grass etc) and spawns a chicken, then sets it's texture to that of a baby chick and halves it's size, sets it to child, sets tamed and owner name.
Congratulations: you have a the proud owner of a baby chicken :)
Congratulations: you have a the proud owner of a baby chicken :)
Re: Post your modding questions here
Looking through what mobs redo already offers, I think I'm going to base my mod on mobs redo rather than on simple mobs.
- BrunoMine
- Member
- Posts: 1082
- Joined: Thu Apr 25, 2013 17:29
- GitHub: BrunoMine
- Location: SP-Brasil
- Contact:
Save settings permanently
About method:
He did not keep the values set after a server shutdown.
We can save permanently?
Code: Select all
minetest.setting_set("name", "value")
We can save permanently?
Re: Post your modding questions here
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
- Hybrid Dog
- Member
- Posts: 2836
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
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
lt shouldn't be called forcing because force is too vague…
A -sd (save directly) option could mean saving it directly after the setting was set.
If you use lubuntu (or similar) and want to disable access to your disk, hit alt+print(+s)+u. l don't know if minetest crashes then, l only know that it doesn't start.
Re: Post your modding questions here
Topic: How do I make decorations appear underground (ex. in caves)
Why: I'm making a mod that tries to encourage exploration. There is one item, called a rock, which is very important for making some items.
More info:
My current code for spawning the rock is:
My other section of code for spawning sticks on the ground works just fine, however:
(i overrote the default stick to make it a node)
Basically, when I go into a cave, there are no rocks to be seen, and I dont know why.
Why: I'm making a mod that tries to encourage exploration. There is one item, called a rock, which is very important for making some items.
More info:
My current code for spawning the rock is:
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"
}
})
Basically, when I go into a cave, there are no rocks to be seen, and I dont know why.
Re: Post your modding questions here
Cave generation doesn't work like biome generation with decorations like grass, flowers and trees... you have to use on_generate to place decoration underground, like this:
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)
Who is online
Users browsing this forum: No registered users and 12 guests