Post your modding questions here

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Tue Sep 13, 2016 19:12

Not sure what you mean

But yes, in the example version I posted, 'user' is indeed an object. You might have wanted my_function(user:get_player_name()) afterwards
 

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

Re: Post your modding questions here

by Nyarg » Fri Sep 23, 2016 13:17

Hi all )
Why ? lua.init for example contain only:
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 modName = minetest.get_current_modname()
     print(modName)

minetest.register_on_generated( function( minp, maxp, seed)
     local modName = minetest.get_current_modname()
     print(modName)
end)


First minetest.get_current_modname() return real mod name.
Second call return nil.
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Fri Sep 23, 2016 13:48

Get current mod name only works at load time
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Fri Sep 23, 2016 18:02

You may want to do 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
minetest.after(0, function()
   local t = minetest.registered_on_generateds
   for i = 1, #t do
      local func = t[i]
      t[i] = function(...)
         print(minetest.get_current_modname())
         return func(...)
      end
   end
end)
 

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

Re: Post your modding questions here

by Nyarg » Sat Sep 24, 2016 23:49

Some difficult for me ) will be tested.
At a glance it seems like each function in minetest.registered_on_generateds will be merged with print(minetest.get_current_modname()).

Another question.
Is here a way to make nodes (adding new during game experience) dynamically like:
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
 minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
    minetest.register_node(name,def)
end)


At end of my experiments I have new nodes in my inventory but without texture.
+ Spoiler

I may set node on ground and iterate properties but F5 see nothing when I point at and field mod_origin = "??" .
+ Spoiler
+ Spoiler
I search trought mods for using minetest.register_node() and have not found somethig like dynamic node register.
+ Spoiler
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Sun Sep 25, 2016 09:56

Note that the nodedefs use metatable, so to get the real content, you may need to use rawget(t, i).
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Sun Sep 25, 2016 10:49

NOde registration needs to be done at load time.

You should register everything in advance then. It is possible to exclude nodes from the creative inventory.

What game play mechanic are you trying to achieve?
 

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

Re: Post your modding questions here

by Nyarg » Sun Sep 25, 2016 15:10

Hybrid Dog wrote:Note that the nodedefs use metatable, so to get the real content, you may need to use rawget(t, i).
Feelings like I want RTFM minetest source code )

taikedz wrote:What game play mechanic are you trying to achieve?
For example it's particular saw results maked when I need it, instead as in [moreblocks] mod where as I see miniblocks is predefined in *.obj
Last edited by Nyarg on Sun Sep 25, 2016 16:50, edited 2 times in total.
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Sun Sep 25, 2016 16:50

moreblocks registers nodes in advance, but these cannot be accessed via the creative inventories. Only the circular_saw can return a list of resulting nodes.

What you could do is add a "createdyet" property to your node definition, and make a tool that returns only nodes whose "createdyet" property is true.

You can then register all your nodes in advance, and set the "createdyet" property to false.

When you need to "dynamically" register you node, simply set the "createdyet" property to true

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
minetest.registered_nodes["mymod:dynamicnode"].createdyet = true
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Sep 25, 2016 17:28

node should be registered on map creation. a tab in invetory should be created.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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

Re: Post your modding questions here

by Nyarg » Sun Sep 25, 2016 19:23

Ok. Lets turn question another side )
If I don't know what node I need on loadTime (inAdvance) what's way to make or simulate it after loadTime.
I only see way to make 100500 nodes that I manage during play (as taikedz said if I am properly understand)

For example lets look at game play mechanic like dirting lower border of node depend from nearest nodes.
In that case we have free texture combinig during play.
In simple it's give us full cartesian product of results.
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Sun Sep 25, 2016 22:18

There is no other way. When/if changing the properties of individual nodes becomes possible, one way to do it would be with those parts of the API.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Mon Sep 26, 2016 06:33

We would need texture overriding from node metadata
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Mon Sep 26, 2016 10:52

If you play LEGO you also can only change the bricks you have if you leave and rejoin the world where you build.
 

PlanetKiller
Member
 
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Mon Sep 26, 2016 15:13

Trying to make a tool that turns nodes into air.
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
minetest.register_tool("matblox:air_rod", {
   description = "Air Rosin",
   inventory_image = "matblox_air_rod.png",
   
   
   
   on_use = function(pos, node, clicker)
      --local x = 0
      --local y = 0
      --local z = 0
      local final = 10
      local target = node
      for a=0,final,1 do
         for b=0,final,1 do
            for c=0,final,1 do
               local newnode = minetest.get_node(pos)
               if target.name == newnode.name then
                  minetest.set_node({x = pos.x+a, y = pos.y+b, z = pos.z+c}, {name = "core.CONTENT_AIR "})
               end         
            end
         end
      end
   end
})


on_rightclick didn't work, and this keeps giving me a c++ exception.
It is supposed to take the block it is over, then turn all similar blocks into air; for quick map clearing.
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")
 

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

Re: Post your modding questions here

by cx384 » Mon Sep 26, 2016 15:40

PlanetKiller wrote:name = "core.CONTENT_AIR"

I think this should be name = "air"
Can your read this?
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Mon Sep 26, 2016 15:42

"" this what it should be.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

PlanetKiller
Member
 
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Mon Sep 26, 2016 15:51

Thanks, but

2016-09-26 10:50:22: ERROR[Main]: ServerError: Lua: Runtime error from mod 'matblox' in callback item_OnUse(): C++ exception

it didn't solve the problem.

It seems that on_use is not getting the node, and I can't seem to get the node from the position. Tried printing their names, but no luck. Tried on_dig and on_punch without any luck either.

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
on_use = function(itemstack, user, pointed_thing)
   print(pointed_thing.name)
end


This outputs nil, but I'm pointing at a node.
Last edited by PlanetKiller on Mon Sep 26, 2016 17:11, edited 2 times in total.
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Mon Sep 26, 2016 16:16

azekill_DIABLO wrote:"" this what it should be.


Nope, "air"

("" is the name of the hand)
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Mon Sep 26, 2016 17:49

rubenwardy wrote:
azekill_DIABLO wrote:"" this what it should be.


Nope, "air"

("" is the name of the hand)

you're true. sorry.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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

Re: Post your modding questions here

by sofar » Mon Sep 26, 2016 22:09

Nodes need to be registered at mod init time. You can not add new nodes afterwards.

So you can do this in init.lua:

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
minetest.register_node("node:name", {})


But you cannot do 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
minetest.after(0, minetest.register_node, "node:name", {})
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Wed Sep 28, 2016 08:26

PlanetKiller wrote:Thanks, but

2016-09-26 10:50:22: ERROR[Main]: ServerError: Lua: Runtime error from mod 'matblox' in callback item_OnUse(): C++ exception

it didn't solve the problem.

It seems that on_use is not getting the node, and I can't seem to get the node from the position. Tried printing their names, but no luck. Tried on_dig and on_punch without any luck either.

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
on_use = function(itemstack, user, pointed_thing)
   print(pointed_thing.name)
end


This outputs nil, but I'm pointing at a node.

You know what pointed_thing is? it's NOT a node. Look in lua_api what it contains, probably pointed_thing.under is what you want.
Remember to check if pointed_thing.under actually exists, you may be clicking an object...
For LUA it is irrelevant how function arguments are named, the order matters. lua_api tells in which order arguments are passed to the function (e.g.the first argument is a position, the second the player and the third is pointed_thing). Just reordering argument names does definitely not work.

It's 'air', not ''.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

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

Re: Post your modding questions here

by ulla » Wed Sep 28, 2016 14:47

Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Thu Sep 29, 2016 05:16

How exactly would I have minetest.get_node work to ensure a node needs space to spread, or only does a certain action if a certain node is above it? I tried looking into it when looking at the tutorial guide for modding but it doesn't seem to explain anything beyond, "Just use minetest.get_node to stop the destruction"

I guess a specific way to figure it out (as I still want to puzzle out the execution I want to try later on) is, with the alien grass example, how would I used get_node to make it only spread if the blocks it spreads to have air above them?
 

ManElevation
Member
 
Posts: 213
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation

Re: Post your modding questions here

by ManElevation » Thu Sep 29, 2016 06:00

how do you make a mod topic
Hey there im going to be off minetest for a while because my company has been deleloping a game called Ground Conflict, if you wish to see some screenshots or have some info, than please join our discord server https://discord.gg/C9ygXJn
 

PlanetKiller
Member
 
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Thu Sep 29, 2016 15:08

Icalasari wrote:How exactly would I have minetest.get_node work to ensure a node needs space to spread, or only does a certain action if a certain node is above it? I tried looking into it when looking at the tutorial guide for modding but it doesn't seem to explain anything beyond, "Just use minetest.get_node to stop the destruction"

I guess a specific way to figure it out (as I still want to puzzle out the execution I want to try later on) is, with the alien grass example, how would I used get_node to make it only spread if the blocks it spreads to have air above them?


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
if minetest.get_node({x = pos.x, y = pos.y+1, z = pos.z}).name == "air" then
    minetest.set_node({x = pos.x, y = pos.y+1, z = pos.z}, {name = "alien:grass"})
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Thu Sep 29, 2016 17:06

ManElevation wrote:how do you make a mod topic

You can only post in the WIP mods section.
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Thu Sep 29, 2016 17:09

PlanetKiller 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
if minetest.get_node({x = pos.x, y = pos.y+1, z = pos.z}).name == "air" then
    minetest.set_node({x = pos.x, y = pos.y+1, z = pos.z}, {name = "alien:grass"})


Huh, wonder why it looks that slightest bit different

Thank you, seeing it laid out like this actually answered a few other questions that I was leaving for later as well (although I bet the code for those things is going to be sloppy as hell, but hey, learning)
 

PlanetKiller
Member
 
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Thu Sep 29, 2016 18:26

Because I wrote a tree generating procedure that uses loops for creating a tree and modified a couple lines I copied from it. I'm playing around with modding trees and adding trees using the default nodes and active block modifiers. Thinking about starting with NPCs, but path-finding has always been a problem for me. Maybe I could add a specific node that can only be removed with an item, or use a set of coordinates.
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")
 

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

Re: Post your modding questions here

by ulla » Thu Sep 29, 2016 18:46

ulla wrote:Hi all and thanks advance , i make my new mod named summer i have put :
big umrella open and closed ,deckshair, lobster, big ballon ,air mattress etc...
now i need a little help for add simple function sit or lay on_rightclick ,
but but I found nothing on internet,
i have see beds but can only sleep, and boat are mixed with driver function , i have registered a node and i want the player can lay on the node with right click pls Help
sorry for my bad english

some help?
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 24 guests

cron