Post your modding questions here

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Post

Sergey wrote:How to make each inventory slot hold more than 99 items (if items are stackable)?
Say, 1000 items.
Do you even try to research anything on your own
before posting these questions?


for nodes and craft items:
stack_max = 1000,

not sure about actual inventories.
best to look at specialty mods that deal with inventories for examples

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

Re: Post your modding questions here

by Nyarg » Post

Stix wrote:Question: is it possible to attach a entity to a nodebox?
As I know an answer is "No".
For example falling node will be converted by engine transparently to entity and after fall converted back to the node.
All nodes inside engine merged into one model.
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
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

Napiophelios, you may not bother answering me.

With some effort I figured out that it was you who answered me.
Posts from foes are not displayed, fortunately.

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Post

Sergey wrote:Napiophelios, you may not bother answering me.

With some effort I figured out that it was you who answered me.
Posts from foes are not displayed, fortunately.
Edit: moving on

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

Sergey wrote:
Sergey wrote:How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.
Can anybody answer me?
This could be helpful for everyone who wants to print stuff:

Code: Select all

function print_concat_table(a)
	local str=""
	local stra=""
	local t
	for i=1,20 do
		t=a[i]
		if t==nil then
			stra=stra.."nil "
		else
			str=str..stra
			stra=""
			if type(t)=="table" then
				if t.x and t.y and t.z then
					str=str..minetest.pos_to_string(t)
				else
					str=str..dump(t)
				end
			elseif type(t)=="boolean" then
				if t then
					str=str.."true"
				else
					str=str.."false"
				end
			else
				str=str..t
			end
			str=str.." "
end
	end
	return str
end

-- actually my atprint() function from advtrains
pint=function(t, ...)
	local text=print_concat_table({t, ...})
	minetest.chat_send_all("[???]"..text)--this does the trick
end

properly dumps tables and positions, you can pass everything to it and it won't cause problems
example:

Code: Select all

pint("This is", {an="example"}, "of", "a cool", function() end)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

orwell wrote:This could be helpful for everyone who wants to print stuff:
...
Thank you.
But why did you blow so much code if there is already dump function as part of Minetest?

I usually do this:

Code: Select all

minetest.debug( dump( obj ) )
But this will write to debug.txt file. Not to in-game console.

Because debug.txt is a huge text file, instead of opening it and scroll-scroll-scroll to the end, you can do this.
In GNU/Linux console use "tail" command like this:

Code: Select all

tail -n 100 ~/.minetest/debug.txt
This will output at least 100 last lines of any file with any size. Usually it's enough to view your dumping. If not — specify more lines to output, e.g. 200.
Last edited by Sergey on Mon Sep 18, 2017 22:53, edited 6 times in total.

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

Stix wrote:Question: is it possible to attach a entity to a nodebox?
No, but there's no reason to. Nodeboxes are nodes and they do not move, so there is no reason to attach it. Just place the entity at the right location.

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

I looked through this article about texture and I have a question.

How can I make particular texture more contrast?

Modifier [brighten makes texture bright (black becomes grey, grey becomes almost white). It's not about increasing contrast.

Is there a direct way or some workaround to make texture more contrast?

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

Sergey wrote:
orwell wrote:This could be helpful for everyone who wants to print stuff:
...
Thank you.
But why did you blow so much code if there is already dump function as part of Minetest?

I usually do this:

Code: Select all

minetest.debug( dump( obj ) )
But this will write to debug.txt file. Not to in-game console.

Because debug.txt is a huge text file, instead of opening it and scroll-scroll-scroll to the end, you can do this.
In GNU/Linux console use "tail" command like this:

Code: Select all

tail -n 100 ~/.minetest/debug.txt
This will output at least 100 last lines of any file with any size. Usually it's enough to view your dumping. If not — specify more lines to output, e.g. 200.
But you can't specify multiple values on a single line... However, not of importance.
I know the tail command, its very useful in this case.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

orwell wrote:But you can't specify multiple values on a single line...

Code: Select all

minetest.debug( dump( { obj1, obj2, obj3 } ) )

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your modding questions here

by azekill_DIABLO » Post

Sergey wrote:How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.
print() is used to put messages on the debug console (active it in advanced setting)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

azekill_DIABLO wrote:
Sergey wrote:How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.
print() is used to put messages on the debug console (active it in advanced setting)
What is that setting name?

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: Post your modding questions here

by azekill_DIABLO » Post

Code: Select all

enable_console
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

Title: Is there a way to create our own Registration API's? I.E: <modname>.register_<itemtype>?

Reason: I want to give one of my mods a registration API for registering nodes of structure to simplify creating complex nodes.

Example: Registering a new material of a wall that takes up a 3X3 space.
Constructing mechs and wingless aircraft since 2016.

User avatar
Krock
Developer
Posts: 4649
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

John_Constructor wrote:Title: Is there a way to create our own Registration API's? I.E: <modname>.register_<itemtype>?
Yes. Here an example of a mod that could make you hungry:

Code: Select all

-- Declare the mod's namespace (table) for use in other mods
my_brownie_mod = {}
-- Table containing all registered brownies (or whatever you want)
my_brownie_mod.registered_brownies = {}

-- Function to register an item
function my_brownie_mod.register_brownie(def)
	-- Registers a brownie, given a table in the argument "def"

	-- Check whether required params are defined:
	assert(type(def.itemname) == "string", "register_brownie(): Missing itemname parameter!")

	-- Set defaults, if desired:
	def.name = def.name or "unnamed brownie"

	-- Run commands, like
	minetest.register_node("my_brownie_mod:".. def.itemname, {
		-- node definition goes here
	})

	-- Collect all definition tables in a single table
	table.insert(my_brownie_mod.registered_brownies, def)
end

-- Registering a specific item
my_brownie_mod.register_brownie({
	itemname = "real_brown",
	name = "Real Brown Brownie",
	heals = 10,
	-- as many params you would like
})

-- Searching for an item
for _, v in pairs(my_brownie_mod.registered_brownies) do
	if v.itemname == "real_brown" then
		print("Real brown brownie is registered!")
		do_the_bottle_flip(v) -- or anything else
		break
	end
end
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
BirgitLachner
Member
Posts: 393
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Post

So, here are some questions from my husband who want to make a mod to show pictures on the wall. As he is a professional programmer, he just need a bit help with the Minetest-API-specific hints.

He will use the ideas of the mod "gemalde" viewtopic.php?id=4635 but make it better.

You should place a node on the wall, then right click to choose the size of the picture and the picture itself, which is depending on the size (so you have different pictures for 1x1, 2x1, ... pictures). Second thing will be to have a frame around the picture, may be you can choose the wood-type after right-clicking the picture. The next idea is to add support to use channels from the german page foto-community so you have changing pictures (he already did it for the desktops and knows ho to use the channel).
Okay ... that are the advanced features.

Now the first questions:
1.) We want to have different sizes. In the gemalde mod the visual_scale is used to the make the pictures bigger than one node. But scaling seems to be only possible in two directions at the same time. So, how can we have a 1x2 pictures? In the "gemalde" mod you can do this by have a picture where a part is transparent. Okay ... but we want to have a frame that should be only around the 1x2 area.
For that, a 1x2 picture should be shown in front of 2 blocks and not, like it is in the moment at "gemalde" the pcitures centered around on block and overlap the 8 block aorund the center.
So, what will the best solution to have different sizes for the pictures? Can you give me the name of other mods where we can find ideas how to get it?
2.) The frames can be made of cause with node boxes. But can we combine the picture with the frame. The empty frame would be quite easy. Make a nodebox block and use the texture of wood. But can it be combined? A background and the nodebox above it? The big problem for me is that I want to have the wood texture and the pictures. How can I "mix" it. I donÄt have any idea for this problem.
3.) What needs to be in "register_node" that the frame is always "on" the wall and not flying away from it. Sorry, forgot it :-/

Okay ... that are the first questions for a hopefully wonderfull mod in future. ;-)
Birgit

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

BirgitLachner wrote:So, here are some questions from my husband who want to make a mod to show pictures on the wall. As he is a professional programmer, he just need a bit help with the Minetest-API-specific hints.

He will use the ideas of the mod "gemalde" viewtopic.php?id=4635 but make it better.

You should place a node on the wall, then right click to choose the size of the picture and the picture itself, which is depending on the size (so you have different pictures for 1x1, 2x1, ... pictures). Second thing will be to have a frame around the picture, may be you can choose the wood-type after right-clicking the picture. The next idea is to add support to use channels from the german page foto-community so you have changing pictures (he already did it for the desktops and knows ho to use the channel).
Okay ... that are the advanced features.

Now the first questions:
1.) We want to have different sizes. In the gemalde mod the visual_scale is used to the make the pictures bigger than one node. But scaling seems to be only possible in two directions at the same time. So, how can we have a 1x2 pictures? In the "gemalde" mod you can do this by have a picture where a part is transparent. Okay ... but we want to have a frame that should be only around the 1x2 area.
For that, a 1x2 picture should be shown in front of 2 blocks and not, like it is in the moment at "gemalde" the pcitures centered around on block and overlap the 8 block aorund the center.
So, what will the best solution to have different sizes for the pictures? Can you give me the name of other mods where we can find ideas how to get it?
2.) The frames can be made of cause with node boxes. But can we combine the picture with the frame. The empty frame would be quite easy. Make a nodebox block and use the texture of wood. But can it be combined? A background and the nodebox above it? The big problem for me is that I want to have the wood texture and the pictures. How can I "mix" it. I donÄt have any idea for this problem.
3.) What needs to be in "register_node" that the frame is always "on" the wall and not flying away from it. Sorry, forgot it :-/

Okay ... that are the first questions for a hopefully wonderfull mod in future. ;-)
Birgit
Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Every time a mod API is left undocumented, a koala dies.

User avatar
ZenonSeth
Member
Posts: 64
Joined: Mon Sep 18, 2017 19:23
GitHub: ZenonSeth
In-game: ZenonSeth ZenSeth

Re: Post your modding questions here

by ZenonSeth » Post

Hi, I'm trying to create a formspec to display some meta-data for a node, and let the user edit that meta-data.
Except the catch is, the formspec only displays for certain users (e.g. admins/moderators), while it actually has a completely different functionality for normal users.

That seems to be a problem because:
  • If I put the formspec in the node's metadata, the callback gives me the position so I can modify the node's meta-data, but I don't seem to have any control over to whom to show the formspec.
  • If I call minetest.show_formspec from the node's on_rightclick, I can control who sees the form, but the callback gives me no information about the node itself, so I can't go edit the node's meta data.
The workaround I can think of is to maybe put a hidden (off-screen) field that stores the node's position, so I can get it via the fields in register_on_player_receive_fields. But then I'm pretty sure tabbing around will let you accidentally edit that field, which would cause problems, so I'd rather avoid that. Is there a better way to do this?

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Post

ZenonSeth wrote:Hi, I'm trying to create a formspec to display some meta-data for a node, and let the user edit that meta-data.
Except the catch is, the formspec only displays for certain users (e.g. admins/moderators), while it actually has a completely different functionality for normal users.

That seems to be a problem because:
  • If I put the formspec in the node's metadata, the callback gives me the position so I can modify the node's meta-data, but I don't seem to have any control over to whom to show the formspec.
  • If I call minetest.show_formspec from the node's on_rightclick, I can control who sees the form, but the callback gives me no information about the node itself, so I can't go edit the node's meta data.
The workaround I can think of is to maybe put a hidden (off-screen) field that stores the node's position, so I can get it via the fields in register_on_player_receive_fields. But then I'm pretty sure tabbing around will let you accidentally edit that field, which would cause problems, so I'd rather avoid that. Is there a better way to do this?
Maybe you could have a mod like Advanced Ranks in the depends.txt and
have your mod verify "rank" to determine who sees what.

or create your own privs for people you want to have full access to formspecs

User avatar
ZenonSeth
Member
Posts: 64
Joined: Mon Sep 18, 2017 19:23
GitHub: ZenonSeth
In-game: ZenonSeth ZenSeth

Re: Post your modding questions here

by ZenonSeth » Post

Napiophelios wrote: Maybe you could have a mod like Advanced Ranks in the depends.txt and
have your mod verify "rank" to determine who sees what.

or create your own privs for people you want to have full access to formspecs
I think using privs might be good, but how would I go about to stop the formspec stored in the node's metadata from displaying based on privileges?

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Post

Maybe edit features/buttons of formspec only visible to players with privileges
or have 2 formspecs...priv check determines which one to show.

User avatar
ZenonSeth
Member
Posts: 64
Joined: Mon Sep 18, 2017 19:23
GitHub: ZenonSeth
In-game: ZenonSeth ZenSeth

Re: Post your modding questions here

by ZenonSeth » Post

Napiophelios wrote:Maybe edit features/buttons of formspec only visible to players with privileges
or have 2 formspecs...priv check determines which one to show.
That makes sense, but it doesn't solve my problem.

I can use privileges as you suggested, if I use minetest.show_formspec - but then I don't get the position variable in the callback, since the form is not linked to the node in any way.

And like I said, if I use the meta data to store the formspec under the "formspec" field, I get the callback with a "pos" in the node's on_receive_fields, but then it always get shown to everyone. The formspec data in this case is just dumped into the meta data, and we don't even get a chance to execute any logic before its shown, as far as I can tell.

I got the way with minetest.show_formspec working by storing the node position in an invisible field. I'm also storing a hopefully unique meta field in my node, so that if the field holding the position gets edited, I don't accidentally override the meta-data of another node somehow.

User avatar
Krock
Developer
Posts: 4649
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

ZenonSeth wrote:I can use privileges as you suggested, if I use minetest.show_formspec - but then I don't get the position variable in the callback, since the form is not linked to the node in any way.
You can do more than just show the formspec in on_rightclick. Notice that the position and player information are given there from the function parameters. Create a new table in your mod's namespace to temporary save the player name and position of the clicked node. This works, as the player can not open a 2nd node once the formspec is shown.
Here's the example from the locked chests:
on_rightclick: Collect the data
register_on_player_receive_fields: Reuse the collected data
register_on_leaveplayer: Free the memory once the player left

Other examples can be found in several shop nodes (which also have an owner mode) and shared chests.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
BirgitLachner
Member
Posts: 393
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Post

Byakuren wrote: Currently nodes aren't flexible enough for what you want. You either need to register a node for every combination, or use entities to display the pictures.
Okay, no problem ... if you mean that for every kind of size 1x1, 1x2, 2x1, 2x2 and so on ... we need a special node, that's okay.

The questions are:
1.) How can we make it flexible, to have a given frame and then a choosen picture.
2.) Is it possible to replace the starting-node, where you can choose the size and picture, the the wanted size node and the wanted picture.

Birgit

User avatar
ZenonSeth
Member
Posts: 64
Joined: Mon Sep 18, 2017 19:23
GitHub: ZenonSeth
In-game: ZenonSeth ZenSeth

Re: Post your modding questions here

by ZenonSeth » Post

Krock wrote: You can do more than just show the formspec in on_rightclick. [snipped]
Ah ok, I see. I wasn't sure about using a mod-global list of names cause I wasn't sure of the access order - e.g. if I store the pos in a table, my form shows, but then another of my form's right click is process before mine, using up the pos. I think just being new to the minetest modding api, and having bad experiences with global tables like that before, made me cautious.

The approach I 'solved' it with is essentially the same, only i stored the pos in the formspec itself, using:

Code: Select all

"field[-1,-1;0,0;"..fieldNodePos..";;" .. spos .. "]"..
where spos is a comma-separated coord list. Though even if 'hidden' the field can still be edited. A solution that just occured to me is to store the pos in the field name, as in have the name be some known prefix, say fieldNodePos, concatinated with the comma-separated coords. Would probably work, just have to iterate over all fields on the formspec callback.

But I mean, if the minetest_game uses the global lookup table to store right clicked position, I should too. Thanks

Locked

Who is online

Users browsing this forum: Google [Bot] and 6 guests