Post your modding questions here

sofar
Developer
Posts: 2132
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Post

petra2201 wrote:Topic: Where to put code for stairs.
Reason: I've made a mod for indestructible obsidian and my stairs keep blowing up.

In all my other nodes I can put code in the code block marked minetest.register_node.
However in stairs that codeblock is listed in an if else and no matter where I put my code in the code blocks my stairs keep blowing up. The rest of my nodes (block, door, glass) work great.
register your stair+slab nodes normally, then afterwards, use minetest.override_*() to attach an `on_blast()` callback handler that stops the explosion from breaking the stair node.

http://dev.minetest.net/minetest.register_node#on_blast

JackWilliam
Member
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Post

Topic: How can put a node on map?
Reason: I want to make a mod.
More Info: I tried, but I did not succeed. what should I do? I want to do add a node on the map and find it in a cave for example. As if it were a block of coal, stone, dirt etc. can you help me ?

User avatar
TenPlus1
Member
Posts: 2934
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Post

JackWilliam: look here for info on ore spawning: viewtopic.php?id=7013

JackWilliam
Member
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Post

TenPlus1 wrote:JackWilliam: look here for info on ore spawning: viewtopic.php?id=7013
thanks a lot TenPlus1, but I'm not looking for this, I want to create a new block in the map and when I'm in game I can find and mine it. As if it were a default block of the map that is generated when the map is loaded. How can I do that?

petra2201
Member
Posts: 30
Joined: Fri Jun 05, 2015 14:42

Re: Post your modding questions here

by petra2201 » Post

Thanks for the help on my explosion proof mod. Paramat helped me and I'm going to re-upload after giving him credit. I wish there was a way to limit damage past my blocks but that would require accessing the radius of the tnt mod but only in relation to my blocks. I'm not sure that's possible.

User avatar
cx384
Member
Posts: 504
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

I figured it out. :D
(sorry for the question)
+ Spoiler
Can your read this?

User avatar
GreenXenith
Member
Posts: 1335
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: Post your modding questions here

by GreenXenith » Post

Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

User avatar
GreenXenith
Member
Posts: 1335
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: Post your modding questions here

by GreenXenith » Post

Another question: How do I register an item as a dye? I have an item I want to register as a substitute for green dye that is included in ALL recipes for green dye. Such as {'mynode','wool:white'} makes green wool and {'mynode','dye:blue'} makes cyan dye and etc (all other dye combos)... How would I do this?
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

User avatar
GreenXenith
Member
Posts: 1335
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: Post your modding questions here

by GreenXenith » Post

Oh and here is another question: Where is the damage API stored? Where it defines when to use the hit sound and what to do when a player is hit? Where is that code? (I am using linux xubuntu).
EDIT: No longer need this.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

User avatar
orwell
Member
Posts: 859
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

GreenDimond wrote:Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?
You should ask in the Technic forum thread
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
GreenXenith
Member
Posts: 1335
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenXenith
In-game: GreenXenith
Location: The singularity
Contact:

Re: Post your modding questions here

by GreenXenith » Post

orwell wrote:
GreenDimond wrote:Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?
You should ask in the Technic forum thread
Will do.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenXenith#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.

User avatar
yzelast
Member
Posts: 54
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast
Location: Far Far Away

Re: Post your modding questions here

by yzelast » Post

Hi guys,i'm having a weird problem:my mod adds more tree leaves,and the leaves are using the same logic of the default.
the problem is that the leaves starts to fall for a few seconds,and the remaining stops to fall without reason.
it's doesn't make sense, so i had to create another abm to work around this issue but now the code is duplicated.
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

User avatar
Hybrid Dog
Member
Posts: 2775
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

by Hybrid Dog » Post

Do you mean your leaves fall like sand and gravel?
If so (l doubt it), remove falling=1 from the groups.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
yzelast
Member
Posts: 54
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast
Location: Far Far Away

Re: Post your modding questions here

by yzelast » Post

they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

Code: Select all

minetest.register_node("real_trees:small_leaves", {
	description = "Small Leaves",
	drawtype = "nodebox",
	paramtype = "light",
	paramtype2 = "facedir",
	groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
	sounds = default.node_sound_leaves_defaults(),
	drop =	{
		max_items = 1,
		items = {
				{items = {"default:sapling"},rarity = 160},
				{items = {'real_trees:small_leaves'}}
				}
			},

	tiles = {"default_leaves.png"},
	after_place_node = default.after_place_leaves,
	node_box = {type = "fixed", fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

User avatar
Semmett9
Member
Posts: 155
Joined: Sun Oct 07, 2012 13:48
Location: Gallifrey
Contact:

Reusable Function

by Semmett9 » Post

I was wondering if they is a way to call a function.

I have some code which on every on_click it places a note above it. The idea is to have a reusable function so that this code can be used more than once, and my different nodes.

so

Code: Select all

MAIN FUNCTION {
// code for node
send location of node and name to function 1
print function result 1
}

function 1 {
 // code
 return to main function 
}
thanks in advance

User avatar
DS-minetest
Member
Posts: 1149
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: DS-minetest
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 DS-minetest » Post

Eh, you need to use lua.
use -- instead of //
and eg.:

Code: Select all

local functionname = function(parameter)
-- code, eg.:
something = parameter
return something
end
mfunctionname = function(n)
-- code, eg.:
print(functionname("bla")..tostring(n))
end
So, "mfunction(1)" prints "bla1".
Note that I've recently renamed myself on github and co. to "Desour". (I'm bad at naming things.)
Feel free to call me DS.

KCoombes
Member
Posts: 412
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt
Location: SW Florida, USA

Re: Post your modding questions here

by KCoombes » Post

yzelast wrote:they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

-snip-,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
-snip-
leafdecay = 3 means the leaves in a 3x3 radius around default:tree (the wood) will fall if the wood is removed - leaves outside this radius will not fall
setting leafdecay higher can result in leaves from tree A being held in place by tree B

User avatar
yzelast
Member
Posts: 54
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast
Location: Far Far Away

Re: Post your modding questions here

by yzelast » Post

KCoombes wrote:
yzelast wrote:they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

-snip-,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
-snip-
leafdecay = 3 means the leaves in a 3x3 radius around default:tree (the wood) will fall if the wood is removed - leaves outside this radius will not fall
setting leafdecay higher can result in leaves from tree A being held in place by tree B
i will take a look, thanks
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

User avatar
yzelast
Member
Posts: 54
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast
Location: Far Far Away

Re: Post your modding questions here

by yzelast » Post

Hi guys,today i have a little question:
if i stop the node timer with the function stop(), what will happen with the elapsed time? Will i be able to get it with the function get_elapsed()?
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

User avatar
TumeniNodes
Member
Posts: 2879
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your modding questions here

by TumeniNodes » Post

can particles be added/activated to a node, for only during punch?
so they are only activated while the user is mining a node?
and if so..., can anyone point me to the basic code please, so I can screw it up? :D
Thank you
Ich mag keine grünen Eier und Schinken, ich mag sie nicht Sam I Am

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

Re: Post your modding questions here

by ulla » Post

HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev

Code: Select all

https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0
SEE first the README
X4cna2d4UqsiawIzUumDgPoYNx3JLGII

User avatar
orwell
Member
Posts: 859
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:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev

Code: Select all

https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0
SEE first the README
To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.

Code: Select all

minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)
Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:

Code: Select all

local contents_of_text_field = fields.<name of text field>
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
ulla
Member
Posts: 109
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:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev

Code: Select all

https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0
SEE first the README
To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.

Code: Select all

minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)
Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:

Code: Select all

local contents_of_text_field = fields.<name of text field>
TY for answer and sorry for my english is my first problem i need big time for understand english tutor/ial :-) and the guides for formspec are mutch inexplicative :-( (for me :-P) this is my code

Code: Select all

local function play_track(pos, track)
	return minetest.sound_play("juke_track_"..tostring(track),
			{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
end 
local function stop_player(pos, node)
	local pos_hash = minetest.hash_node_position(pos)
	local music_handle = music_handles[pos_hash]
	if music_handle then
		minetest.sound_stop(music_handle)
		music_handles[pos_hash] = nil
	end
end
-- Show form when the /formspec command is used.
minetest.register_chatcommand("juke", {
	func = function(name, param)
		minetest.show_formspec(name, "jukebox:form",
				"size[4.0,4.5]" ..
                "background[-0,-0;4,4.5;juke_bag.png]"..
             	"label[0,0;CIAO!!!, " .. name .. "]" ..
            	"field[0.3,2.5;4,1;ded;" .. name .. ", DEDICA;]" ..
                "button[1,0.3;2,1;stop;STOP!]"..
                "button[0,1;1,1;track_1;1]"..
                "button[1,1;1,1;track_2;2]"..
			    "button[2,1;1,1;track_3;3]"..
			    "button[3,1;1,1;track_4;4]"..
                "button[0,3;1,1;track_5;5]"..
                "button[1,3;1,1;track_6;6]"..
			    "button[2,3;1,1;track_7;7]"..
			    "button[3,3;1,1;track_8;8]"..
				"button_exit[1,3.7;2,1;exit;EXIT]")
                   end
	
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="jukebox:form" 
    
      
    local stop_player = 0  
    local " .. name .. ", DEDICA = fields.ded
	local juke_track = nil
		if fields.stop then juke_track = 0 end
		elseif fields.track_1 then juke_track_ = 1 end
		elseif fields.track_2 then juke_track_ = 2 end
		elseif fields.track_3 then juke_track = 3 end
		elseif fields.track_4 then juke_track = 4 end
		elseif fields.track_5 then juke_track = 5 end
		elseif fields.track_6 then juke_track = 6 end
		elseif fields.track_7 then juke_track = 7 end
		elseif fields.track_8 then juke_track = 8 end
		elseif fields.track_9 then juke_track = 9 end
		elseif ded then func = function(name, param)
		minetest.chat_send_all(field)
         end 		
      end 
   end
end       
)
help pls ty in advance
X4cna2d4UqsiawIzUumDgPoYNx3JLGII

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

Re: Post your modding questions here

by ulla » Post

ulla wrote:
orwell wrote:
ulla wrote:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev

Code: Select all

https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0
SEE first the README
To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.

Code: Select all

minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)
Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:

Code: Select all

local contents_of_text_field = fields.<name of text field>
TY for answer and sorry for my english is my first problem i need big time for understand english tutor/ial :-) and the guides for formspec are mutch inexplicative :-( (for me :-P) this is my code

Code: Select all

local function play_track(pos, track)
	return minetest.sound_play("juke_track_"..tostring(track),
			{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
end 
local function stop_player(pos, node)
	local pos_hash = minetest.hash_node_position(pos)
	local music_handle = music_handles[pos_hash]
	if music_handle then
		minetest.sound_stop(music_handle)
		music_handles[pos_hash] = nil
	end
end
-- Show form when the /formspec command is used.
minetest.register_chatcommand("juke", {
	func = function(name, param)
		minetest.show_formspec(name, "jukebox:form",
				"size[4.0,4.5]" ..
                "background[-0,-0;4,4.5;juke_bag.png]"..
             	"label[0,0;CIAO!!!, " .. name .. "]" ..
            	"field[0.3,2.5;4,1;ded;" .. name .. ", DEDICA;]" ..
                "button[1,0.3;2,1;stop;STOP!]"..
                "button[0,1;1,1;track_1;1]"..
                "button[1,1;1,1;track_2;2]"..
			    "button[2,1;1,1;track_3;3]"..
			    "button[3,1;1,1;track_4;4]"..
                "button[0,3;1,1;track_5;5]"..
                "button[1,3;1,1;track_6;6]"..
			    "button[2,3;1,1;track_7;7]"..
			    "button[3,3;1,1;track_8;8]"..
				"button_exit[1,3.7;2,1;exit;EXIT]")
                   end
	
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="jukebox:form" 
    
      
    local stop_player = 0  
    local " .. name .. ", DEDICA = fields.ded
	local juke_track = nil
		if fields.stop then juke_track = 0 end
		elseif fields.track_1 then juke_track_ = 1 end
		elseif fields.track_2 then juke_track_ = 2 end
		elseif fields.track_3 then juke_track = 3 end
		elseif fields.track_4 then juke_track = 4 end
		elseif fields.track_5 then juke_track = 5 end
		elseif fields.track_6 then juke_track = 6 end
		elseif fields.track_7 then juke_track = 7 end
		elseif fields.track_8 then juke_track = 8 end
		elseif fields.track_9 then juke_track = 9 end
		elseif ded then func = function(name, param)
		minetest.chat_send_all(field)
         end 		
      end 
   end
end       
)
help pls ty in advance
resolved thank's all for answer
X4cna2d4UqsiawIzUumDgPoYNx3JLGII

User avatar
Lejo
Member
Posts: 715
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Post

Topic: How to fix #1 bad argument to get_player_by_name (string expected, got userdata)
Reason: I want to make a mod.
More Info:code:

Code: Select all

minetest.register_tool("blood:victimknife", {
	description = "Victimknife",
	inventory_image = "Victimknife.png",
	on_use = function(player)
			local pname = minetest.get_player_by_name(player)
			pname:set_hp(pname:get_hp()-2)
	end,
})

Locked

Who is online

Users browsing this forum: No registered users and 3 guests