yaman wrote:How do you make something that can't be placed on the ground, like a lump? I need it to make something for my mod.
minetest_game/craftitems.lua wrote:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_craftitem("default:coal_lump", {
description = "Coal Lump",
inventory_image = "default_coal_lump.png",
})
Krock wrote: inventory_image = "default_coal_lump.png",
Casimir wrote:minetest.register_craftitem(name, item definition)
The item definition is almost the same. You can read more in the lua_api.txt
edit: Krock was faster
Krock wrote:Okay, an easier question now:
When I've a configuration file in the worldpath, how can I set a variable in it with LUA?
Hybrid Dog wrote:you could use os.execute for a compiled c program which can do thisKrock wrote:Okay, an easier question now:
When I've a configuration file in the worldpath, how can I set a variable in it with LUA?
API Docs wrote:Settings: An interface to read config files in the format of minetest.conf
- Can be created via Settings(filename)
methods:
- get(key) -> value
- get_bool(key) -> boolean
- set(key, value)
- remove(key) -> success
- get_names() -> {key1,...}
- write() -> success
^ write changes to file
- to_table() -> {[key1]=value1,...}
Krockody wrote:Topic: Converting virtual money into... virtual money
Reason: I try but I've no itea how to make something like a "exchange rate"
More info: Well, I've a mod which gives money as items, but there are also other currencies like "money", those use non-touchable-money.
I planned to make something like an change block for the money mod any my mod-with-item-currency but I've no idea how I should make the formula for the exchange rate.
This is advanced but I'd be very thankful about that help.
pandaro wrote:I do not think that's what I try. I have to run a function when a player put an item in the first row of the inventory. I do not want to use a "globalstep" because it is computationally exaggerated.
local DURATION = 1.0;
local timer = 0.0;
minetest.register_globalstep(
function(dtime)
timer = timer + dtime;
if timer < DURATION then return end
timer = timer - DURATION;
-- Your logic
end);
local DURATION = 1.0;
local function myFunction()
minetest.after(DURATION, myFunction);
-- Your logic
end
-- Boostrap it
minetest.after(DURATION, myFunction);
pandaro wrote:Then I still try to change "on_put" of the inventory of the player.
I discovered that through minetest.get_inventory ("player", "name_of_the_player")I can get a reference.
At this point can i change "on_put" for this player? or even for all players?
MrElmux wrote:How do i register an inventory for an Entity (To access it via get_inventory)
philipbenr wrote:When using after_place_node, can I determine the direction in which a certain node is placed? (ex, facedir
wcwyes wrote:how would I add an extra function to a special pick axe? like if I mine something from pos then do function?
prestidigitator wrote:wcwyes wrote:how would I add an extra function to a special pick axe? like if I mine something from pos then do function?
Oddly, there's not a lot of customization you can do for the behavior from the tool's end. You can either completely override what it does by adding an on_use() callback (same for tools as for nodes), or you're pretty much stuck with what it does using the default Minetest behavior.
Nore wrote:prestidigitator wrote:wcwyes wrote:how would I add an extra function to a special pick axe? like if I mine something from pos then do function?
Oddly, there's not a lot of customization you can do for the behavior from the tool's end. You can either completely override what it does by adding an on_use() callback (same for tools as for nodes), or you're pretty much stuck with what it does using the default Minetest behavior.
Wrong: there is the after_use callback in the API now:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2106
prestidigitator wrote:philipbenr wrote:When using after_place_node, can I determine the direction in which a certain node is placed? (ex, facedir
I believe the node's 'param2' value determines the direction it faces, but it may depend on the node's drawtype and other considerations. I believe 'param2' is set automatically for nodes a player places directly from inventory (for some types of node?), but you will probably have to set it explicitly if adding the node from Lua code.
shaheerziya wrote:how to make a mod?
Krock wrote:shaheerziya wrote:how to make a mod?
Complicated or easy way?
Pitriss wrote:Complicated: learn lua, read http://dev.minetest.net/Intro, get an idea, write mod, profit
Easy way: learn lua, read http://dev.minetest.net/Intro, get an idea, write mod, profit
:D
shaheerziya wrote:how to make a mod?
Pitriss wrote:Krock wrote:shaheerziya wrote:how to make a mod?
Complicated or easy way?
Complicated: learn lua, read http://dev.minetest.net/Intro, get an idea, write mod, profit
Easy way: learn lua, read http://dev.minetest.net/Intro, get an idea, write mod, profit
:D
Ferdi Napoli wrote:Can someone put the download of the third person mod?
Sorry for the language,i'm italian
philipbenr wrote:That's not quite what I meant. I know how to do so, but I need to be able to set the facing position inside the callback after_place_node.
prestidigitator wrote:philipbenr wrote:That's not quite what I meant. I know how to do so, but I need to be able to set the facing position inside the callback after_place_node.
I believe you'll need to call minetest.set_node() to change the 'param2' attribute while preserving 'name' and 'param1'. You may also need to preserve the metadata if it is important using minetest.get_meta():to_table() and minetest.get_meta():from_table() before and after set_node(), respectively. I believe metadata is reset when the node is changed, but I can't remember for sure. You might want to test it.
Nore wrote:prestidigitator wrote:philipbenr wrote:That's not quite what I meant. I know how to do so, but I need to be able to set the facing position inside the callback after_place_node.
I believe you'll need to call minetest.set_node() to change the 'param2' attribute while preserving 'name' and 'param1'. You may also need to preserve the metadata if it is important using minetest.get_meta():to_table() and minetest.get_meta():from_table() before and after set_node(), respectively. I believe metadata is reset when the node is changed, but I can't remember for sure. You might want to test it.
No: use minetest.swap_node(pos, new_node), it preserves metadata
Users browsing this forum: No registered users and 34 guests