Post your modding questions here

yaman
Member
 
Posts: 56
Joined: Wed Sep 04, 2013 21:22

by yaman » Tue Dec 31, 2013 14:56

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.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Tue Dec 31, 2013 15:29

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",
})

Those things are called items.
EDIT: mo-hahah I was first!
Last edited by Krock on Tue Dec 31, 2013 15:54, edited 1 time in total.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

by Casimir » Tue Dec 31, 2013 15:29

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
Last edited by Casimir on Tue Dec 31, 2013 15:30, edited 1 time in total.
 

yaman
Member
 
Posts: 56
Joined: Wed Sep 04, 2013 21:22

by yaman » Tue Dec 31, 2013 15:41

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

Thanks, to both of you :D
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Tue Dec 31, 2013 21:17

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Wed Jan 01, 2014 09:27

Okay, an easier question now:

When I've a configuration file in the worldpath, how can I set a variable in it with LUA?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Pitriss
Member
 
Posts: 253
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss

by Pitriss » Wed Jan 01, 2014 13:25

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?


Variable: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1869

Data structures are easier.. you just put them into table and serialize them by minetest.serialize and write them into file.
Last edited by Pitriss on Wed Jan 01, 2014 13:27, edited 1 time in total.
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
 

User avatar
fairiestoy
Member
 
Posts: 191
Joined: Sun Jun 09, 2013 19:25

by fairiestoy » Wed Jan 01, 2014 13:32

Hybrid Dog wrote:
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?
you could use os.execute for a compiled c program which can do this

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.

Why not making it configurable? Choose an initial exchange rate but refer to your code in order to make it changeable by the admin ( which would fit your needs about the configuration file ). Maybe with a extra option to add changes within this rate by time or by conversion amount ( the landrush way ).

Edit:
Hell, Pitriss x) Same thoughts it seems
Last edited by fairiestoy on Wed Jan 01, 2014 13:33, edited 1 time in total.
Interesting about new things is, to figure out how it works ...
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Wed Jan 01, 2014 22:54

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.


What I do is use the global step or (probably better) repeated uses of minetest.after. With the global step, do something like this to avoid large amounts of redundant computation:

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
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);


With the other solution, it'll look something more like:

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
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?


Unfortunately you can't do this with a player's (normal) inventory; only a node and a detached inventory. I've proposed unifying the inventory callback API in the past, but I guess it's not on the priority list of any approved developer.
Last edited by prestidigitator on Wed Jan 01, 2014 22:55, edited 1 time in total.
 

User avatar
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Wed Jan 01, 2014 23:00

many thanks prestidigitator will evaluate your suggestions
sorry for bad english
Linux debian 7 wheezy 64
kde
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Wed Jan 01, 2014 23:19

MrElmux wrote:How do i register an inventory for an Entity (To access it via get_inventory)

Entities do not have inventory. You can essentially create one by keeping a table of ItemStack objects in the entity object itself. You could even create a "class" that gives such a virtual inventory the same API as a full standard inventory.

Another option would be to create a unique name for each entity instance and use it to create a detached inventory associated with the entity. In this case you'd want to be really careful about "memory leaks" though. I haven't played with using metatables on entities, but theoretically you could use this to install a Lua finalizer to take care of cleanup.

Either way you'd want to also manage entity static data carefully if persisting the inventory contents is important. The engine is only going to persist node and player inventory data for you, so if you want other kinds of inventory you are pretty much on your own.
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Wed Jan 01, 2014 23:52

how would I add an extra function to a special pick axe? like if I mine something from pos then do function?
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

by philipbenr » Thu Jan 02, 2014 03:45

When using after_place_node, can I determine the direction in which a certain node is placed? (ex, facedir)

Not like this:
Image




But like so:
Image
"The Foot is down!"
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Thu Jan 02, 2014 05:15

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.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Thu Jan 02, 2014 05:37

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. [EDIT: I stand corrected. See Nore's post below. Excellent!] You can set parameters for the latter to customize the damage it does, how quickly it digs various types of block, what materials it can affect, etc., but you can't just do arbitrary things. If you make your own on_use() method, you'll have to figure out every detail of what happens when you left-click with it; the default behavior for digging and damage and all of that does not take effect, instead being replaced with whatever your callback does.

From the receiving end—meaning a node or entity on which a tool is being used—you have a few more options. So if there's some special entity/mob/node (but not player) you want the tool to affect in a particular way, there are a number of options to play with. For example, there are the on_punch(), on_dig(), can_dig(), after_dig_node(), and on_rightclick() callbacks on nodes and the punch() and right_click() callbacks on entites. From most of these you either get the wielded item as a parameter or get a reference to the player doing the digging/clicking and can use the player API to test things like what tool they are wielding.

It may be possible to re-create enough of the default behavior of digging/hitting if you dig around in the built-in Lua code a bit to figure out what everything is doing, but you'll have to be pretty careful to do it in a way that will work nicely with other mods (because of the way they assume it is all going to work).
Last edited by prestidigitator on Fri Jan 03, 2014 19:55, edited 1 time in total.
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Thu Jan 02, 2014 07:32

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: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2106
Last edited by Nore on Thu Jan 02, 2014 14:56, edited 1 time in total.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Thu Jan 02, 2014 11:26

Thanks for all helpers with that saving question.
I used the "io.open("file", "w")" function for now but other timer, it will be better using another way :)
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

wcwyes
Member
 
Posts: 145
Joined: Wed Jul 31, 2013 22:42

by wcwyes » Thu Jan 02, 2014 14:24

sweet thnx
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
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

by philipbenr » Thu Jan 02, 2014 18:43

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.

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.
"The Foot is down!"
 

shaheerziya
Member
 
Posts: 51
Joined: Sat Dec 07, 2013 06:57

by shaheerziya » Fri Jan 03, 2014 05:13

how to make a mod?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Fri Jan 03, 2014 10:32

shaheerziya wrote:how to make a mod?

Complicated or easy way?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Pitriss
Member
 
Posts: 253
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss

by Pitriss » Fri Jan 03, 2014 11:05

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
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Fri Jan 03, 2014 11:07

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

+1
Thought the same :)
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

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

by Topywo » Fri Jan 03, 2014 11:26

shaheerziya wrote:how to make a mod?


Actually there are 2 easy ways too:

- Copy and paste other mods. Then change them. Don't forget to give their makers credit.

- Read the decowood tutorial (scroll down after clicking the link):
http://dev.minetest.net/Intro

Also debug.txt is your best friend trying out mods you make.


Edit: This intro link is without a ","
Last edited by Topywo on Fri Jan 03, 2014 11:28, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Jan 03, 2014 13:49

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

The complicated way is: learn lua, read https://github.com/minetest/minetest/blob/master/doc/lua_api.txt, get an idea, write mod, profit
 

User avatar
Ferdi Napoli
Member
 
Posts: 14
Joined: Thu Jan 02, 2014 12:12

by Ferdi Napoli » Fri Jan 03, 2014 14:30

Can someone put the download of the third person mod?
Sorry for the language,i'm italian
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Fri Jan 03, 2014 14:35

Ferdi Napoli wrote:Can someone put the download of the third person mod?
Sorry for the language,i'm italian

It's not a mod.
https://forum.minetest.net/viewtopic.php?id=5397
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Jan 03, 2014 20:02

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
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Fri Jan 03, 2014 20:07

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
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

by philipbenr » Sat Jan 04, 2014 07:14

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


Oh, Thank you so much. It will save me a lot of time.
"The Foot is down!"
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 64 guests

cron