Page 123 of 125

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 09:48
by TumeniNodes
burli wrote:
TumeniNodes wrote:can it be applied to an object which will open and close?

Not sure what you mean. Any example?

The idea of VoxelManip is, that you can get a part of the map (a chunk or a part of the chunk) as array. You can change the data in this array and write it back. But the chunk has to be generated first and the area has to be inside the chunk plus the surrounding shell of 16 nodes (emin, emax)


This is why, I have a sneaking suspicion... the voxelmanip is not going to work for a drawbridge?
Is it not reserved for generated map objects?
I need sleep, I'll check here in the morn

PostPosted: Wed Mar 08, 2017 11:32
by Hybrid Dog
vmanip isn't reserved for mapgen, but if you use it for mapgen you need to consider the differences of usage, see http://dev.minetest.net/vmanip

By the way, there's a PR about increasing the collision check range https://github.com/minetest/minetest/pull/5335

Re:

PostPosted: Wed Mar 08, 2017 11:44
by TumeniNodes
Hybrid Dog wrote:vmanip isn't reserved for mapgen, but if you use it for mapgen you need to consider the differences of usage, see http://dev.minetest.net/vmanip

By the way, there's a PR about increasing the collision check range https://github.com/minetest/minetest/pull/5335


Sweet....
and, thank you. Yeh, I wasn't sure because I saw "mapgen", and "generated" upon first 4 second glance, and judging by burli's posts... I jumped to conclusions :P

edit: just read through real quick.
I agree with sofar and paramats suggestions of finding another means to use multiple nodes (i.e. voxelmanip).

And paramat mentioned focusing more toward the node collision box code (which makes better sense, since that would not impact the load on resources for the end user)

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 19:37
by sofar
I'd look at the TNT mod - it uses a vmanip to create the crater, and does so outside of mapgen domain.

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 19:45
by TumeniNodes
sofar wrote:I'd look at the TNT mod - it uses a vmanip to create the crater, and does so outside of mapgen domain.


cool, thank you sofar

I'll look at it now... I could use something to get me away from posting on the forums for a bit :P

edit: so..., "if" I manage to wrap my inefficient brain around voxelmanip... would it make sense for me to apply it only to the lowered bridge?
If I am able to make just that walkable... I'll be one happy duck.

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 21:56
by sofar
TumeniNodes wrote:so..., "if" I manage to wrap my inefficient brain around voxelmanip... would it make sense for me to apply it only to the lowered bridge?
If I am able to make just that walkable... I'll be one happy duck.


Well, what I would do is:

1. make everything just 1x1x1 nodes so the whole collision box problem goes away
2. use a vmanip to make the door open/close node changes all at once

I assume your "open" door is a bunch of laying-down-looking nodes, and your "closed" door is a bunch of upright-looking nodes.

So the vmanip would be used to both switch from open to close, and from close to open. You'd use one vmanip to rapidly replace the /closed/ nodes with air, and put down the /open/ nodes, and vice versa.

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 22:37
by TumeniNodes
sofar wrote:Well, what I would do is:

1. make everything just 1x1x1 nodes so the whole collision box problem goes away
2. use a vmanip to make the door open/close node changes all at once

I assume your "open" door is a bunch of laying-down-looking nodes, and your "closed" door is a bunch of upright-looking nodes.

So the vmanip would be used to both switch from open to close, and from close to open. You'd use one vmanip to rapidly replace the /closed/ nodes with air, and put down the /open/ nodes, and vice versa.


okie dokie
thank you

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 22:41
by orwell
@TumeniNodes, I just overflew your code, but did you set walkable=true for the upper node? I think not...
If a node is not walkable, nothing will collide with it, independent of if a collision box is set.
EDIT: probably not of interest for the problem (raised drawbridge...), but indeed, it's not walkable, so you can walk through!
----
I need help regarding models:
I know that minetest supports multiple textures for an object. I have a Blender object that has 2 material slots with materials in it, and different faces assigned to these materials. Because this single blender files contains many objects (it is the file with the different rail variants for my advtrains mod) I export single objects by selecting "Export selected only" while exporting.
Then, in LUA, I have a node with tiles={"texture1.png", "texture2.png"}, and want all faces assigned to the first material slot of the blender object to use texture1.png, and all other use texture2.png
What do I have to do that minetest recognizes both materials? For me, the first texture gets applied for all faces of the mesh.
Is multiple material textures even implemented for nodes?

Re: Post your modding questions here

PostPosted: Wed Mar 08, 2017 22:55
by TumeniNodes
orwell wrote:@TumeniNodes, I just overflew your code, but did you set walkable=true for the upper node? I think not...
If a node is not walkable, nothing will collide with it, independent of if a collision box is set.


I did have walkable = true in there before. I remember it was you who suggested I try it. : )
The problem is, the object is too large for what the collision code in MT handles.

I had thought about trying to see if using a schematic might work but, sofar has suggested I apply voxelmanip.
Not really confident I will be able to work it out but, I'll try.

I know your question is not directed toward me but,

Nathan S is the Blender guru here but... did you set those 2 textures to the materials in Blender?
If not, you need to do that.
Even though you set each face with a material, you still need to go in and assign a texture to each as well, set the normals, and adjust the textures to each face / assign each texture to each material.
And your drawtype should be "mesh" not node

If I read the question correctly, these are the steps you are missing
Nathan also made some vid tutorials on this very recently, checking the out might help : )

Re: Post your modding questions here

PostPosted: Thu Mar 09, 2017 09:37
by orwell
What I've tried now:
- Copy the required object to a new blender file
- add 2 materials into two slots and assign the right materials to faces
- selected a dummy color grid and a dummy uv grid as textures, one for each material slot
- assigned the texture to the faces by selecting the uvs and swapping the image
Still, it does not work.
EDIT:Also tried OBJ instead of B3D. When exporting to OBJ, a .mtl file is created that holds both materials (so this should work)
EDIT2: also doesn't work when using an entity instead of a node.

Re: Post your modding questions here

PostPosted: Thu Mar 09, 2017 20:21
by kaeza
burli wrote:A, ok, it's a little bit confusing that a rightclick callback is sometimes called on_rightclick and sometimes on_place. Doc could be more clear at this point

When you interact (in this case, right click) with a node, there are two items involved: the wielded item, and the node you're pointing at. Note that the hand is also considered an item by the engine.

The `on_place` callback is called for the wielded item. The `on_rightclick` callback is called for the pointed node. There's a difference between the two, and what you should override or otherwise implement depends on the use case.

BTW, this is also the same for `on_punch`/`on_use` pair of callbacks.

Re: Post your modding questions here

PostPosted: Thu Mar 09, 2017 20:32
by D00Med
Is there a way to make a particular biome flat in v7 mapgen? or valleys?

Re: Post your modding questions here

PostPosted: Fri Mar 10, 2017 23:46
by GreenDimond
How do I set the size of space between slots when defining an inventory list?

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 08:10
by orwell
You can't, except by defining every single slot as separate list[] element, which is overkill

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 08:30
by burli
Thx kaeza, that helps a lot

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 13:20
by burli
How can I add wear to an item if it is used with the right mouse button?

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 14:46
by burli
burli wrote:How can I add wear to an item if it is used with the right mouse button?

Meanwhile I got this, but I still don't understand uses.

For example: a wooden shovel has uses = 10, but I can dig 31 sand nodes, a stone shovel has uses = 20, but I can dig 61 sand, a mese shovel has also uses = 20, but I can dig nearly 550 sand

How so? Maybe I didn't understand Uses

How is leveldiff calculated? The diff between what?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Table of resulting digging times:

    crumbly        0     1     2     3     4  <- level
         ->  0     -     -     -     -     -
             1  0.80  1.60  1.60     -     -
             2  0.60  1.20  1.20     -     -
             3  0.40  0.80  0.80     -     -

    level diff:    2     1     0    -1    -2


I assume "crumbly" is the level of the crumbly group of the node, e.g. crumbly = 3 for sand. But what is meant with "level"?

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 15:13
by cx384
Is there a way to copy a file without using os.execute()?

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 21:23
by orwell
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local file=io.open("source.txt", "r")
local target=io.open("target.txt", "w")
target:write(file:read("*a"))
file:close()
target:close()

works with security as long as copied file is in mod or world directory

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 21:32
by orwell
burli wrote:
burli wrote:How can I add wear to an item if it is used with the right mouse button?

Meanwhile I got this, but I still don't understand uses.

For example: a wooden shovel has uses = 10, but I can dig 31 sand nodes, a stone shovel has uses = 20, but I can dig 61 sand, a mese shovel has also uses = 20, but I can dig nearly 550 sand

How so? Maybe I didn't understand Uses

How is leveldiff calculated? The diff between what?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Table of resulting digging times:

    crumbly        0     1     2     3     4  <- level
         ->  0     -     -     -     -     -
             1  0.80  1.60  1.60     -     -
             2  0.60  1.20  1.20     -     -
             3  0.40  0.80  0.80     -     -

    level diff:    2     1     0    -1    -2


I assume "crumbly" is the level of the crumbly group of the node, e.g. crumbly = 3 for sand. But what is meant with "level"?

The leveldiff is the difference between the node's "level" group (not the crumbly rating) and the tool's "maxlevel" for the digging group (here crumbly)
Sand is level 0, wooden shovel has maxlevel 1, so leveldiff is 1-> 10*3^1=30 uses
Mese shovel has maxlevel 3, leveldiff 3 -> 20*3^3=20*27=540

Re: Post your modding questions here

PostPosted: Sat Mar 11, 2017 21:45
by burli
orwell wrote:The leveldiff is the difference between the node's "level" group (not the crumbly rating) and the tool's "maxlevel" for the digging group (here crumbly)
Sand is level 0, wooden shovel has maxlevel 1, so leveldiff is 1-> 10*3^1=30 uses
Mese shovel has maxlevel 3, leveldiff 3 -> 20*3^3=20*27=540


Thank you. Meanwhile I got this myself, but only because I assumed that the default level is 0. Takes a while to find that out. Didn't found any hint in the doc what's the default value if no level is given

Re: Post your modding questions here

PostPosted: Sun Mar 12, 2017 08:44
by burli
How can I update param2 of a node? Currently I replace the node with set_node() and the new param2 value, but I hope there is a faster way

Re: Post your modding questions here

PostPosted: Sun Mar 12, 2017 08:45
by sofar
burli wrote:How can I update param2 of a node? Currently I replace the node with set_node() and the new param2 value, but I hope there is a faster way


swapnode(pos, {name = node.name, param2 = newparam2})

no faster way than that.

Re: Post your modding questions here

PostPosted: Sun Mar 12, 2017 11:34
by cx384
orwell wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local file=io.open("source.txt", "r")
local target=io.open("target.txt", "w")
target:write(file:read("*a"))
file:close()
target:close()

works with security as long as copied file is in mod or world directory

Thank you orwell, but the file is in the /.minetest/textures directory (texture packs) (and it is a .png file).
Anyway I have to change the secure.trusted_mods setting.
But I cant use minetest.setting_set("secure.trusted_mods", "modname") right?

Re: Post your modding questions here

PostPosted: Sun Mar 12, 2017 18:31
by orwell
Of course not. You need to instruct the user to add this mod to trusted_mods.
After a private conversation with NathanS, I got my blender issue fixed. Thanks Nathan

Re: Post your modding questions here

PostPosted: Sun Mar 12, 2017 18:33
by orwell
burli wrote:
orwell wrote:The leveldiff is the difference between the node's "level" group (not the crumbly rating) and the tool's "maxlevel" for the digging group (here crumbly)
Sand is level 0, wooden shovel has maxlevel 1, so leveldiff is 1-> 10*3^1=30 uses
Mese shovel has maxlevel 3, leveldiff 3 -> 20*3^3=20*27=540


Thank you. Meanwhile I got this myself, but only because I assumed that the default level is 0. Takes a while to find that out. Didn't found any hint in the doc what's the default value if no level is given

If a group is not given, it's rating defaults to 0. So...

Re: Post your modding questions here

PostPosted: Thu Mar 16, 2017 02:28
by kaeza
cx384 wrote:Thank you orwell, but the file is in the /.minetest/textures directory (texture packs) (and it is a .png file).

You can't do that. Mods (currently) run only on the server. Texture packs are on the client.

Can you specify what you're actually trying to do?

cx384 wrote:Anyway I have to change the secure.trusted_mods setting.
But I cant use minetest.setting_set("secure.trusted_mods", "modname") right?

Of course not. What is the point of having a secure environment if mods can disable or otherwise mess with it?

Re: Post your modding questions here

PostPosted: Thu Mar 16, 2017 10:06
by Muuus
Hi, I'm searching a way to allow the player to place a specific item ONLY into a specific node inventory. Meaning, I have my ModdedItem_A and I want the player to be able to place it only into ModdedNode_B's inventory, but not into any other inventory, like chest's, or other modded node's inventory. Is there any easy way to do that ?

Re: Post your modding questions here

PostPosted: Thu Mar 16, 2017 14:07
by cx384
kaeza wrote:Can you specify what you're actually trying to do?

I'm making a mod which copies textures from the texturepacks folder into the mod textures folder, because I want to register nodes with this textures.
This is my code for this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local path_mod = minetest.get_modpath("ntm_texture_packs")
local path_minetest = string.sub(path_mod,1,string.find(path_mod,"/mods/"))
local path_mod_textures = path_mod.."/textures/"

local insecure_environment = minetest.request_insecure_environment()

if not insecure_environment then
   error("You have too add the ntm_texture_packs mod to the secure.trusted_mods setting if you want to use it.")
end

local function file_exists(name)
   setfenv(1, insecure_environment)
   local f=io.open(name,"r")
   if f~=nil then io.close(f) return true else return false end
end

local function copy_and_rename_texture(texture_pack, texture)
      setfenv(1, insecure_environment)
      local file=io.open(path_minetest.."textures/"..texture_pack.."/"..texture, "r")
      local target=io.open(path_mod_textures..texture, "w")
      target:write(file:read("*a"))
      file:close()
      target:close()
      os.rename (path_mod_textures..texture, path_mod_textures..texture_pack.."_"..texture)
end

local function get_and_check_texture(texture_pack, texture)
   if not file_exists(path_mod_textures..texture_pack..texture) then
      if file_exists(path_minetest.."textures/"..texture_pack.."/"..texture) then         
         copy_and_rename_texture(texture_pack, texture)
      else
         return false
      end   
   end
   return true
end

Re: Post your modding questions here

PostPosted: Thu Mar 16, 2017 16:51
by Nyarg
500000 nodes = 30 FPS
10500 entities = 3 FPS

W.T.H. is does exactly MT render or engine when draw simple node Versus simplest entity ?
entity simple single side plate (without any material assigned in blender)

the entity
+ Spoiler
the plate.x
+ Spoiler