Post your modding questions here

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Post your modding questions here

by Linuxdirk » Post

burli wrote: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
You need to set up a list ring in your formspec definition.

viewtopic.php?f=18&t=12629

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

Re: Post your modding questions here

by burli » Post

Linuxdirk wrote:
burli wrote: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
You need to set up a list ring in your formspec definition.

viewtopic.php?f=18&t=12629
Ah, thanks. Will try this now

Mwamba
Member
Posts: 19
Joined: Fri Feb 26, 2016 06:55
GitHub: mwambanatanga

Re: Post your modding questions here

by Mwamba » Post

  • Any good way to find out if player's wielded item is a tool (and not a block)?
  • Any good way to find out which of the registered items are tools (basically, get a list of available tools)?

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

Re: Post your modding questions here

by Nyarg » Post

Is fog configurable now ?
I found something
Spoiler
Image
Image
but I am new on github and misunderstand do it means implemented or not.
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
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Post your modding questions here

by Linuxdirk » Post

Mwamba wrote:
  • Any good way to find out if player's wielded item is a tool (and not a block)?
  • Any good way to find out which of the registered items are tools (basically, get a list of available tools)?
There is minetest.registered_tools which is a table of all the registered tools. You can read this table to get, well, all registered tools. You can also iterate over the table and compare to the currently wielded item.

Something like this (untested):

Code: Select all

local wielditem_is_tool = function(player)
    local registered_tools = minetest.registered_tools
    local wielded_item_name = player:......... -- whatever you have to do when
                                               -- you want to get the currently
                                               -- wielded item name

    for name,definition in pairs(registered_tools) do
        if name == wielded_item_name then return true end
    end

    return false
end
Call with wielditem_is_tool(player) to get either true (wielded item is a registered tool) or false (wielded item is not a registered tool).

Mwamba
Member
Posts: 19
Joined: Fri Feb 26, 2016 06:55
GitHub: mwambanatanga

Re: Post your modding questions here

by Mwamba » Post

Linuxdirk wrote:There is minetest.registered_tools
Oh, great! This perfectly answers my second question. Thank you!

Still, is it possible to get player's wielded item and check for it's parameters? All I discovered up to this point is that tools have a tool_capabilities parameter, but I can't figure out how to check whether it's set...

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Post your modding questions here

by Linuxdirk » Post

Mwamba wrote:Still, is it possible to get player's wielded item
You can use player:get_wielded_item().

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

Re: Post your modding questions here

by Nyarg » Post

I don't see particle rotation property (something like angleStartByX etc or angleStaticX)
am I missing it somewhere ?

And what about glow and blend ? Where is it's description described ?
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 )

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

Linuxdirk wrote:
Mwamba wrote:
  • Any good way to find out if player's wielded item is a tool (and not a block)?
  • Any good way to find out which of the registered items are tools (basically, get a list of available tools)?
There is minetest.registered_tools which is a table of all the registered tools. You can read this table to get, well, all registered tools. You can also iterate over the table and compare to the currently wielded item.

Something like this (untested):

Code: Select all

local wielditem_is_tool = function(player)
    local registered_tools = minetest.registered_tools
    local wielded_item_name = player:......... -- whatever you have to do when
                                               -- you want to get the currently
                                               -- wielded item name

    for name,definition in pairs(registered_tools) do
        if name == wielded_item_name then return true end
    end

    return false
end
Call with wielditem_is_tool(player) to get either true (wielded item is a registered tool) or false (wielded item is not a registered tool).
Iterating over the table is a waste, better to do

Code: Select all

return minetest.registered_tools[wielded_item_name] ~= nil
Every time a mod API is left undocumented, a koala dies.

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:I don't see particle rotation property (something like angleStartByX etc or angleStaticX)
am I missing it somewhere ?
No, it does not exist. Particles are either - always facing the player no matter the angle, or - always facing the player but vertical (rotating horizontal).
Nyarg wrote:And what about glow and blend ? Where is it's description described ?
Glow is implemented, blend was cut and is not implemented.

See lua_api.txt. Just search for "glow".

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

@nyarg, on your pos on the previous page
You are registering an entity inside a callback. You should never do this.
Because you misuse the API, you get an error.
I think you rather want to add an entity into the world at this place.
minetest.add_entity()
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Post your modding questions here

by Linuxdirk » Post

Byakuren wrote:Iterating over the table is a waste, better to do

Code: Select all

return minetest.registered_tools[wielded_item_name] ~= nil
Yep. Better solution.

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

Re: Post your modding questions here

by burli » Post

Is is possible to profile on_timer with the builtin profiler?

Mwamba
Member
Posts: 19
Joined: Fri Feb 26, 2016 06:55
GitHub: mwambanatanga

Re: Post your modding questions here

by Mwamba » Post

Byakuren wrote:Iterating over the table is a waste, better to do

Code: Select all

return minetest.registered_tools[wielded_item_name] ~= nil
Oh, yeah, that's what I need. Thank you!!!

User avatar
mbb
Member
Posts: 256
Joined: Sat Jan 17, 2015 17:47
GitHub: mbruchert
IRC: mBb
In-game: MBB

Re: Post your modding questions here

by mbb » Post

how i can generate some decorations like bushes?
my mapgen.lua dosesn´t works
here is my mod
Forestos_plants.zip
(5.75 KiB) Downloaded 57 times
cdb_2fcfab1b41f9

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

mbb, have a look at code of other mods:
https://github.com/D00Med/moreplants/bl ... t.lua#L681
https://github.com/D00Med/moreplants/bl ... t.lua#L905

l think you did a typo in the first line of init.lua:
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
your mapgen.lua isn't loaded…

And l guess you don't need to use the flowers table.

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

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

Mwamba wrote:
  • Any good way to find out if player's wielded item is a tool (and not a block)?
An alternative and probably faster:

Code: Select all

local stack = player:get_wielded_item()
local def = stack:get_definition()
if def.type == "tool" then
  -- do something
end
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
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

Get_definition is slower as it needs to go into c++
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Philosoph228
New member
Posts: 1
Joined: Fri Mar 24, 2017 11:49
GitHub: Philosoph228
In-game: Philosoph228
Location: Yekaterinburg

Re: Post your modding questions here

by Philosoph228 » Post

How can I get the maximum and minimum heights of the world?

User avatar
mbb
Member
Posts: 256
Joined: Sat Jan 17, 2015 17:47
GitHub: mbruchert
IRC: mBb
In-game: MBB

Re: Post your modding questions here

by mbb » Post

thx for your help now i need other one
how i can generate a 1 block deep ozean per mod?
cdb_2fcfab1b41f9

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

Philosoph228 wrote:How can I get the maximum and minimum heights of the world?
http://wiki.minetest.net/End_of_the_wor ... _the_world
mbb wrote:how i can generate a 1 block deep ozean per mod?
You can use vmanip http://dev.minetest.net/vmanip#Examples

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

User avatar
RealGoldenHart
Member
Posts: 59
Joined: Fri Dec 23, 2016 23:27
GitHub: GoldenHart
IRC: GoldenHart
In-game: GoldenHart
Location: Here, and not there.

Re: Post your modding questions here

by RealGoldenHart » Post

Three questions, I think they are all impossible, but that's what this forum is for...pro coders solving my noobish problems.

1. How would I go about setting a node to be collidable with all but one other node? To be more specfic, I want node a to be able to go through node b, but I don't want node c, or any other node, to be able to go through node b. I also want to be able to build on node b.... soo I'm confused.

2. Can I make a node able to travel up after taking a certain action, such as right clicking the node.

3. How would I go about generating a realm in the sky? For example, rather than in caverealms where the realms are spawned underground, is it possible to do that in the sky?
Now...I realize this makes the mod impossible for servers to add, because they would have to make a new world for this addition. Is there any alternative that achieves the same goal?

I am new to Lua coding, and Mt modding in general. I do have a bit of c++ experience. Not as much as most though. Thanks for reading and I hope you have some answers for me.

If this mod idea doesn't work, I will happily move on over to something else, maybe I shouldn't try something so big for my first mod, but I think I have an idea of how to develop this.
K. I'm bored with signatures.

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

RealGoldenHart wrote:1. How would I go about setting a node to be collidable with all but one other node? To be more specfic, I want node a to be able to go through node b, but I don't want node c, or any other node, to be able to go through node b. I also want to be able to build on node b.... soo I'm confused.
Nodes can't move. Period.

Nodes can temporarily fall, but they'll stop as soon as they hit another (non-air) node.

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

RealGoldenHart wrote:2. Can I make a node able to travel up after taking a certain action, such as right clicking the node.
Nodes can't move. Period.

You can fake movement by removing the node at position A, and then making a new node that looks just like it at position B. It will look like it moved, but it didn't.

API relevant functions:

minetest.remove_node(pos)
minetest.set_node(pos, node)

dawgdoc
Member
Posts: 260
Joined: Mon Feb 27, 2017 01:10
GitHub: dawgdoc

Re: Post your modding questions here

by dawgdoc » Post

You may find some usable code in the Pontoons mod. I recall it is used to make under water builds float to the surface and become floating buildings. But, I think that mod converted the building to an entity, floated the entity up, and then converted it back to nodes. It is entirely possible that it will not be of any use to you. There was a distinct stopping point for the events to occur; that is when the entity had air above in instead of water. I don't know how you can change the code to suit your purposes.
Give a man a fish, feed him for a day. Give a kid a fish, it's going to die.

Locked

Who is online

Users browsing this forum: No registered users and 5 guests