Post your modding questions here

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

burli wrote:
yzelast wrote:Hey guys, i have a little question: There's a way to get how the node is rotated?

What a want to do is basically:
  • get node's rotation
  • set the pos with air
  • placa another node with the same rotation
What you want is param2. Take a look in the stairs mod.

or try swap_node()

https://github.com/minetest/minetest/bl ... .txt#L2188

And you don't need to set air first
Thanks, it'll help a lot. But the function didn't kept the rotation. I Had to get the param2 manually and set it on the table to work.

I tested with this abm:

Code: Select all

minetest.register_abm {
	nodenames = {"real_trees:wide_leaves"},
	interval = 1,
	chance = 1,
	action = function(pos)
		local node = minetest.get_node(pos)
		minetest.swap_node(pos,{name = "real_trees:wide_acacia_leaves",param1 = light,param2 = node.param2})
	end,
}
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

hlah_
New member
Posts: 1
Joined: Thu Feb 23, 2017 16:47
GitHub: hlah

Re: Post your modding questions here

by hlah_ » Post

How to change how nodes are dig?

I want to create a mod that adds a strength level to each player, so a player with more strength would dig some nodes faster. I took some look on the modding reference but could not find clearly how I could do this.

Could you help me on how I can implement this, such as what function or variable I should override/change?

ABJ
Member
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.

Re: Post your modding questions here

by ABJ » Post

EthanD57 wrote:I managed to make the player invisible but along with my other questions (see post above) I have a new one: How would I give a player "night vision", allowing them to see everything as if in daylight?
As far as I know, that is not possible at the moment.

User avatar
Desour
Member
Posts: 1472
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

yzelast wrote:Hey guys, i have a little question: There's a way to get how the node is rotated?

What a want to do is basically:
  • get node's rotation
  • set the pos with air
  • placa another node with the same rotation
You can easily get param1 and param2 and paramtype1 and paramtype2. This should be enough.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

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

The rotation of a node is stored in 'param2'
local node=minetest.get_node(pos)
local param2=node.param2
--set node
minetest.set_node(pos, {name="whatever", param2=param2})
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Is it possible to make recipes with tools which will not be consumed? For example make a dough for a cake in a mixing bowl.

Add the bowl, flor, water and maybe salt to the crafting field to get the dough, but the mixing bowl remains in the crafting field.

Is that possible?

ABJ
Member
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.

Re: Post your modding questions here

by ABJ » Post

It's been done - with repairing tools feature.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

ABJ wrote:It's been done - with repairing tools feature.
???

With tool repair nothing stays in the crafting field. I can put two stone axes in the field and get one in the output

http://wiki.minetest.net/Repairing

Or is there another method?

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

Replacements in crafting recipe definition. Look in lua_api.txt
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

orwell wrote:Replacements in crafting recipe definition. Look in lua_api.txt
Didn't know that, thanks

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Have a question about ABM times.

The mushroom spread and death ABM has an interval of 11 seconds and a chance of 50. Does that mean each mushroom will spread/die in an average time of 550 seconds?

The flowers spread ABM has an interval of 13 and a chance of 96. That would mean an average of 1248 seconds or over 20 minutes. Is that correct?

Of course it can be much faster or slower, it is just the statistical average

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

Re: Post your modding questions here

by sofar » Post

burli wrote:The mushroom spread and death ABM has an interval of 11 seconds and a chance of 50. Does that mean each mushroom will spread/die in an average time of 550 seconds?
no, it means that ever 11 seconds, 1 in 50 mushrooms will spread/die.

So logically, this means that after 22 seconds, there will be a small chance that the same mushroom will spread again if it didn't die, but most likely one of the other mushrooms gets picked (49 out of 50 chance).

So after 33 seconds, most likely (48/50) it's a different mushroom, and 2/50 chance it's a previous mushroom.

But since some of them may have died, the chance fluctuates

And so on. The chance is really hard to predict. This is the problem with trying to estimate binomial distributions.

Let's take a simpler example:

100 leaves. every 1 second there's a 1/2 chance the leaf decays.

after 1 second you have probably 50 leaves left
after 2 seconds you have probably 25 leaves left
after 3 seconds you have probably 13 leaves left
after 4 seconds you have probably 7 leaves left
after 5 seconds you have probably 4 leaves left
after 6 seconds you have probably 2 leaves left
after 7 seconds you have probably 1 leaves left

how many leaves do you have left after 8 seconds? Could be 0, could be 1. You don't know.

Now let's look at the average number calculation:

average = 50 * 1 + 25 * 2 + 13 * 3 + 7 * 4 + 4 * 5 + 2 * 6 + 7 + 9 / 100 (assuming the last one took 2 tries)

average = 2.15

Now, this is just pure luck that it pans out this way. If I redo the experiment 10 more times, I might get answers that wildly vary, since the chance that at the first second exactly 50 decay is common, but not that common. It's highly likely that the number varies quite a bit.

TL:DR; You can't just multiply the numbers, lots of factors account and may influence the result. Conduct experiments multiple times to get an idea how the numbers work out in reality instead.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Hmm, ok, thanks sofar.

Another question: is it possible to display infotext for any node, also map generated nodes like dirt? I assume it is not possible

User avatar
admicos
Member
Posts: 13
Joined: Fri Feb 24, 2017 14:31
GitHub: admicos
IRC: admicos
In-game: admicos
Contact:

Re: Post your modding questions here

by admicos » Post

Is there a way to "ignore" chat messages?

For example, when a player says "i am new", i want the message to stop getting sent, and instead send my custom message, like "player is new to this server!"

I am currently using register_on_chat_message and everything i want to do is ready, except the old message still sends.

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

Re: Post your modding questions here

by Hybrid Dog » Post

burli, yes, you can set infotext to every node, try the pencil: https://github.com/HybridDog/technic_ex ... t.lua#L284
You can even set infotext of ignore outside the walkable map boundaries.

admicos, the lua api is not up to date. Before that bad chat prediction was removed, changing the message did not work for the player who wrote it but only for the other ones. This also disallows colouring chat messages.

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

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

HybridDog sorry, that's a misunderstanding. I want to set infotext at registration. I want to have infotext at all nodes, even mapgen generated nodes.

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

by Hybrid Dog » Post

You can set the infotext in the on_construct function in the nodedef. on_construct is executed when the node is set with minetest.set_node (or add_node), mapgen (core or vmanip) doesn't care for such a function, it would have a severe impact on performance. So you need to set the infotext manually to each node in the mapchunk with register_on_generated.
You could also change the source code to display infotext if it's not preset in meta.

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

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Post

Infotext is in node metadata, so I would expect adding infotext to every node will greatly inflate map size and map updates sent to players. You are better off waiting for client-side modding support, which is making progress and is no longer a meme.
Every time a mod API is left undocumented, a koala dies.

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

admicos wrote:Is there a way to "ignore" chat messages?

For example, when a player says "i am new", i want the message to stop getting sent, and instead send my custom message, like "player is new to this server!"

I am currently using register_on_chat_message and everything i want to do is ready, except the old message still sends.
Have you tried returning `true` from your chat message handler?
lua_api.txt wrote: * `minetest.register_on_chat_message(func(name, message))`
* Called always when a player says something
* Return `true` to mark the message as handled, which means that it will not be sent to other players
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
Hybrid Dog
Member
Posts: 2834
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Does node metadata become compressed?

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

User avatar
admicos
Member
Posts: 13
Joined: Fri Feb 24, 2017 14:31
GitHub: admicos
IRC: admicos
In-game: admicos
Contact:

Re: Post your modding questions here

by admicos » Post

kaeza wrote:
admicos wrote:Is there a way to "ignore" chat messages?

For example, when a player says "i am new", i want the message to stop getting sent, and instead send my custom message, like "player is new to this server!"

I am currently using register_on_chat_message and everything i want to do is ready, except the old message still sends.
Have you tried returning `true` from your chat message handler?
lua_api.txt wrote: * `minetest.register_on_chat_message(func(name, message))`
* Called always when a player says something
* Return `true` to mark the message as handled, which means that it will not be sent to other players
My current code is:

Code: Select all

minetest.register_on_chat_message(function(name, message)
    -- my stuff bla bla bla
    minetest.chat_send_all(myMessage)
    return true
end)
but it still shows the old message as being sent. I am currently only testing on singleplayer right now, so that might be a issue.

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

Ah. If you're using stable 0.4.15, you will see your own message but other players shouldn't.

There's this commit which will be available in 0.4.16.
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
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Byakuren wrote:Infotext is in node metadata, so I would expect adding infotext to every node will greatly inflate map size and map updates sent to players. You are better off waiting for client-side modding support, which is making progress and is no longer a meme.
Ok, so infotext is not a node description like the name. It is an individual text for each single node in the map. Then I agree that it doesn't make sense

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

Hey guys, today i have another small question: I'm not able to concatenate 2 strings...

The function:

Code: Select all

realtrees.dry = function(pos1,pos2,chance)
local leaves = minetest.find_nodes_in_area(pos1,pos2,{"group:leaves"})
	for key,value in pairs(leaves) do
		if math.random(1,chance) == 1 then
			local node = minetest.get_node(value)
				node.name = node.name .. "_dry"
				minetest.swap_node(value,node})
		end
	end
end
Changing the name to any other itemstring works fine but the concatenation doesn't
G84mU6AQ9dKaNhxn6dq8P5C0y5r8NssE

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Post

yzelast wrote:Hey guys, today i have another small question: I'm not able to concatenate 2 strings...

The function:

Code: Select all

realtrees.dry = function(pos1,pos2,chance)
local leaves = minetest.find_nodes_in_area(pos1,pos2,{"group:leaves"})
	for key,value in pairs(leaves) do
		if math.random(1,chance) == 1 then
			local node = minetest.get_node(value)
				node.name = node.name .. "_dry"
				minetest.swap_node(value,node})
		end
	end
end
Changing the name to any other itemstring works fine but the concatenation doesn't
What do you mean? Is there an error when you try to concatenate?
Every time a mod API is left undocumented, a koala dies.

Locked

Who is online

Users browsing this forum: No registered users and 4 guests