Post your modding questions here

Locked
User avatar
HeroOfTheWinds
Member
Posts: 470
Joined: Wed Apr 23, 2014 23:16
GitHub: HeroOfTheWinds
IRC: WindHero
Location: Hawaii

Re: Post your modding questions here

by HeroOfTheWinds » Post

Nathan.S wrote:
Krock wrote:
Nathan.S wrote:<snip> I believe that RBA added support a while back. <snip> but I can't find any documentation on it. <snip>
Here you can find a simple use of meshnodes:
https://github.com/RealBadAngel/meshnod ... r/init.lua
Thanks, but I've already got that part figured out, it's the figuring out how to have two different models, or three, for the same node and the engine will place either the top, bottom, or side that's tripping me up.
This is a universal problem with nodes: you can't dynamically change textures/meshes/nodeboxes. You need to register three versions of it, then decide which one to place.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

HeroOfTheWinds wrote: Thanks, but I've already got that part figured out, it's the figuring out how to have two different models, or three, for the same node and the engine will place either the top, bottom, or side that's tripping me up.
This is a universal problem with nodes: you can't dynamically change textures/meshes/nodeboxes. You need to register three versions of it, then decide which one to place.[/quote]
but you can dynamically change objects, the itemframes mod does it

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

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

How to make indestructible sword?

by BrunoMine » Post

Code: Select all

minetest.register_tool("default:sword_wood", {
	description = "Espada de Madeira",
	inventory_image = "default_tool_woodsword.png",
	tool_capabilities = {
		full_punch_interval = 1.2,
		max_drop_level=0,
		groupcaps={
			snappy={times={[2]=0.01, [3]=0.01}, uses=2, maxlevel=1},
		},
		damage_groups = {fleshy=2},
	}
})
Where should I change?

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

https://github.com/HybridDog/superpick/blob/master/init.lua

by Hybrid Dog » Post

brunob.santos wrote:

Code: Select all

minetest.register_tool("default:sword_wood", {
	description = "Espada de Madeira",
	inventory_image = "default_tool_woodsword.png",
	tool_capabilities = {
		full_punch_interval = 1.2,
		max_drop_level=0,
		groupcaps={
			snappy={times={[2]=0.01, [3]=0.01}, uses=2, maxlevel=1},
		},
		damage_groups = {fleshy=2},
	}
})
Where should I change?
set the uses to 0 could work https://github.com/HybridDog/superpick/ ... it.lua#L29

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

Jericho
New member
Posts: 6
Joined: Fri Jun 27, 2014 18:35
In-game: Jericho

Re: Post your modding questions here

by Jericho » Post

I want to make it to where when I shift click an item in my chest, it will move the entire stack to the top empty slot in my inventory, and vice versa, how would I do that?

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Post

Jericho wrote:I want to make it to where when I shift click an item in my chest, it will move the entire stack to the top empty slot in my inventory, and vice versa, how would I do that?
That's one of the reasons my daughter likes minecraft more. That and the fact that all her friends have it
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Post your modding questions here

by Sokomine » Post

Jericho wrote: I want to make it to where when I shift click an item in my chest, it will move the entire stack to the top empty slot in my inventory, and vice versa, how would I do that?
I'm afraid that can't be done easily with a mod. Perhaps my chesttools mod might help you. It allows to swap your inventory and that of a chest, to drop or take out everything in one go, and even extends that to bags. It's not exactly what you asked for, but probably close enough?
A list of my mods can be found here.

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

Re: Post your modding questions here

by Linuxdirk » Post

Sokomine wrote:I'm afraid that can't be done easily with a mod.
So you’re saying that whole inventory thing needs a complete re-implementation? :)

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Post your modding questions here

by Sokomine » Post

Linuxdirk wrote: So you’re saying that whole inventory thing needs a complete re-implementation? :)
Not necessarily. Just what was asked for is more complicated because there are no good hooks for that particular functionality. But then, perhaps on_metadata_inventory_take does provide information about which keys where pressed. I'm not sure right now. Anyway, a mod would still be only server-side and not help much on multiplayer servers if it's not installed there. Guess the client could be changed to do that, but it wouldn't be trivial.
A list of my mods can be found here.

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

Re: Post your modding questions here

by Linuxdirk » Post

Sokomine wrote:but it wouldn't be trivial.
Could maybe solved simultaneously with inventory rewrite because of bug 1374.

I know that a lot of people know or played Minecraft: Their inventory management is actually pretty decent with a lot of great key and mouse button combinations for moving things around (and it’s super smooth even on very high latency servers).

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

Re: Post your modding questions here

by Linuxdirk » Post

Hey, since I accidentally posted my modding question in the wrong thread I re-post it here :)

As far as I understand mods are loaded individually for each player on a server. Is there a way to load a mod only once – or is there a better solution for having a mod running only once on the server independent of the amount of players?

For example: I write a mod that sets a timer and performs /time 12000 every 5 minutes (I know I can store the time and therefore freeze it, but that’s not my point here. I just use /time because it affects the whole server – You can add any command here if you want *g* AGAIN: The command or changing/setting time is COMPLETELY IRRELEVANT for the question I have!).

5 Players join the game. One player each minute. Since mods are loaded for each player, how do I prevent the time setting to 12000 every minute triggered by each one of the players after 5 minutes? (Or – again – any other command imaginable, since the command is irrelevant for my question, please excuse me repeating that over and over again *g*)

The players are random players and the timer must not be bound to anyone of the players.

Is there something like a “fake player” representing the server where I can bind the timer to?

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: Post your modding questions here

by ExeterDad » Post

Linuxdirk wrote:Hey, since I accidentally posted my modding question in the wrong thread I re-post it here :)

As far as I understand mods are loaded individually for each player on a server. Is there a way to load a mod only once – or is there a better solution for having a mod running only once on the server independent of the amount of players?

For example: I write a mod that sets a timer and performs /time 12000 every 5 minutes (I know I can store the time and therefore freeze it, but that’s not my point here. I just use /time because it affects the whole server – You can add any command here if you want *g* AGAIN: The command or changing/setting time is COMPLETELY IRRELEVANT for the question I have!).

5 Players join the game. One player each minute. Since mods are loaded for each player, how do I prevent the time setting to 12000 every minute triggered by each one of the players after 5 minutes? (Or – again – any other command imaginable, since the command is irrelevant for my question, please excuse me repeating that over and over again *g*)

The players are random players and the timer must not be bound to anyone of the players.

Is there something like a “fake player” representing the server where I can bind the timer to?
Isn't the mod only loaded one time server side on start up? Then changed behavior is available from that point on? If you ran your timer with minetest.register_on_joinplayer it would fire with every player joining.

Perhaps I'm misunderstanding your issue also :)

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

Re: Post your modding questions here

by Linuxdirk » Post

ExeterDad wrote:If you ran your timer with minetest.register_on_joinplayer it would fire with every player joining.
At one point the time must be registered, right? Or can I simply write minetest.after([…]) without any registering function?

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

In formspec "list[context;fuel;2,3;1,1;]" What am I supposed to use as "context"?

@ Linuxdirk, the mods only run on the server and they only run once independent from how many players there are. Maybe post a part of your code, so the problem becomes clear.
Last edited by Casimir on Sat Nov 22, 2014 20:57, edited 2 times in total.

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

Re: Post your modding questions here

by Krock » Post

Casimir wrote:In formspec "list[context;fuel;2,3;1,1;]" What am I supposed to use as "context"?
"context" is the current node.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

But I get the error that the inventory "undefined" was not found.
I think the problem is because the formspec is defined in a separate function.

Code: Select all

freiprotector.generate_formspec = function (meta)
	local formspec = "size[8,9]"
		.."label[0,0;Use Minegeld to protect the area.]"
		.."list[context;fuel;0,1;1,1;]"
		.."image[1,1;1,1;freiprotect_fuel.png]"
		.."label[0,2;Members:]"
		.."list[current_player;main;0,5;8,4;]"
end
The node:

Code: Select all

	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Protected by "..meta:get_string("owner"))
		meta:set_string("members", "")
		local inv = meta:get_inventory()
		inv:set_size("fuel", 1)
	end,
	on_rightclick = function(pos, node, clicker, itemstack)
		local meta = minetest.get_meta(pos)
		if freiprotector.can_dig(1, pos, clicker, true) then
			minetest.show_formspec(
				clicker:get_player_name(),
				"freiprotector_"..minetest.pos_to_string(pos),
				freiprotector.generate_formspec(meta)
			)
		end
	end,

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

Re: Post your modding questions here

by Linuxdirk » Post

[tl;dr]TIL: Lua error messages are useless and Minetest mods aren’t completely parsed before execution :)
Casimir wrote:Maybe post a part of your code, so the problem becomes clear.
While messing around I noticed that mods seem not to be parsed completely before executed.

So while …

Code: Select all

minetest.register_on_joinplayer(function(player)
   minetest.after(6, doStuffHere)
end)

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end
… prints [the current time]: doStuffHere being executed every 6 seconds as expected …

Code: Select all

minetest.after(6, doStuffHere)

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end
… breaks with a pretty useless error message telling me about an Invalid core.after invocation […] in function 'assert'. instead of telling me that doStuffHere() was not recognized/defined.

Because when I use …

Code: Select all

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end

minetest.after(6, doStuffHere)
… it works as expected.

I just was confused about the error message and thought the timer has to be registered with something.

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

"context" is the location of the inventory. If used in a formspec assigned to a node, it means "use the inventory of this node". Since you are showing the formspec via `show_formspec`, there's no "current node" to speak of.

You will have to modify your `generate_formspec` function to define the node (and thus inventory) location explicitly,

Code: Select all

freiprotector.generate_formspec = function (location)
	local formspec = "size[8,9]"
		.."label[0,0;Use Minegeld to protect the area.]"
		.."list["..location..";fuel;0,1;1,1;]"
		.."image[1,1;1,1;freiprotect_fuel.png]"
		.."label[0,2;Members:]"
		.."list[current_player;main;0,5;8,4;]"
end
Then in `on_rightclick`:

Code: Select all

	on_rightclick = function(pos, node, clicker, itemstack)
		local meta = minetest.get_meta(pos)
		if freiprotector.can_dig(1, pos, clicker, true) then
			minetest.show_formspec(
				clicker:get_player_name(),
				"freiprotector_"..minetest.pos_to_string(pos),
				freiprotector.generate_formspec(meta:get_inventory():get_location())
			)
		end
	end,
Please note: the code above is untested.
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
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

Ok, location is a table, so I had to use the position.

Code: Select all

	local l_xyz = ""..pos.x..","..pos.y..","..pos.z..""

		.."list[nodemeta:"..l_xyz..";fuel;0,1;1,1;]"
It somehow looks ugly, but it works.

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Linuxdirk wrote:[tl;dr]TIL: Lua error messages are useless and Minetest mods aren’t completely parsed before execution :)
Casimir wrote:Maybe post a part of your code, so the problem becomes clear.
While messing around I noticed that mods seem not to be parsed completely before executed.

So while …

Code: Select all

minetest.register_on_joinplayer(function(player)
   minetest.after(6, doStuffHere)
end)

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end
… prints [the current time]: doStuffHere being executed every 6 seconds as expected …

Code: Select all

minetest.after(6, doStuffHere)

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end
… breaks with a pretty useless error message telling me about an Invalid core.after invocation […] in function 'assert'. instead of telling me that doStuffHere() was not recognized/defined.

Because when I use …

Code: Select all

function doStuffHere()
    -- doing some random stuff here and call the timer again
    minetest.debug(os.date('%X')..': doStuffHere being executed')
    minetest.after(6, doStuffHere)
end

minetest.after(6, doStuffHere)
… it works as expected.

I just was confused about the error message and thought the timer has to be registered with something.
The mod is loaded from the top left to the bottom right, I think. So doStuffHere is nil when minetest.after puts it into its table of functions and timers.
The mods of a server aren't run on every cIient, just the server uses them, the clients may be modified by them.

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

Zeno Effect
Member
Posts: 14
Joined: Tue Nov 25, 2014 22:46
In-game: Zeno_Effect

Re: Post your modding questions here

by Zeno Effect » Post

I have tried looking it up but can not find an answer anywhere. Can someone tell me how you use a command block and what exactly you can do with one?

User avatar
Hybrid Dog
Member
Posts: 2836
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Post your modding questions here

by Hybrid Dog » Post

Zeno Effect wrote:I have tried looking it up but can not find an answer anywhere. Can someone tell me how you use a command block and what exactly you can do with one?
Do you mean the one of mesecons?

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

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Post

Hybrid Dog wrote:
Zeno Effect wrote:I have tried looking it up but can not find an answer anywhere. Can someone tell me how you use a command block and what exactly you can do with one?
Do you mean the one of mesecons?
If you do mean mesecoms then look here. http://mesecons.net/items.php
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

Zeno Effect
Member
Posts: 14
Joined: Tue Nov 25, 2014 22:46
In-game: Zeno_Effect

Re: Post your modding questions here

by Zeno Effect » Post

I do mean the mesecon one and all it says on their site is it is like the one in minecraft but give no direction how how to input commands, if it needs to be powered, etc.

This is exactly what mesecons.net has to say about the command block....

"Command block

Craft recipe
There is no crafting recipe as this should only be available for server admins.

Description
Quite similar to the Minecraft counterpart. Executes server commands."

but this does not really tell me anything about how to use it and how it is activated.

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Post

If you ask on the mesecon thread you might get an answer. Jeija is back from what I hear and hopefully Mesecons will be maintained and forum questions answered in a timely manor.
viewtopic.php?id=628
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

Locked

Who is online

Users browsing this forum: No registered users and 11 guests