[Mod] Mobs Redo [1.61] [mobs]

Gibeinumo
Member
Posts: 30
Joined: Tue Oct 23, 2018 07:19

Re: [Mod] Mobs Redo [1.50] [mobs]

by Gibeinumo » Post

Hi,
I am trying to set the texture within on_spawn, but I can't figure out how to access the variable. I tried the following:

Code: Select all

on_spawn=function(self)                                                                 
    self.object:get_luaentity().base_texture="texture.png"             
    self.base_texture="texture.png"                                    
    self.object.base_texture="texture.png"    
end
How do I access the texture of a mob?

edit:
I found the answer in the modding book by rubenwardy (^_^). I need to use set_properties on self.object.

Code: Select all

on_spawn=function(self)   
    self.object:set_properties({textures={"texture.png"}})
end

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

check out the mobs_monster and especially the spider. lua file, gives you a good example of texture handling.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: [Mod] Mobs Redo [1.50] [mobs]

by Stix » Post

Ive been trying to edit a mob so that it beaches correctly when on land, however when trying to get the objects position minetest crashes complaining that get_pos() returns nil, which would mean that self doesn't exist.... but ive put the code in the do_custom function that has "self" as one of the callbacks. Any help?

Relevant code:

Code: Select all

do_custom = function(self, dtime)
		local pos = self:get_pos()
		pos.y = pos.y - 1
		if pos ~= self.fly_in then
			self.type = "animal"
			self.passive = true
			self.walk_velocity = 0
			self.run_velocity = 0
        	        self.view_range = 0
        	        self.walk_chance = 0
        	        self.animation = animation_beached
			self.pushable = true
			return
		end
	end,
(Please ignore the wrong indentation of some variables, the minetest forums are screwing up indentation and no matter what i do i cant get it to come out right)
Hey, what can i say? I'm the bad guy.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by duane » Post

Stix wrote:when trying to get the objects position minetest crashes complaining that get_pos() returns nil
The exact error would have been more helpful, but I suspect you want "self.object:get_pos()". The game ObjectRef is stored as object.
Believe in people and you don't need to believe anything else.

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: [Mod] Mobs Redo [1.50] [mobs]

by Stix » Post

duane wrote:
Stix wrote:when trying to get the objects position minetest crashes complaining that get_pos() returns nil
The exact error would have been more helpful, but I suspect you want "self.object:get_pos()". The game ObjectRef is stored as object.
Thanks duane! for some reason i thought self was the object, not a table holding the object :)

Ten:

Im not sure if this is a bug or a limitation of the api but ive now gotten the beaching to work... somewhat.
I understand that the mob def table is run every server tick for updates (or at least for the do_custom() function) And using some minetest.chat_send_all()'s and dump's seems to confirm that. My problem is however that The mobs stats arent always overrided along with the new animation being set when it gets beached. My if statement turns true every time they are beached, which means the assignement statements within should always run, but the dont, at least not always. Generally if the mob swims on to the shore itself it becomes properly beached, but if I knock it onto land or spawn it there it generally doesnt become beached. And if i restart the game some mobs that wouldnt beach become beached and some beached mobs become un-beached. Any idea what the problem is? (*note that i dont get any errors with the code im using)

Relavant code:

Code: Select all

-- Aquatic Mobs get beached
	do_custom = function(self, dtime)
		local pos = self.object:get_pos()
		pos.y = pos.y - 1
		local node = minetest.get_node_or_nil(pos)
		print(dump(node))
		if node and self.standing_in ~= self.fly_in and node.name ~= self.fly_in then
			minetest.chat_send_all("True")
			if self.type ~= "animal" then
				self.type = "animal"
			end
			if self.passive ~= true then
				self.passive = true
			end
			if self.walk_velocity ~= 0 then
				self.walk_velocity = 0
			end
			if self.run_velocity ~= 0 then
				self.run_velocity = 0
			end
			if self.view_range ~= 0 then
				self.view_range = 0
			end
			if self.walk_chance ~= 0 then
				self.walk_chance = 0
			end
			if self.pushable ~= true then
				self.pushable = true
			end
			if self.animation ~= animation_beached then
				self.animation = animation_beached
			end
			return
		elseif self.standing_in == self.fly_in then
			self.type = "monster"
			self.passive = false
			self.walk_velocity = 1
			self.run_velocity = 3
			self.view_range = 4
			self.walk_chance = 100
			self.animation = animation_swimming
			self.pushable = false
			return
		end
Last edited by Stix on Tue Aug 13, 2019 11:38, edited 1 time in total.
Hey, what can i say? I'm the bad guy.

Gibeinumo
Member
Posts: 30
Joined: Tue Oct 23, 2018 07:19

Re: [Mod] Mobs Redo [1.50] [mobs]

by Gibeinumo » Post

I was going through warnings and noticed that you are using a deprecated function. You possibly want to change it.

Code: Select all

2019-08-12 18:10:26: WARNING[Server]: Call to deprecated function 'settexturemod', please use 'set_texture_mod' at ...o/.minetest/games/endless_dungeon/mods/mobs_redo/api.lua:2240
2019-08-12 18:10:32: WARNING[Server]: Call to deprecated function 'settexturemod', please use 'set_texture_mod' at ...o/.minetest/games/endless_dungeon/mods/mobs_redo/api.lua:2212

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

Thanks for finding that one Gibeinumo, mobs redo api has been updated :)

User avatar
ElCeejo
Member
Posts: 210
Joined: Thu Feb 28, 2019 23:29
GitHub: ElCeejo
In-game: ElCeejo
Location: Your Mother's house

Re: [Mod] Mobs Redo [1.50] [mobs]

by ElCeejo » Post

Not sure if I'm just missing something but it would seem that the do_punch function doesn't have any effect if the mob is punched by another mob.

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

the custom do_punch is one of the first function checks when a mob is hit: https://notabug.org/TenPlus1/mobs_redo/ ... .lua#L2600

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: [Mod] Mobs Redo [1.50] [mobs]

by Stix » Post

I found an issue with the mobs redo api: When baby mobs grow up they are supposed to jump up to prevent them getting stuck inside blocks, however this doesnt always work first try, especially with bigger mobs, so i was thinking perhaps there could be a check for adults (or all mobs in general if wanted) to see if their feet are inside a solid node, and if so, make them jump. the get_pos() function however returns the pos of the middle of the entity, so i wrote a simple calculation to get the feet pos for a mobs api im currently working on, feel free to use it:

Code: Select all

if minetest.get_node_or_nil(self.object:get_pos()) ~= nil then
        local height = (math.abs(self.initial_properties.collisionbox[2] - self.initial_properties.collisionbox[5]) / 2)
        local temp_pos = self.object:get_pos()
        temp_pos.y = temp_pos.y - height
        local def = minetest.get_node_or_nil(temp_pos)
        mob.standing_in = def
        mob.standing_in.def = minetest.registered_nodes[def.name]
        mob.standing_in.pos = temp_pos
    end

    return self
Hey, what can i say? I'm the bad guy.

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Update...

by TenPlus1 » Post

- Mobs jump if standing inside a solid block to escape :)

Note: Thanks Stix for telling me about the glitch.

User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: [Mod] Mobs Redo [1.50] [mobs]

by Steamed_Punk » Post

Hi TenPlus1

This isn't a bug, but i have an issue with the cow mob.
I haven't been around long and I'm learning as i go.. Minetest..., Lua..., Blender are all new to me, gimp also but for around 4 months now.
Since I discovered minetest, i have almost finished the default texture pack at 256x256 and as a break from working images i started taking a look at modding. I have built a couple of things so far, one thing led to another and my mod idea is getting bigger every hour or so. To take thing further and based on a tutorial i saw, can't find it now, i used a mob as an example to try and modify it. All's well so far. Then i decided to build a new mesh for it and here's the hick.
My mesh looks like a tiny beetle running around my feet and i can't see how or where i am supposed to scale it up.
Within blender everything is the right size although just short of the 3 block radius (i believe i have read correctly 3 max?)
The mob i have tried to learn with and modify is the mob_cow.x This was a real pig (cow) to get converted and into blender to have a look but it was sat on it's rear end, bones are there but no animation. I straight built a new mesh (not yet animated) and saved it as .b3d.
Is there something i should do, or is it impossible/very hard to replace the cow.x with a newmesh.b3d at the right scale.
regards
The sky is not the limit - It's my playground

User avatar
v-rob
Developer
Posts: 970
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: [Mod] Mobs Redo [1.50] [mobs]

by v-rob » Post

Actually, meshes in Minetest have to be 10 times bigger when used on entities (don't ask me why), so scale it up by a factor of 10 and it should work.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

User avatar
Steamed_Punk
Member
Posts: 156
Joined: Sat Aug 10, 2019 13:31
GitHub: steamed-punk

Re: [Mod] Mobs Redo [1.50] [mobs]

by Steamed_Punk » Post

Excellent v-rob that did the trick, thanks man. I've been scratching my head for an hour or so. I just have to make this thing walk and eat like the cow now, I can model almost anything anyone wants, but have never had the need to animate in all my years. LOST! yeah you could say that.
I'll stop here so as to not mess up the thread.
Thanks.again
The sky is not the limit - It's my playground

poskaf
New member
Posts: 2
Joined: Mon Sep 02, 2019 06:17

Re: [Mod] Mobs Redo [1.50] [mobs]

by poskaf » Post

Hello, dear developer. Installed it yesterday myself, your mod "Mobs Redo v1.5".
At the approach of the mob in the night, when the mob attack, the server is crashing and gives an error.

Server 5.0.0.1

Code: Select all

2019-09-02 09:08:40: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '*builtin*' in callback luaentity_Step(): Runtime error from mod '*builtin*' in callback on_punchplayer(): /usr/share/minetest/builtin/game/knockback.lua:45: attempt to call method 'add_p
2019-09-02 09:08:40: ERROR[Main]: layer_velocity' (a nil value)
2019-09-02 09:08:40: ERROR[Main]: stack traceback:
2019-09-02 09:08:40: ERROR[Main]: 	/usr/share/minetest/builtin/game/knockback.lua:45: in function </usr/share/minetest/builtin/game/knockback.lua:25>
2019-09-02 09:08:40: ERROR[Main]: 	/usr/share/minetest/builtin/game/register.lua:417: in function </usr/share/minetest/builtin/game/register.lua:401>
2019-09-02 09:08:40: ERROR[Main]: 	[C]: in function 'punch'
2019-09-02 09:08:40: ERROR[Main]: 	...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:2442: in function 'do_states'
2019-09-02 09:08:40: ERROR[Main]: 	...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:3249: in function <...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:3104>
2019-09-02 09:08:40: ERROR[Main]: stack traceback:
2019-09-02 09:08:40: ERROR[Main]: 	[C]: in function 'punch'
2019-09-02 09:08:40: ERROR[Main]: 	...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:2442: in function 'do_states'
2019-09-02 09:08:40: ERROR[Main]: 	...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:3249: in function <...hare/minetest/games/minetest_game/mods/mobs_redo/api.lua:3104>

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

the error looks like its dealing with the new dev release of Minetest and the player knockback feature, not an actual error with the mob api. I'll look into it and see why it happpens though.

poskaf
New member
Posts: 2
Joined: Mon Sep 02, 2019 06:17

Re: [Mod] Mobs Redo [1.50] [mobs]

by poskaf » Post

Installed the mod '*builtin*' from the stable version. The mistake was gone. SOLVED.

DragonSheen
New member
Posts: 2
Joined: Tue Sep 03, 2019 12:54

Re: [Mod] Mobs Redo [1.50] [mobs]

by DragonSheen » Post

Please forgive our inexperience. We run a small server for a few family's worth of kids to play on together and they have been asking for animals. We got Mobs Redo installed with the mobs_animal, mobs_npc and mobs_horse and are testing it before rolling it out to the kids. We've figured most everything out so far (the previous links to documentation provided earlier in this thread don't seem to be working anymore) by reading this thread and some trial and error, but we have not been able to solve the Protection Runes. They visually look like they work, but even after I give one to an animal and the white 'sparkles' come out, my husband can still kill it, for example. So far we're stumped, can you help us out?

If you need details, we're running 0.4.16 in a world that used v6 generator and so far the only other mods we have installed are craftguide, homedecor_modpack, travelnet and moreblocks.

Thanks for any tips!

auouymous
Member
Posts: 195
Joined: Sun Dec 07, 2014 09:39
GitHub: auouymous
IRC: air
In-game: auouymous

Re: [Mod] Mobs Redo [1.50] [mobs]

by auouymous » Post

DragonSheen wrote:my husband can still kill it
The rune only protects the mob while inside a protected area (protector mod).

DragonSheen
New member
Posts: 2
Joined: Tue Sep 03, 2019 12:54

Re: [Mod] Mobs Redo [1.50] [mobs]

by DragonSheen » Post

I'll look into the Protector mod if we wish to use that part then, thanks for the info!

MoNTE48
Member
Posts: 323
Joined: Sat Apr 06, 2013 11:58
GitHub: MoNTE48
In-game: MoNTE48
Location: Internet

Re: [Mod] Mobs Redo [1.50] [mobs]

by MoNTE48 » Post

For a long time I have my fork mobs_redo inside MultiCraft_game.
If TenPlus1 is interesting, I can make a PR of my changes. My formatting style is different (according to the Lua standard). However, perhaps there is something interesting here.
https://github.com/MultiCraft/MultiCraf ... do/api.lua

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

MoNTE48: Could you list the changes you have made and possible lines they are on and I will check and maybe add to current api :)

MoNTE48
Member
Posts: 323
Joined: Sat Apr 06, 2013 11:58
GitHub: MoNTE48
In-game: MoNTE48
Location: Internet

Re: [Mod] Mobs Redo [1.50] [mobs]

by MoNTE48 » Post

TenPlus1: Oh, that would be difficult :) I can do PR, and then you will say what to revert and what to accept. Or I can suggest you use Diff / WinMerge / your favorite utility for comparing code.

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mobs Redo [1.50] [mobs]

by TenPlus1 » Post

Okies :) look forward to seeing pull changes :P

MoNTE48
Member
Posts: 323
Joined: Sat Apr 06, 2013 11:58
GitHub: MoNTE48
In-game: MoNTE48
Location: Internet

Re: [Mod] Mobs Redo [1.50] [mobs]

by MoNTE48 » Post

TenPlus1 wrote:Okies :) look forward to seeing pull changes :P
Image
Attachments
111.png
111.png (43.86 KiB) Viewed 1193 times

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests