Post your modding questions here

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

by pandaro » Tue Dec 24, 2013 16:39

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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Tue Dec 24, 2013 16:43

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

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 radar_configuration = minetest.Settings("/ minetest / games / mod / player_radar / player_radar.conf")
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
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Tue Dec 24, 2013 16:52

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

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

by wtfsamcrap » Tue Dec 24, 2013 17:07

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: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Tue Dec 24, 2013 17:09

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: 452
Joined: Sat Oct 29, 2011 19:31

by Gambit » Wed Dec 25, 2013 04:51

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: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Thu Dec 26, 2013 17:40

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

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

by Krock » Thu Dec 26, 2013 17:55

Topic: Getting item drops
Reason: I don't know how...I'm a newbie
More Info:
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 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
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
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Thu Dec 26, 2013 17:59

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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

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

by kaeza » Thu Dec 26, 2013 18:02

Krock wrote:Topic: Getting item drops
Reason: I don't know how...I'm a newbie
More Info:
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 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

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 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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

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

by pandaro » Thu Dec 26, 2013 18:32

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

by PilzAdam » Thu Dec 26, 2013 18:37

pandaro wrote:about:
object.get_armor_groups()
this API works?

No, its not implemented yet.
 

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

by pandaro » Thu Dec 26, 2013 18:42

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

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

by Casimir » Thu Dec 26, 2013 18:51

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 » Thu Dec 26, 2013 19:29

put parenthesis around string comparisions

cant type more,no kbd here
 

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

by ch98 » Sat Dec 28, 2013 08:12

can someone explain to me how to get node name using lua Voxel Manipulator, place node in certen position with it, and what
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
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.
Mudslide mod Click Here
 

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

by Krock » Sat Dec 28, 2013 14:20

I've a simple question:

How do I check if the node "X" contains items/nodes in it?
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
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Dec 28, 2013 14:25

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:
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 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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Dec 28, 2013 14:27

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:
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 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.
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
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Dec 28, 2013 14:31

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:
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 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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Dec 28, 2013 14:38

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...
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
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Dec 28, 2013 14:46

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:
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
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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Dec 28, 2013 14:50

PilzAdam 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
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.
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
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Sat Dec 28, 2013 19:17

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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Dec 28, 2013 20:03

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/technic/blob/master/technic/tools/flashlight.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
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Sun Dec 29, 2013 19:01

Krock wrote:
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/technic/blob/master/technic/tools/flashlight.lua


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.


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?
sorry for bad english
Linux debian 7 wheezy 64
kde
 

MrElmux
Member
 
Posts: 17
Joined: Sun Dec 29, 2013 09:50

by MrElmux » Mon Dec 30, 2013 14:17

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

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

by yaman » Mon Dec 30, 2013 14:37

Is it possible to spawn an ore in the air because wherein = "default:air", doesn't seem to work
 

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

by kaeza » Mon Dec 30, 2013 15:27

yaman wrote:Is it possible to spawn an ore in the air because wherein = "default:air", doesn't seem to work

The node name for air is "air", not "default:air". See if that works.
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
 

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

by yaman » Mon Dec 30, 2013 22:45

kaeza wrote:
yaman wrote:Is it possible to spawn an ore in the air because wherein = "default:air", doesn't seem to work

The node name for air is "air", not "default:air". See if that works.

It worked, thanks. Another question: is it possible to spawn something that isn't random, like a house or somethin, and how?
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron