Questions about lua API

Hashlime
Member
 
Posts: 12
Joined: Fri Oct 17, 2014 23:36

Questions about lua API

by Hashlime » Sun Oct 19, 2014 01:52

Hi everyone, I started modding a few days ago and here is a list of questions I have :
  1. How can I add my new item to an existing group ? Ex: I add a 'Wood Planks' item how can I add it to 'group:wood' ?
  2. Is there a way to interact with the keyboard ?
  3. Is it possible to rewrite the 'Esc' menu ? (I didn't find anything in the code, is it defined in c++ while all others (menus) are defined in lua ?)
  4. Why some items are defined like this (I saw 'air' and 'ignored') :
    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
    -- {...} = some stuff
    minetest.register_craftitem("air", {...})
  5. How the dependencies are managed ? If my mod's dependencies are not resolved what will happen ? What about priorities ? The dependencies are executed before/after/no relation ?
  6. If I add resources (textures, sound, models) to my mod are they overwritten by textures packs ?
  7. Is it possible to rotate (x, y, z axes) a Node box in Node Boxes ?
And another question about shaders : Can I code new shaders and place them in ~/.minetest (on Linux, I don't know the path on Windows/Mac OS) ?

Thank you.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Questions about lua API

by kaeza » Sun Oct 19, 2014 03:30

Hello, and welcome.

1: You need to specify the group in the node `groups` field:
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_node("foo:bar", {
  -- ...
  groups = { cracky=1, wood=1, foo=4, bar=2 },
  -- ...
})


2: Not currently, other than reading the game keys (up, down, left, right, jump, etc) via `playerobj:get_player_control()`.

4: I'm not sure what you mean.

5: The dependencies are loaded first, recursively. I.e. foo depends on bar and bleh, it loads bar first, then bleh, but bar depends on baz and bleh, so it loads baz first, then goes to bleh (from bar dependencies), then actually loads bar, then finally loads foo (the first mod). The `bleh` dependency of foo is ignored because it was already loaded before baz. If any mod in the chain is not found, the engine reports an error and refuses to start. *

6: Yes, but only textures AFAIK. Not sure if texture/resource packs can specify models/sounds.
7: Not currently.

Edit:
* To clarify on point 5, there's also optional dependencies, specified as 'modname?' in `depends.txt`. If the mod is not found, the engine just ignores it and continues with dependency checking.

Hope that helps.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Hashlime
Member
 
Posts: 12
Joined: Fri Oct 17, 2014 23:36

Re: Questions about lua API

by Hashlime » Sun Oct 19, 2014 15:38

Thank you very helpful !
One more question about groups, in your example you wrote `wood=1`, what is the meaning of '1' ?
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: Questions about lua API

by Calinou » Sun Oct 19, 2014 16:29

Hashlime wrote:Thank you very helpful !
One more question about groups, in your example you wrote `wood=1`, what is the meaning of '1' ?


It means the node is part of the “wood” group. Any integer value (even negative) can be used, even 100, but some groups actually only use 0 or 1 as values.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Questions about lua API

by Wuzzy » Wed Oct 22, 2014 19:15

Is it possible to rewrite the 'Esc' menu ? (I didn't find anything in the code, is it defined in c++ while all others (menus) are defined in lua ?)

Of course it is! Minetest is free software. :-)

But it is defined in C++, not Lua. A few other menus are currently hardcoded in C++ as well, but not many.
 

User avatar
DuDraig
Member
 
Posts: 69
Joined: Sun Sep 28, 2014 17:56
IRC: DuDraig
In-game: DuDraig

Re: Questions about lua API

by DuDraig » Sat Oct 25, 2014 11:14

Hashlime wrote:Why some items are defined like this (I saw 'air' and 'ignored') :
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
-- {...} = some stuff
minetest.register_craftitem("air", {...})

The world is divided into areas that are not all necessarily loaded. There is a caching system that keeps areas and all the nodes in them from being loaded if they are not yet seen or used by players. The "ignore" node type means the area for that position is not loaded.

There is no such thing as an empty node position. It is always filled with something be it an item, an entity, a fluid, or air. This allows the world to deal with the effects of each type of node be it solid, liquid, or gas.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Questions about lua API

by rubenwardy » Sat Oct 25, 2014 17:49

The don't have a mod name as they are in builtin, which is not a mod.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron