Post your modding questions here

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

Re: Post your modding questions here

by burli » Post

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?

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"?

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

Re: Post your modding questions here

by cx384 » Post

Is there a way to copy a file without using os.execute()?
Can your read this?

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

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
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

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?

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
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: 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

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

Re: Post your modding questions here

by burli » Post

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

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: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.

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

Re: Post your modding questions here

by cx384 » Post

orwell wrote:

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?
Can your read this?

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

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
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

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...
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

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?
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

Muuus
New member
Posts: 2
Joined: Thu Jan 19, 2017 18:37
In-game: Muuus

Re: Post your modding questions here

by Muuus » Post

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 ?

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

Re: Post your modding questions here

by cx384 » Post

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:

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
Can your read this?

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

Re: Post your modding questions here

by Nyarg » Post

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

Code: Select all

	visual = "mesh",
	mesh = "plate.x",
	visual_size = {x=1, y=1, z=1},
	physical = false,
   collisionbox = {0,0,0,0,0,0},
the plate.x
Spoiler

Code: Select all

xof 0303txt 0032

Frame Root {
  FrameTransformMatrix {
     1.000000, 0.000000, 0.000000, 0.000000,
     0.000000,-0.000000, 1.000000, 0.000000,
     0.000000, 1.000000, 0.000000, 0.000000,
     0.000000, 0.000000, 0.000000, 1.000000;;
  }
  Frame Plane {
    FrameTransformMatrix {
       1.000000, 0.000000, 0.000000, 0.000000,
       0.000000, 1.000000, 0.000000, 0.000000,
       0.000000, 0.000000, 1.000000, 0.000000,
       0.000000, 0.000000, 0.000000, 1.000000;;
    }
    Mesh { // Plane mesh
      4;
      -1.000000;-1.000000; 0.000000;,
       1.000000;-1.000000; 0.000000;,
       1.000000; 1.000000; 0.000000;,
      -1.000000; 1.000000; 0.000000;;
      1;
      4;3,2,1,0;;
      MeshNormals { // Plane normals
        1;
         0.000000; 0.000000; 1.000000;;
        1;
        4;0,0,0,0;;
      } // End of Plane normals
      MeshTextureCoords { // Plane UV coordinates
        4;
         0.000000; 1.000000;,
         1.000000; 1.000000;,
         1.000000; 0.000000;,
         0.000000; 0.000000;;
      } // End of Plane UV coordinates
    } // End of Plane mesh
  } // End of Plane
} // End of Root
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 )

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

Nyarg wrote: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)
nodes are rendered into a "mesh" together. So 500k nodes can end up being only a few hundred meshes. 10k entities is 10k meshes, full stop. Plus entities need to be serviced every step to update position and calculate physics, so, they're really resource consuming to both client and server.

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

by Hybrid Dog » Post

You could abort position and physics calculation of entities and particles after a specific amount of time exceeded (e.g. 1/60) to reduce only the object and particle fps instead of the aggregate fps rate.

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

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

Re:

by Nyarg » Post

sofar wrote:nodes are rendered into a "mesh" together. .
I am trying attach entities success but have no effect in FPS.
sofar wrote:entities need to be serviced every step .
Is there a way to block every step calculation for entities (even may be globalTable editing) ?
Hybrid Dog wrote:You could abort position and physics calculation of entities and particles .
How do I may abort that calculation ?
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
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

>How do I may abort that calculation ?

edit the source code

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

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

Re: Post your modding questions here

by burli » Post

Is voxelmanip always faster than get_node? I noticed that the hopper mod uses voxelmanip just to get two neighbour nodes.

Is this really better?

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:Is voxelmanip always faster than get_node? I noticed that the hopper mod uses voxelmanip just to get two neighbour nodes.

Is this really better?
yes and no. It can sometimes mean only doing a single lua-to-C call, which is likely cheaper than two get_node() calls. But if it's not performance critical, you shouldn't worry too much.

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

Re: Post your modding questions here

by pandaro » Post

[CSM] client side modding explanation
I'm following the evolving of minetest, i see this new feature.
I need to know:
For such purposes has made this class of API?
On what occasions it is best to use a client mod and in which it is supposed to use a server side mod?

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

Re: Post your modding questions here

by cx384 » Post

pandaro wrote:[CSM] client side modding explanation
I'm following the evolving of minetest, i see this new feature.
I need to know:
For such purposes has made this class of API?
On what occasions it is best to use a client mod and in which it is supposed to use a server side mod?
Do you want to see this?
Can your read this?

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

@pandaro:
There is a client lua api.
Client side mods are good to handle the information that you get from the server. Server side mods are used to add features and CO. to every player on a server.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

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

Re: Post your modding questions here

by Nyarg » Post

Next code rise error
Spoiler
Image

Code: Select all

minetest.register_on_punchnode( ...
       minetest.register_entity( modName .. ":efRB", eObjRB )
...
end )
But if I make simple stub in minetest-0.4.14\builtin\game\register.lua like

Code: Select all

local function check_modname_prefix(name)
...
---	local expected_prefix = core.get_current_modname() .. ":"
		local expected_prefix 
		if core.get_current_modname()==nil then expected_prefix = "lumpmg"
		else expected_prefix = core.get_current_modname() 
		end
		expected_prefix = expected_prefix .. ":"
...
All works fine and new entity creating after loadTime now, wow !

Question:
What problem do it may cause and where (if change stub with proper code) ?

*have dreaming about like above backdoor for node register same way
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
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

How can I add "shift click" to move item stacks between inventories like in the chest? I can't find any reason why it works for a chest, but not in my mod

Locked

Who is online

Users browsing this forum: No registered users and 6 guests