Modding the cow

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

Modding the cow

by Steamed_Punk » Post

I am following a tutorial from the wiki, which explains how to mod a mod using the mobs as the lesson.
I am using the cow.
I have built a new .b3d mesh and textured it (learning blender on the go) and it shows perfectly in Minetest.
I am learning lua at the same time so it's a lot to take in and i am obviously missing bits and pieces along the way.

My new cow, which is in fact no longer a cow doesn't attack (dogfight) when i punch it. Apart from removing code concerning taming, feeding and milking everything is intact (and obvious name changing).

Does anyone know where i should be looking. Is this down to the fact that i haven't animated the thing yet. I can't see what i am missing. If i slap the old cow it definitely charges.

regards
The sky is not the limit - It's my playground

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Modding the cow

by Nathan.S » Post

If you spawn the cow with a spawn egg it won't attack you. You need to find a naturally spawned one, or spawn one with chat commands.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

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

Re: Modding the cow

by duane » Post

Without seeing your code, it's hard to say.
Believe in people and you don't need to believe anything else.

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

Re: Modding the cow

by TenPlus1 » Post

You can hold down sneak while spawning a cow using the spawn egg and it will spawn a natural cow with no owner :)

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

Re: Modding the cow

by Steamed_Punk » Post

Nathan.S wrote:If you spawn the cow with a spawn egg it won't attack you. You need to find a naturally spawned one, or spawn one with chat commands.
Haha, cool! We live and learn. I have also been watching your videos to learn, they are a great help, thanks for putting them up.
TenPlus1 wrote:You can hold down sneak while spawning a cow using the spawn egg and it will spawn a natural cow with no owner :)
That makes things easier while i am testing.


It works, the damn thing killed me! I will just have to play around with the settings, i have given it to much reach so it's not charging or following with wheat. I'll get there.

Thanks for the heads up.
The sky is not the limit - It's my playground

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

Re: Modding the cow

by Steamed_Punk » Post

EDIT:
I managed to solve the problem below, thanks to TenPlus1's API. Just misplaced characters.
https://notabug.org/TenPlus1/mobs_redo/ ... i.txt#L316
==================================================================================

I thought i had managed to solve this, but my lack of knowledge proves me wrong. I am trying to modify part of the cow code to stop it from following or being tamed, but each time i get minetest screaming errors at me or the model stops attacking as well. I just need it to graze and defend.

If someone has the time I'd appreciate a little help removing the correct parts..........

Code: Select all

	
	follow = {"farming:wheat", "default:grass_1"},
	view_range = 8,
	replace_rate = 10,
	replace_what = {
		{"group:grass", "air", 0},
		{"default:dirt_with_grass", "default:dirt", -1}
	},
	fear_height = 2,
	on_rightclick = function(self, clicker)

		-- feed or tame
		if mobs:feed_tame(self, clicker, 8, true, true) then

			-- if fed 7x wheat or grass then cow can be milked again
			if self.food and self.food > 6 then
				self.gotten = false
			end

			return
		end

		if mobs:protect(self, clicker) then return end
		if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end

		local tool = clicker:get_wielded_item()
		local name = clicker:get_player_name()

		-- milk cow with empty bucket
		if tool:get_name() == "bucket:bucket_empty" then

			--if self.gotten == true
			if self.child == true then
				return
			end

			if self.gotten == true then
				minetest.chat_send_player(name,
					S("Cow already milked!"))
				return
			end

			local inv = clicker:get_inventory()

			tool:take_item()
			clicker:set_wielded_item(tool)

			if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then
				clicker:get_inventory():add_item("main", "mobs:bucket_milk")
			else
				local pos = self.object:get_pos()
				pos.y = pos.y + 0.5
				minetest.add_item(pos, {name = "mobs:bucket_milk"})
			end

			self.gotten = true -- milked

			return
		end
	end,
	on_replace = function(self, pos, oldnode, newnode)

		self.food = (self.food or 0) + 1

		-- if cow replaces 8x grass then it can be milked again
		if self.food >= 8 then
			self.food = 0
			self.gotten = false
		end
	end,
})
regards
The sky is not the limit - It's my playground

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests