Post your modding questions here

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

Re: Post your modding questions here

by burli » Sat Mar 11, 2017 14:46

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: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sat Mar 11, 2017 15:13

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

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

Re: Post your modding questions here

by orwell » Sat Mar 11, 2017 21:23

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: 803
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Post your modding questions here

by orwell » Sat Mar 11, 2017 21:32

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: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Sat Mar 11, 2017 21:45

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: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Sun Mar 12, 2017 08:44

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: 2100
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Sun Mar 12, 2017 08:45

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: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Mar 12, 2017 11:34

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: 803
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Post your modding questions here

by orwell » Sun Mar 12, 2017 18:31

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: 803
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

Re: Post your modding questions here

by orwell » Sun Mar 12, 2017 18:33

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
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Thu Mar 16, 2017 02:28

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 » Thu Mar 16, 2017 10:06

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: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Thu Mar 16, 2017 14:07

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 » Thu Mar 16, 2017 16:51

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
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: 2100
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Thu Mar 16, 2017 18:30

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: 2726
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Thu Mar 16, 2017 20:24

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 » Fri Mar 17, 2017 02:00

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: 2726
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Fri Mar 17, 2017 09:01

>How do I may abort that calculation ?

edit the source code

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

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

Re: Post your modding questions here

by burli » Sat Mar 18, 2017 13:03

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: 2100
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Sun Mar 19, 2017 05:58

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: 320
Joined: Sun Jan 08, 2012 21:34
Location: behind
GitHub: pandaro

Re: Post your modding questions here

by pandaro » Sun Mar 19, 2017 11:26

[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: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sun Mar 19, 2017 13:40

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
DS-minetest
Member
 
Posts: 1123
Joined: Thu Jun 19, 2014 19:49
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Sun Mar 19, 2017 13:42

@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.
Do not call me -minetest.
Call me DS or DS-minetest.
I am German, so you don't have to pm me English if you are also German.
The background is a lie.
 

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

Re: Post your modding questions here

by Nyarg » Sun Mar 19, 2017 17:17

Next code rise error
+ Spoiler
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: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Mon Mar 20, 2017 08:15

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
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests