Post your modding questions here

Locked
User avatar
addi
Member
Posts: 666
Joined: Thu Sep 20, 2012 03:16
GitHub: adrido
Location: Black-Forest, Germany

Re: Post your modding questions here

by addi » Post

Bas080 wrote:addi, that's because the formspec is defined with a string. The api documentation helped me. Also looking at mods that alter the player formspec should give you the solution.

https://github.com/minetest/minetest/bl ... i.txt#L922
yes i know, but what is about this: http://dev.minetest.net/Lua_Table_Formspec
i thougt its new, but it seems not so. :-(

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

Is it possible to get particle collision coordinates? What does playername parameter for minetest.add_particle is used for?

User avatar
durtective6
Member
Posts: 186
Joined: Sun Aug 12, 2012 14:19
In-game: derplez or BlockFrog
Location: a shed in the desert

Re: Post your modding questions here

by durtective6 » Post

Hello, I've been trying to make some tools in a mod I am making but I am having trouble making two of them. How would I make it so a pickaxe drops the smelted product of whatever it digs? Also how would I make it so when a ore is dug by a certain pickaxe it drops a different item (e.g. gold ore--> gold shards/pieces etc)? Thanks

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

Re: Post your modding questions here

by Casimir » Post

drkwv wrote:Is it possible to get particle collision coordinates?
No, But you can use entities instead. See PilzAdams throwing mod.
drkwv wrote:What does playername parameter for minetest.add_particle is used for?
Particles are only shown to that player.

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

How do I capture mouse right click on nothing with node or craftitem?

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

drkwv wrote:How do I capture mouse right click on nothing with node or craftitem?
Items:

Code: Select all

    on_place = func(itemstack, placer, pointed_thing),
    ^ Shall place item and return the leftover itemstack
    ^ default: minetest.item_place
https://github.com/minetest/minetest/bl ... 2338-L2340

Nodes:

Code: Select all

    after_place_node = func(pos, placer, itemstack, pointed_thing),
    ^ Called after constructing node when node was placed using
      minetest.item_place_node / minetest.place_node
    ^ If return true no item is taken from itemstack
    ^ default: nil
https://github.com/minetest/minetest/bl ... 2436-L2440
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

Krock wrote:on_place, after_place_node
Both don't work when I click on nothing (on air).

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

drkwv wrote:
Krock wrote:on_place, after_place_node
Both don't work when I click on nothing (on air).
Well then, for nodes:

Code: Select all

    on_rightclick = func(pos, node, clicker, itemstack, pointed_thing),
    ^ default: nil
    ^ if defined, itemstack will hold clicker's wielded item
    ^ Shall return the leftover itemstack
    ^ Note: pointed_thing can be nil, if a mod calls this function
https://github.com/minetest/minetest/bl ... 2453-L2457

Haven't found anything about craftitems on_rightclick.
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

Do you mean you want to create a node/item/tool that you hold in the hand and when pointing onto the sky and right click a function should be executed?
Then it would be something like this.

Code: Select all

on_place = function(itemstack, user, pointed_thing)
	if pointed_thing then return end
	print("Oh, see those clouds!")
end,

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

Krock wrote:on_rightclick
On_rightclick is used when I right clicking on the placed node by hand. Tested it too.
Casimir wrote:Do you mean you want to create a node/item/tool that you hold in the hand and when pointing onto the sky and right click a function should be executed?
Yes, this is correct. But on_place is triggered only when I right click not on air.

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

Re: Post your modding questions here

by Casimir » Post

Then I don't think it is possible, you probably have to use on_use.

Does anybody know why this returns "0" ? I'm calling it five seconds after the game started.
local number = table.maxn(minetest.registered_items)

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:local number = table.maxn(minetest.registered_items)
And

Code: Select all

local number = #minetest.registered_items
?
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

Zero

This works:

Code: Select all

	local number = 0
	for name, item in pairs(minetest.registered_items) do
		number = number + 1
	end

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: Post your modding questions here

by philipbenr » Post

Quick Question:
(probably been asked before, but I can't seem to find it)

When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels. I want the output to be 5 glasses of milk, and I also want to have the bucket be returned to a slot in my inventory. How to do so?

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

philipbenr wrote:<snip>
Do you mean replacements?

Code: Select all

minetest.register_craft( {
	type = "shapeless",
        output = "homedecor:terracotta_base 8",
        recipe = {
		"default:dirt",
		"default:clay_lump",
		"bucket:bucket_water"
        },
	replacements = { {"bucket:bucket_water", "bucket:bucket_empty"}, },
})
Random from homedecor.
It will return you 8 terracotta base and an empty bucket.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: Post your modding questions here

by philipbenr » Post

I believe so. Thank you, Krock.

User avatar
lag01
Member
Posts: 321
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag
Contact:

Re: Post your modding questions here

by lag01 » Post

Hello,
i want to write lua code to punish players who hit another players at spawn.
How can i detect when that happens?

Or maybe there already is mod for that?

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

Re: Post your modding questions here

by Sokomine » Post

philipbenr wrote: When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels.
There's a receipe (afaik in the food mod?) that uses two buckets of milk for one cheese - without returning any buckets. I'm not sure if two items may be returned simultaneously. Perhaps in such cases a special "machine" might be best. I didn't get around to give the barrels from my cottages mod any functionality yet.
A list of my mods can be found here.

User avatar
Topywo
Member
Posts: 1721
Joined: Fri May 18, 2012 20:27

Re: Post your modding questions here

by Topywo » Post

Sokomine wrote:
philipbenr wrote: When crafting an item, how can I get an item as an output and then have another item be put back into my inventory? I wish to craft milk in drinking glasses that uses a bucketful of milk from kpgmobs and vessels.
There's a receipe (afaik in the food mod?) that uses two buckets of milk for one cheese - without returning any buckets. I'm not sure if two items may be returned simultaneously. Perhaps in such cases a special "machine" might be best. I didn't get around to give the barrels from my cottages mod any functionality yet.
replacements = { { "bucket:bucket_water", "bucket:bucket_empty"}, { "charcoal:charcoal", "default:torch 4"}}


This seems to work, giving you the standard output, an empty bucket and 4 torches (tested with charcoal mod). I thought I tried something similar a year ago without any luck, so maybe it's a new feature, idk.


Edit: The replacements are placed in the crafting grid. This means that as long as you can craft, the replacements are not placed in the crafting grid, because the crafting materials are in there. So not very suitable for 'mass' crafting production. It would have been nicer if the replacements would be placed directly in your inventory.

leeminer
Member
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Post

I'm getting the hang of modding minetest now. I'm curious about the limits of the modding api. Can someone give me a rough idea of what is possible with the minetest api? What can and cannot be done.

User avatar
lag01
Member
Posts: 321
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag
Contact:

Re: Post your modding questions here

by lag01 » Post

leeminer wrote:I'm getting the hang of modding minetest now. I'm curious about the limits of the modding api. Can someone give me a rough idea of what is possible with the minetest api? What can and cannot be done.
For now, i noticed two wierd limitations:
you can use your function on chat message event, but cannot change or cancel message itself.
no api to call your code, when player is hit or killed by other player. workaround i used in my mod, was to use minetest.register_on_dieplayer + minetest.get_objects_inside_radius

You probably already had seen http://dev.minetest.net/Category:Methods, http://dev.minetest.net/Player etc. Also more insane way: http://dev.minetest.net/Global_tables

leeminer
Member
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Post

Been banging my head for some time so here goes.

How can you access the player object in singleplayer and modify it? I am trying to modify the player object to decrease gravity or increase jump height but I get an error when I insert my code.

Code: Select all

player:set_physics_override({gravity=3.0})
I also tried

Code: Select all

user:set_physics_override({gravity=3.0})
I found info here, http://dev.minetest.net/Player, however once again I think I am missing something horribly simple and obvious. Any help would be appreciated. I want my character to jump a round like superman ;)

User avatar
lag01
Member
Posts: 321
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag
Contact:

Re: Post your modding questions here

by lag01 » Post

leeminer wrote:Been banging my head for some time so here goes.

How can you access the player object in singleplayer and modify it? I am trying to modify the player object to decrease gravity or increase jump height but I get an error when I insert my code.

Code: Select all

player:set_physics_override({gravity=3.0})
I also tried

Code: Select all

user:set_physics_override({gravity=3.0})
I found info here, http://dev.minetest.net/Player, however once again I think I am missing something horribly simple and obvious. Any help would be appreciated. I want my character to jump a round like superman ;)
If you want do this to all players in game, i believe you can do this just by minetest.conf

Else, you must call your code somewhere, where "player" is set, for example inside http://dev.minetest.net/minetest.register_on_joinplayer

leeminer
Member
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Post

Getting closer to changing the speed, gravity and jump of the player. Sooo close...
Can someone tell me why this code doesn't work? It throws a lua init error when launching the world with my mod enabled.

Code: Select all

local player = minetest.get_player_by_name("singleplayer")
player:set_physics_override({gravity=3.0,jump=3.0,speed=3.0})
I also tried the example at this page with no luck...

http://dev.minetest.net/minetest.get_player_by_name

So close I can taste it!

User avatar
lag01
Member
Posts: 321
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag
Contact:

Re: Post your modding questions here

by lag01 » Post

leeminer wrote:Getting closer to changing the speed, gravity and jump of the player. Sooo close...
Can someone tell me why this code doesn't work? It throws a lua init error when launching the world with my mod enabled.
may-be you are calling your code at wrong place or in wrong time. for example right in mod body, while player "singleplayer" not exists yet.
try something like this:

Code: Select all

minetest.register_on_joinplayer(function(player)
	player:set_physics_override({gravity=3.0,jump=3.0,speed=3.0})
end)

Locked

Who is online

Users browsing this forum: No registered users and 3 guests