Post your modding questions here

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

Re: Post your modding questions here

by Linuxdirk » Mon Mar 20, 2017 08:19

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

Re: Post your modding questions here

by burli » Mon Mar 20, 2017 08:29

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 » Mon Mar 20, 2017 08:40

  • 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 » Mon Mar 20, 2017 08:51

Is fog configurable now ?
I found something
+ Spoiler
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: 2165
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Mon Mar 20, 2017 10:03

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 » Mon Mar 20, 2017 10:11

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: 2165
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk
 

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

Re: Post your modding questions here

by Nyarg » Mon Mar 20, 2017 14:30

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: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Mon Mar 20, 2017 15:43

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

Re: Post your modding questions here

by sofar » Mon Mar 20, 2017 16:09

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: 784
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 » Mon Mar 20, 2017 17:16

@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: 2165
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: Post your modding questions here

by Linuxdirk » Mon Mar 20, 2017 18:20

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

Re: Post your modding questions here

by burli » Tue Mar 21, 2017 10:21

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 » Thu Mar 23, 2017 10:58

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: 251
Joined: Sat Jan 17, 2015 17:47
Location: in front of my pc
GitHub: mbblp
IRC: mBb
In-game: MBB

Re: Post your modding questions here

by mbb » Fri Mar 24, 2017 14:32

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 18 times
If you want to contact me please send me a twitter pm https://twitter.com/mbbdev
 

User avatar
Hybrid Dog
Member
 
Posts: 2718
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Fri Mar 24, 2017 16:06

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

Re: Post your modding questions here

by kaeza » Sat Mar 25, 2017 00:09

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: 5826
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

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

Re: Post your modding questions here

by Philosoph228 » Sat Mar 25, 2017 08:43

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

User avatar
mbb
Member
 
Posts: 251
Joined: Sat Jan 17, 2015 17:47
Location: in front of my pc
GitHub: mbblp
IRC: mBb
In-game: MBB

Re: Post your modding questions here

by mbb » Sat Mar 25, 2017 09:17

thx for your help now i need other one
how i can generate a 1 block deep ozean per mod?
If you want to contact me please send me a twitter pm https://twitter.com/mbbdev
 

User avatar
Hybrid Dog
Member
 
Posts: 2718
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sat Mar 25, 2017 12:33

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: 57
Joined: Fri Dec 23, 2016 23:27
Location: My office.
IRC: GoldenHart
In-game: GoldenHart

Re: Post your modding questions here

by RealGoldenHart » Sun Mar 26, 2017 03:15

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

Re: Post your modding questions here

by sofar » Sun Mar 26, 2017 05:28

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

Re: Post your modding questions here

by sofar » Sun Mar 26, 2017 05:29

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: 246
Joined: Mon Feb 27, 2017 01:10
GitHub: dawgdoc

Re: Post your modding questions here

by dawgdoc » Sun Mar 26, 2017 06:45

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.
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest