Pandaro questions

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

Pandaro questions

by pandaro » Mon Nov 26, 2012 21:24

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

jin_xi
Member
 
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Mon Nov 26, 2012 21:37

there is get_objects_inside_radius(pos, radius)
 

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

by pandaro » Mon Nov 26, 2012 22:02

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

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

by pandaro » Mon Nov 26, 2012 22:35

oh sorry! syntax error!
maybe it works...
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 » Tue Nov 27, 2012 14:56

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
 

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

by pandaro » Tue Nov 27, 2012 22:08

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

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

by pandaro » Wed Nov 28, 2012 10:05

I solved alone, is sufficient to use lua_entity (). itemstring
sorry for bad english
Linux debian 7 wheezy 64
kde
 

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

by pandaro » Wed Dec 05, 2012 09:42

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

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

by Topywo » Wed Dec 05, 2012 10:18

I use dropbox. www.dropbox.com

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

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

by Calinou » Wed Dec 05, 2012 10:29

You can also drag-and-drop your file to Dropbox's website (when you are logged in) and it should upload it. ;)
 

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

by pandaro » Tue Dec 11, 2012 20:41

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

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

by pandaro » Wed Dec 12, 2012 11:55

Nothing to do?
No one knows how to help me?
sorry for bad english
Linux debian 7 wheezy 64
kde
 

thetoon
Member
 
Posts: 106
Joined: Tue Dec 11, 2012 12:55

by thetoon » Wed Dec 12, 2012 12:21

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.
 

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

by pandaro » Tue Jan 22, 2013 12:36

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

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Tue Jan 22, 2013 12:43

Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

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

by pandaro » Tue Jan 22, 2013 12:50

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

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

by pandaro » Thu Jan 31, 2013 20:11

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

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Thu Jan 31, 2013 21:16

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
 

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

by pandaro » Thu Jan 31, 2013 21:28

I have not defined on_blast? I do not know ... what I wrote I posted.

on_destruct still works well

thanks mito551
sorry for bad english
Linux debian 7 wheezy 64
kde
 

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

by Calinou » Thu Jan 31, 2013 21:58

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.
 

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

by pandaro » Thu Jan 31, 2013 22:15

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


Return to WIP Mods

Who is online

Users browsing this forum: Google [Bot] and 53 guests

cron