Post your modding questions here

Locked
User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

A question about:
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,...}
the question is:
I can query a file type. "conf", called, for example: "player_radar.conf", which is located in "/ minetest / games / mod / player_radar / player_radar.conf"?

Perhaps I misunderstand this API, I thought I could use
local radar_configuration minetest.Settings = ("/ minetest / games / mod / player_radar / player_radar.conf")
since the API says:
"Can be created via Settings (filename)"
I'm wrong? what?
sorry for bad english
Linux debian 7 wheezy 64
kde

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

by Krock » Post

pandaro wrote:local radar_configuration minetest.Settings = ("/ minetest / games / mod / player_radar / player_radar.conf")

Code: Select all

local radar_configuration = minetest.Settings("/ minetest / games / mod / player_radar / player_radar.conf")
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

Krock wrote:
pandaro wrote:local radar_configuration minetest.Settings = ("/ minetest / games / mod / player_radar / player_radar.conf")

Code: Select all

local radar_configuration = minetest.Settings("/ minetest / games / mod / player_radar / player_radar.conf")
excuse for imprecision syntax, however this time I typed:
"local radar_configuration = minetest.Settings("/minetest/games/minetest/mods/player_radar/player_radar.conf")"
Terminal says:

"17:47:46: ERROR [main]: Servererror: LuaError ... p/minetest/0.48/bin/../games/minetest/mods/test/init.lua: 25: attempt to call field 'Settings '(a nil value) "

any of you have an example to share?
sorry for bad english
Linux debian 7 wheezy 64
kde

User avatar
wtfsamcrap
Member
Posts: 25
Joined: Mon Dec 09, 2013 21:23
Location: Look behind you :)
Contact:

by wtfsamcrap » Post

I have a confesion to make .. i cant make new nodes or tools or mapgen for a mod but any other lua works fine how do i fix this
Mods

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

sorry, solved by myself. The correct syntax is:
local radar_configuration = Settings("/home/p/minetest/0.48/games/minetest/mods/player_radar/player_radar.conf")
AS THE API SAYS!
sorry for bad english
Linux debian 7 wheezy 64
kde

User avatar
Gambit
Member
Posts: 453
Joined: Sat Oct 29, 2011 19:31
Location: United States

by Gambit » Post

How do I change the viewing height (for lack for a better word)? I feel the player visual hieght is too short/low.
Current Projects: MineToon | PixelBOX
Gambit's Checkmate Server - 43.65.296.232 - port: 30001

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

about:
object.get_armor_groups()
this API works?
sorry for bad english
Linux debian 7 wheezy 64
kde

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

by Krock » Post

Topic: Getting item drops
Reason: I don't know how...I'm a newbie
More Info:

Code: Select all

local drops = minetest.get_node_drops(node.name)
for _, item in ipairs(drops) do
    --How do I get the [u]count[/u] of dropped items here?
    --I know, some things like, clay node returns 4 clay lumps....
end
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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:

by kaeza » Post

Gambit wrote:How do I change the viewing height (for lack for a better word)? I feel the player visual hieght is too short/low.
You can't from Lua. You need to edit the engine sources (C++).
pandaro wrote:about:
object.get_armor_groups()
this API works?
It should. can you paste some code?
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
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

by kaeza » Post

Krock wrote:Topic: Getting item drops
Reason: I don't know how...I'm a newbie
More Info:

Code: Select all

local drops = minetest.get_node_drops(node.name)
for _, item in ipairs(drops) do
    --How do I get the [u]count[/u] of dropped items here?
    --I know, some things like, clay node returns 4 clay lumps....
end

Code: Select all

local drops = minetest.get_node_drops(node.name)
for _, item in ipairs(drops) do
  local stack = ItemStack(item)
  local count = stack:get_count()
  -- Do something with count.
end
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
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

kaeza wrote:
pandaro wrote:

about:
object.get_armor_groups()
this API works?

It should. can you paste some code?
code:
minetest.register_tool("test:42", {
description = "Sword42",
inventory_image = "sword42.png",
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level=0,

groupcaps={
fleshy={times={[2]=1.10, [3]=test.swt}, uses=10, maxlevel=1},
snappy={times={[2]=0.9, [3]=0.45}, uses=10, maxlevel=1},
choppy={times={[3]=0.90}, uses=20, maxlevel=0}
}
},

range=10,
damage_groups = {fleshy=2},
on_use=function(itemstack, user, pointed_thing)
user:set_armor_groups({fleshy=7})
print(dump(user:get_armor_groups()))
end,
})
the terminal says me:
attempt to call method 'get_armor_groups' (a nil value)
I tried with:
print(dump(user:get_armor_groups(fleshy)))
print(dump(user:get_armor_groups("fleshy")))
print(dump(user:get_armor_groups([fleshy])))
sorry for bad english
Linux debian 7 wheezy 64
kde

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

by PilzAdam » Post

pandaro wrote:about:
object.get_armor_groups()
this API works?
No, its not implemented yet.

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

ok thanks to all
sorry for bad english
Linux debian 7 wheezy 64
kde

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

by Casimir » Post

Casimir wrote:About the hud; No matter what I set "direction" to, it always looks the same. Could it be that this is not implemented yet?
Found it. I had to use "dir" instead of "direction". But dir=1 looks like there is still some work to do.

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

put parenthesis around string comparisions

cant type more,no kbd here

ch98
Member
Posts: 463
Joined: Wed Jan 02, 2013 06:14

by ch98 » Post

can someone explain to me how to get node name using lua Voxel Manipulator, place node in certen position with it, and what

Code: Select all

VoxelManip: An interface to the MapVoxelManipulator for Lua
- Can be created via VoxelManip()
- Also minetest.get_voxel_manip()
methods:
- read_from_map(p1, p2): Reads a chunk of map from the map containing the region formed by p1 and p2.
  ^ returns actual emerged pmin, actual emerged pmax
- write_to_map(): Writes the data loaded from the VoxelManip back to the map.
  ^ important: data must be set using VoxelManip:set_data before calling this
- get_data(): Gets the data read into the VoxelManip object
  ^ returns raw node data is in the form of an array of node content ids
- set_data(data): Sets the data contents of the VoxelManip object
- update_map(): Update map after writing chunk back to map.
  ^ To be used only by VoxelManip objects created by the mod itself; not a VoxelManip that was
  ^ retrieved from minetest.get_mapgen_object
- set_lighting(light): Set the lighting within the VoxelManip
  ^ light is a table, {day=<0...15>, night=<0...15>}
  ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
- calc_lighting(): Calculate lighting within the VoxelManip
  ^ To be used only by a VoxelManip object from minetest.get_mapgen_object
- update_liquids(): Update liquid flow

means?
I have serched and read over things as much as i could but there is not much infomation about this. What i want to do is to get large box as 2 position, read exactry how many of what is in that large box that is diggable and what is drops, turn it all in to air and keep the liquid, then place them in chest like stuff organised. (i'm trying to make technic quarry like thing that charges like battery and digs instantly when fully charged.)

ps
someone need to make developers wiki page about Lua Voxel Manipulator.
Last edited by ch98 on Sat Dec 28, 2013 08:16, edited 1 time in total.
I have stopped playing minetest, and may not come back to it again. I would like to thank everyone that made the amazing time I had playing it. This account is not in use anymore, and the email has been linked to a unused account. If any administrator reading this has time, feel free to delete my account. Thank you very much for the great experience.

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

by Krock » Post

I've a simple question:

How do I check if the node "X" contains items/nodes in it?
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

by PilzAdam » Post

Krock wrote:I've a simple question:

How do I check if the node "X" contains items/nodes in it?
What do you mean by "contains items"? An inventory like a chest?
The node's inventory is in the meta, that can be gotten via:

Code: Select all

local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
Then it depends on the node in which list the content is, e.g. for a chests its in "main".

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

by Krock » Post

PilzAdam wrote:
Krock wrote:I've a simple question:

How do I check if the node "X" contains items/nodes in it?
What do you mean by "contains items"? An inventory like a chest?
The node's inventory is in the meta, that can be gotten via:

Code: Select all

local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
Then it depends on the node in which list the content is, e.g. for a chests its in "main".
Well, I mean like the chest or furnace, but I need a general checking if there is something stored or not..else will my new node erase everything in it.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

by PilzAdam » Post

Krock wrote:
PilzAdam wrote:
Krock wrote:I've a simple question:

How do I check if the node "X" contains items/nodes in it?
What do you mean by "contains items"? An inventory like a chest?
The node's inventory is in the meta, that can be gotten via:

Code: Select all

local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
Then it depends on the node in which list the content is, e.g. for a chests its in "main".
Well, I mean like the chest or furnace, but I need a general checking if there is something stored or not..else will my new node erase everything in it.
Hmmm... I dont know how to get a list of all used listnames in that inventory.

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

by Krock » Post

PilzAdam wrote:Hmmm... I dont know how to get a list of all used listnames in that inventory.
Or is there another way then with listnames? I've tried with meta:to_table() but that does not work...
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

by PilzAdam » Post

Krock wrote:
PilzAdam wrote:Hmmm... I dont know how to get a list of all used listnames in that inventory.
Or is there another way then with listnames? I've tried with meta:to_table() but that does not work...
I guess something like this could work:

Code: Select all

for listname,list in pairs(meta:to_table().inventory) do
    for index,item in ipairs(list) do
        -- do something with item
    end
end

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

by Krock » Post

PilzAdam wrote:

Code: Select all

for listname,list in pairs(meta:to_table().inventory) do
    for index,item in ipairs(list) do
        -- do something with item
    end
end
okay thanks, I will try.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

by pandaro » Post

I need to execute a function when I put an item in the first row of the inventory of the player. Inventory of reference should be current_player, main. So I should redefine the function on_put () for inventory, "current_player"

is this possible?
sorry for bad english
Linux debian 7 wheezy 64
kde

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

by Krock » Post

pandaro wrote:I need to execute a function when I put an item in the first row of the inventory of the player. Inventory of reference should be current_player, main. So I should redefine the function on_put () for inventory, "current_player"

is this possible?
You might look into the "flashlight" node/tool of the technic mod:
https://github.com/minetest-technic/tec ... hlight.lua
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Locked

Who is online

Users browsing this forum: No registered users and 1 guest