Post your modding questions here

Nyarg
Member
Posts: 276
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Post

ulla wrote:
ulla wrote:... now i need a little help for add simple function sit or lay on_rightclick ,
but I found nothing on internet,
some help?
Find like here may be useful )
Spoiler
Image
I am a noob. still yet. Not so noob ) [vml] WIP and a little proof for fun PlantedTorch )))
MT Strike 78a36b468554d101e0be3b0d1f587a555f396452 Great! Somebody have found it )
"My english isn't well" I know. I'm sorry )

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

ulla wrote:
ulla wrote:Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english
some help?

Code: Select all

--state=true: lay, state=false: stand up
local function lay_down(player, pos, state)
	local name = player:get_player_name()
	if not player or not name then
		return
	end

	-- stand up
	if state ~= nil and not state then

		-- physics, eye_offset, etc
		player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
		player:set_look_yaw(math.random(1, 180) / 100)
		default.player_attached[name] = false
		player:set_physics_override(1, 1, 1)
		default.player_set_animation(player, "stand" , 30)

	-- lay down
	else
		player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
		local yaw, param2 = get_look_yaw(bed_pos)
		player:set_look_yaw(yaw) <you still need to implement that function that tells you in which direction the player should look when laying>
		local dir = minetest.facedir_to_dir(param2)
		local p = <position where the lay-thing is>
		player:set_physics_override(0, 0, 0)
		player:setpos(p)
		default.player_attached[name] = true
		default.player_set_animation(player, "lay" , 0) --that does the trick with laying the player down
	end
end
These are the relevant lines from beds mod. You need to add some stuff yourself.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

pithy wrote:
ManElevation wrote:how do you make a mod topic
You can only post in the WIP mods section.
read that post:
viewtopic.php?f=11&t=1271
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Post

Is it possible to have a node that consists of two blocks each referencing their own textures? e.g. a jar that is x1=-4,y1=-8,z1=-4,x2=4,y2=2,z2=4 and is like the drawtype glasslike, with an inside that is x1=-3,y1=-7,z1=-3,x2=3,y2=1,z2=3 and is like the drawtype liquid (using NodeBoxEditor hence the 16x16x16 coords)? Or would the inherent nature of NodeBox make it not work?

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Post your modding questions here

by kaeza » Post

Icalasari wrote:Is it possible to have a node that consists of two blocks each referencing their own textures? e.g. a jar that is x1=-4,y1=-8,z1=-4,x2=4,y2=2,z2=4 and is like the drawtype glasslike, with an inside that is x1=-3,y1=-7,z1=-3,x2=3,y2=1,z2=3 and is like the drawtype liquid (using NodeBoxEditor hence the 16x16x16 coords)? Or would the inherent nature of NodeBox make it not work?
If you want that kind of "complex" shape, you will need to create a model for it using e.g. Blender, and use the "mesh" drawtype.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
Desour
Member
Posts: 1473
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Post your modding questions here

by Desour » Post

ulla wrote:
ulla wrote:Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english
some help?
you could make something like

Code: Select all

on_right_click = function(clicker)
if sitter then
sitter:set_animation(stand)
else
sitter = clicker
sitter:set_animation(sit)
end
end
(its not really correct, i think...)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
ulla
Member
Posts: 143
Joined: Wed Feb 04, 2015 09:22
GitHub: IIIullaIII
IRC: ulla
In-game: ulla

Re: Post your modding questions here

by ulla » Post

orwell wrote:
ulla wrote:
ulla wrote:Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english
some help?

Code: Select all

--state=true: lay, state=false: stand up
local function lay_down(player, pos, state)
	local name = player:get_player_name()
	if not player or not name then
		return
	end

	-- stand up
	if state ~= nil and not state then

		-- physics, eye_offset, etc
		player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
		player:set_look_yaw(math.random(1, 180) / 100)
		default.player_attached[name] = false
		player:set_physics_override(1, 1, 1)
		default.player_set_animation(player, "stand" , 30)

	-- lay down
	else
		player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
		local yaw, param2 = get_look_yaw(bed_pos)
		player:set_look_yaw(yaw) <you still need to implement that function that tells you in which direction the player should look when laying>
		local dir = minetest.facedir_to_dir(param2)
		local p = <position where the lay-thing is>
		player:set_physics_override(0, 0, 0)
		player:setpos(p)
		default.player_attached[name] = true
		default.player_set_animation(player, "lay" , 0) --that does the trick with laying the player down
	end
end
These are the relevant lines from beds mod. You need to add some stuff yourself.
TY but how i use whit on_rightclick?
X4cna2d4UqsiawIzUumDgPoYNx3JLGII

User avatar
ulla
Member
Posts: 143
Joined: Wed Feb 04, 2015 09:22
GitHub: IIIullaIII
IRC: ulla
In-game: ulla

Re: Post your modding questions here

by ulla » Post

Nyarg wrote:
ulla wrote:
ulla wrote:... now i need a little help for add simple function sit or lay on_rightclick ,
but I found nothing on internet,
some help?
Find like here may be useful )
Spoiler
Image
TY
on_rightclick is used only in entity? i have a node ,need register entity?
X4cna2d4UqsiawIzUumDgPoYNx3JLGII

zing269
Member
Posts: 109
Joined: Sat Apr 30, 2016 19:10

Re: Post your modding questions here

by zing269 » Post

ulla wrote:
ulla wrote:Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english
some help?
Sokomine's Cottages mod, viewtopic.php?id=5120, has a bench and a couple of beds that allow sitting or laying on right click.

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Post

Well I'm starting to get the hang of things (decided to leave meshwork for later and go a different style route for the node), but I hit a snag

Can nodeboxes have animated textures? Because I tried, with this being the intended result

Instead I got this jar of nope (which I am definitely going to recreate - Planning on two focuses that would split into mod packs, one being a magic and potions mod pack)

Trying to figure out where I went horribly, horribly wrong. Can somebody look at it and see where things are glitching out, please?

Code: Select all

minetest.register_node("mindeca_bugs:firefly_jar", {
	description = "Firefly in a Jar",
	light_source = 5,
	tiles = {
		{
			name = {"mindeca_firefly_top.png",
			"mindeca_firefly_bottom.png",
			"mindeca_firefly_side_animated.png",
			"mindeca_firefly_side_animated.png",
			"mindeca_firefly_side_animated.png",
			"mindeca_firefly_side_animated.png"},
			animation = {
				type = "vertical_frames",
				aspect_w = 16,
				aspect_h = 16,
				length = 2.0,
				},
		},
	},
	drawtype = "nodebox",
	paramtype = "light",
	sunlight_propogates = true,
	groups = {dig_immediate = 3, falling_node = 1},
	node_box = {
		type = "fixed",
		fixed = {
			{-0.1875, -0.5, -0.1875, 0.1875, 0.4375, 0.1875}, -- Central
			{-0.25, -0.4375, -0.25, 0.25, 0.0625, 0.25}, -- Middle
			{-0.3125, -0.375, -0.3125, 0.3125, -0.0625, 0.3125}, -- Edge
			{-0.25, 0.25, -0.25, 0.25, 0.375, 0.25}, -- Cork
		}
	},
	selection_box = {
		type = "fixed",
			fixed = {-0.3125, -0.5, -0.3125, 0.3125, 0.4375, 0.3125},
	}
})

User avatar
Desour
Member
Posts: 1473
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Post your modding questions here

by Desour » Post

@Icalasari:
you have to do it like this:

Code: Select all

minetest.register_node("mindeca_bugs:firefly_jar", {
       description = "Firefly in a Jar",
       light_source = 5,
       tiles = {
		  "mindeca_firefly_top.png",
		  "mindeca_firefly_bottom.png",
		  {
             name = "mindeca_firefly_side_animated.png",
             animation = {
                type = "vertical_frames",
                aspect_w = 16,
                aspect_h = 16,
                length = 2.0,
			          },
                  },
       },
       drawtype = "nodebox",
       paramtype = "light",
       sunlight_propogates = true,
       groups = {dig_immediate = 3, falling_node = 1},
       node_box = {
          type = "fixed",
          fixed = {
             {-0.1875, -0.5, -0.1875, 0.1875, 0.4375, 0.1875}, -- Central
             {-0.25, -0.4375, -0.25, 0.25, 0.0625, 0.25}, -- Middle
             {-0.3125, -0.375, -0.3125, 0.3125, -0.0625, 0.3125}, -- Edge
             {-0.25, 0.25, -0.25, 0.25, 0.375, 0.25}, -- Cork
          }
       },
       selection_box = {
          type = "fixed",
             fixed = {-0.3125, -0.5, -0.3125, 0.3125, 0.4375, 0.3125},
       }
})
ps: nice texture!
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Post

@DS-mintest

Thanks - Still wondering how it screwed up the texture to that degree. Glad to also find out I can cut repeating that three additional times for the same texture

And also thanks on the compliment - I used to do a lot of sprite art, and got a lot of practice when I did the Harvestmooncraft texture pack. Trying a cel shaded style to go with these mods I'm making

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Post

Is there a way to include more information in the tooltip? Looking it up seems to point to no, but I could be missing something

User avatar
AccidentallyRhine
Member
Posts: 252
Joined: Sun Aug 02, 2015 05:43

Re: Post your modding questions here

by AccidentallyRhine » Post

How do you register a tool (sword) and give it an on_use function without overriding it's original function as a sword?

User avatar
D00Med
Member
Posts: 949
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med
Location: Australia...somewhere

Re: Post your modding questions here

by D00Med » Post

^I'm interested to learn that too
Look! I have a signature :]
My subgame: viewtopic.php?f=15&t=14051#p207242

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your modding questions here

by azekill_DIABLO » Post

look at farming mod: the hoe does same.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
BirgitLachner
Member
Posts: 393
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Post

I have two questions:

1.) Where do I get all the name of the default object from? Where do I have to look?

2.) Any hint how to use an object like a bucket? I only found a group for a filled bucket.

red-001
Member
Posts: 205
Joined: Tue Jan 26, 2016 20:15
GitHub: red-001
IRC: red-001

Re: Post your modding questions here

by red-001 » Post

BirgitLachner wrote:I have two questions:

1.) Where do I get all the name of the default object from? Where do I have to look?

2.) Any hint how to use an object like a bucket? I only found a group for a filled bucket.
1. default object?
2. take a look at https://github.com/minetest/minetest_ga ... t/init.lua

User avatar
BirgitLachner
Member
Posts: 393
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Post

Ah, yes ... a "s" is missing. I mean default-objects, like stone, sand ...

PlanetKiller
Member
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Post

Since I got help here with my air rosin, I thought I'd post the finished code for everyone; as a thanks.

Code: Select all


--matblox tools
-- should clear out nodes without crashing
-- no guarantee
-- use as you see fit.
minetest.register_tool("matblox:air_rod", {
	description = "Air Rosin",
	inventory_image = "matblox_air_rod.png",

	on_use = function(itemstack, user, pointed_thing)
		if pointed_thing.under then -- check if it is a node/exists (needed)
		
			-- keep this low, the bigger the # the longer the loop
			local final = 3 -- size of area to delete (+-3 in all directions)
			
			local target = minetest.get_node(pointed_thing.under) -- target node to delete
			local pos = pointed_thing.under -- position of pointed node, centralizes the love
			-- triple direction pos/neg loop
			for a=-final,final,1 do
				for b=-final,final,1 do
					for c=-final,final,1 do
						-- target node to delete
						local newnode = minetest.get_node({x = pos.x+a, y = pos.y+b, z = pos.z+c})
						-- I only want this to delete target nodes
						if target.name == newnode.name then
							-- swaps the node with air
							minetest.remove_node({x = pos.x+a, y = pos.y+b, z = pos.z+c})
						end	
					end
				end
			end
		end
	end-- so many ends, the plot thickens.
})
I've tested that it works, just need an image and a mod folder. It clears out nodes nicely, great for deleting forests. Haven't packaged it into a mod because I'm working on a modpack with scripts for specific things. I'm sure you guys are smart enough to either use it, or learn from it.

Questions:
I have a node that gives copper lumps when right-clicked, unless you are holding copper lumps. What would cause that to happen?
How would I drop an item stack entity that could be picked up?
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")

Havocado
New member
Posts: 2
Joined: Tue Oct 04, 2016 21:04

Re: Post your modding questions here

by Havocado » Post

Is there a way to make an item that drops itself when broken by hand, but drops a different item when broken with the proper tool?

PlanetKiller
Member
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Post

Havocado wrote:Is there a way to make an item that drops itself when broken by hand, but drops a different item when broken with the proper tool?
use get_wielded_item()

if it = a specific item, drop one item
else, drop another.

Not sure how it would exactly work, but that's the best I can find with my skill.

Trying it, but getting errors.

Code: Select all

on_dig = function(pos, node, digger)
	print(digger)
	print(digger.get_wielded_item(digger).name)
end
Tends to either print nil or userdata: 0x00f84510
Tried using .name and .get_name and several crashy variations.
(the block keeps reloading when I break it, but I'm missing a drop so...)
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: Post your modding questions here

by taikedz » Post

PlanetKiller wrote:Since I got help here with my air rosin, I thought I'd post the finished code for everyone; as a thanks.

I've tested that it works, just need an image and a mod folder. It clears out nodes nicely, great for deleting forests.
I know I am late to this.... but I think you might have just wanted one of the default minetest functions 'minetest.get_nodes_in_area": http://dev.minetest.net/minetest.find_nodes_in_area

I actually made a similar tool which I use for clearing large swathes... and it's very useful for putting out fires that have spread over a forest area for a while....

https://github.com/taikedz/vivarium/blob/master/staffmagic/init.lua#L335-L351

User avatar
everamzah
Member
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Post

Havocado wrote:Is there a way to make an item that drops itself when broken by hand, but drops a different item when broken with the proper tool?
minetest.handle_node_drops

If the node is what you want, parse the drops and give to player appropriate item per currently wielded item? (get_wielded_item)

User avatar
everamzah
Member
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Post

AnxiousInfusion wrote:How do you register a tool (sword) and give it an on_use function without overriding it's original function as a sword?
If I remember correctly, this is not possible. I only say that because I tried it myself first, before giving up and using minetest.register_on_dignode instead. In my mind, I would think it possible, but cannot imagine how.

Edit: I think I meant minetest.register_on_punchnode!

Edit2: I assume only defining on_use would be a problem, and that on_secondary_use, or on_rightclick can be used instead, if that would suit your needs.

Locked

Who is online

Users browsing this forum: No registered users and 7 guests