Page 1 of 1
Pandaro questions

Posted:
Mon Nov 26, 2012 21:24
by pandaro
I am studying the minetest API with the intent of writing, perhaps one day, a MOD. I think I can use this post to ask for help.
My first problem is this:
it is possible to know the location of ITEM dropped around to a position, in the same(or almost equal) way by which i can find NODE using:
find_node_near (pos, radius, nodenames)?
I can not find an equivalent function in the API.
If the problem is incomprehensible: I apologize on behalf of google translator.
If the problem has already been discussed, I apologize.
If you help me ... THANKS

Posted:
Mon Nov 26, 2012 21:37
by jin_xi
there is get_objects_inside_radius(pos, radius)

Posted:
Mon Nov 26, 2012 22:02
by pandaro
I tried, maybe I'm wrong, code:
local o = minetest.env: get_object_inside_radius (s, 10)
print(tostring (o))
/.minetest/debug.txt
22:47:02: VERBOSE [main]: error_message = Servererror: LuaError: error running function 'on_step' ... netest / games / minetest_game / mods / pandarotest / init.lua: 115: attempt to call method 'get_object_inside_radius' (a nil value)
"s" is a variable, and it works for: find_node_near()
near "s" there are many "default: sapling"
I can also publish all the code, if it helps.

Posted:
Mon Nov 26, 2012 22:35
by pandaro
oh sorry! syntax error!
maybe it works...

Posted:
Tue Nov 27, 2012 14:56
by PilzAdam
It is
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.env:get_objects_inside_radius(p, r)
(notice the "s" after object; its plural)
It returns a table with all objects in this radius. You can loop through it:
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 _,object in ipairs(minetest.env:get_objects_inside_radius(p, r)) do
[your code here]
end

Posted:
Tue Nov 27, 2012 22:08
by pandaro
Thank you very much, now it works, but I have another small problem:
I use ipairs to travel the list, and through get_luaentity (). name i can know what kind of object is present, but: If you see an item called "pandarotest" function get_luaentity (). name correctly returns "pandarotest." However, if there is a "sapling" or a pic or something definite in default, the function get_luaentity (). name returns the string: "__builtin: item".
I have to discriminate between different types of objects, so I need to know the name(like:"default:sapling")!
Can anyone help me again?

Posted:
Wed Nov 28, 2012 10:05
by pandaro
I solved alone, is sufficient to use lua_entity (). itemstring

Posted:
Wed Dec 05, 2012 09:42
by pandaro
Continuation of this post wondering:
what do you think the EASIEST place to which I can upload a zipped file (theoretically my mod). I've never done this before, so also show me a link with instructions.
Thank you, you will hear from me soon!

Posted:
Wed Dec 05, 2012 10:18
by Topywo
I use dropbox.
www.dropbox.comI don't think you can see the amount of downloads of your files with it, like some other sites do, but I never looked into that.
Uploading --> website/public folder --> click the white paper with the blue arrow
Posting --> website/right click your file or image in the public folder to get a copy of the public link (to paste in your forum post)

Posted:
Wed Dec 05, 2012 10:29
by Calinou
You can also drag-and-drop your file to Dropbox's website (when you are logged in) and it should upload it. ;)

Posted:
Tue Dec 11, 2012 20:41
by pandaro
Can I run a function within an area not loaded?
I tried using the "on_step", but if I walk away too, minetest off my entity.
I tried through minetest.register_ABM, but the result is the same.
I doing something wrong? Maybe I can not do it?
if this topic has already been discussed, I apologize, and ask you only to show me the link.
thanks

Posted:
Wed Dec 12, 2012 11:55
by pandaro
Nothing to do?
No one knows how to help me?

Posted:
Wed Dec 12, 2012 12:21
by thetoon
pandaro wrote:Can I run a function within an area not loaded?
I tried using the "on_step", but if I walk away too, minetest off my entity.
I tried through minetest.register_ABM, but the result is the same.
I doing something wrong? Maybe I can not do it?
if this topic has already been discussed, I apologize, and ask you only to show me the link.
thanks
Disclaimer : I'm really new into the API as well, so these are more general algorithmic principles rather than step-by-step instructions.
It appears you can't. Depending on the process you try to simulate (won't work for bullets and arrows), you could try to allow your on_step function to process several steps at once. If there's a way to know for how long the server has been running (and I'm pretty sure there is), all you'd have to do is to compute how many steps you would have missed and play them all at once.
At least for things like plants decay and/or growth, it should work that way.

Posted:
Tue Jan 22, 2013 12:36
by pandaro
Hello everyone, I need more help 8)
I'm trying to use param1 - param2 to store a variavile in a block, but I can not.
code is:
test={}
minetest.register_node("test:key", {
description = "key",
tiles = {"testkey.png"},
is_ground_content = true,
groups = {cracky=1},
drop = 'test:key',
legacy_mineral = true,
stack_max = 49,
paramtype="none",
paramtype1="none",
paramtype2="none",
after_place_node = function(pos)
local chest = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z})
local key = minetest.env:get_node(pos)
print(dump(chest))
print(dump(key))
end,
})
minetest.register_node("test:chest", {
description = "chest",
tiles = {"testchest.png"},
is_ground_content = true,
groups = {cracky=1},
drop = 'test:chest',
legacy_mineral = true,
stack_max = 49,
on_construct = function(pos)
local code = pos.x..","..pos.y..","..pos.z
minetest.env:place_node({x=pos.x,y=pos.y+1,z=pos.z},{name="test:key",param1=99,param2=34})
end,
})
and terminal output:
13:07:36: ACTION[ServerThread]: singleplayer places node test:chest at (3,2,2)
13:07:36: ACTION[ServerThread]: places node test:key at (3,3,2)
{param1 = 0, name = "test:chest", param2 = 0}
{param1 = 0, name = "test:key", param2 = 0}
what is wrong?
thanks

Posted:
Tue Jan 22, 2013 12:43
by LorenzoVulcan

Posted:
Tue Jan 22, 2013 12:50
by pandaro
Grazie per l'attenzione Lorenzo, volevo vedere se riuscivo a farlo con param, mi sembrava più economico a livello di risorse. Se non si può userò set_meta() e get_meta(). Grazie!
p.s.
Param tu non lo usi mai nel tuo blockforge?

Posted:
Thu Jan 31, 2013 20:11
by pandaro
hello guys....
again:
I'm trying to use the function on_blast (pos, intensity)
but I can not
what is wrong?
here the code:
minetest.register_node("test:x", {
description = "test ",
inventory_image = ("x.png"),
tiles = {"x.png"},
on_blast=function(pos,intensity)
print("hello")
print(dump(pos))
print(tostring(intensity))
end,
})
Nothing prints

Posted:
Thu Jan 31, 2013 21:16
by Mito551
pandaro wrote:hello guys....
again:
I'm trying to use the function on_blast (pos, intensity)
but I can not
what is wrong?
here the code:
minetest.register_node("test:x", {
description = "test ",
inventory_image = ("x.png"),
tiles = {"x.png"},
on_blast=function(pos,intensity)
print("hello")
print(dump(pos))
print(tostring(intensity))
end,
})
Nothing prints
have you defined on_blast?
i don't remember such a function to be default. meybe after_desruct would work better

Posted:
Thu Jan 31, 2013 21:28
by pandaro
I have not defined on_blast? I do not know ... what I wrote I posted.
on_destruct still works well
thanks mito551

Posted:
Thu Jan 31, 2013 21:58
by Calinou
pandaro wrote:hello guys....
again:
I'm trying to use the function on_blast (pos, intensity)
but I can not
what is wrong?
here the code:
minetest.register_node("test:x", {
description = "test ",
inventory_image = ("x.png"),
tiles = {"x.png"},
on_blast=function(pos,intensity)
print("hello")
print(dump(pos))
print(tostring(intensity))
end,
})
Nothing prints
That's normal, you should never put a "," after "end" if I recall correctly.

Posted:
Thu Jan 31, 2013 22:15
by pandaro
Calinou wrote:That's normal, you should never put a "," after "end" if I recall correctly.
I think the comma is necessary, because without:
23:07:55: ERROR[main]: ...-5/minetest-master/bin/../games/minetest_game/mods/closed_chest/init.lua:256: '}' expected (to close '{' at line 184) near 'can_dig'
-I always do:
on_construct=function()
body
end,
...
...
on_blast(pos, intensity)
body(i hope)
end,
I do not know, maybe I can not do it.
but maybe there is some problem with the function call on_blast