Do nodes have uniqie identification numbers?

tbillion
Member
 
Posts: 189
Joined: Wed Apr 03, 2013 16:07

Do nodes have uniqie identification numbers?

by tbillion » Sat Dec 05, 2015 06:17

is there a way to call a node by a unique identifier and get its meta information? given the block exists and i am on the other side of the world if i call a script that has that unigue id i can influence it.

to give an over all example i have a chest say at 0,0,0 and i am standing at my castle in the sky, 1000,1000,1000 and i want to add items to that chest, the code wants to know the position, so i would call something like

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
node_id=2342354
pos = get_node_id_pos(node_id)

???

what i am trying to say is i know that the node is but i dont know its position and the code wants to know the nodes position. the nodes position however is constantly changing so how would i get its position.
 

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

Re: Do nodes have uniqie identification numbers?

by rubenwardy » Sat Dec 05, 2015 11:04

Store the position in a variable? Nodes have a serial, but serials are basically positions stored in one number.
 

tbillion
Member
 
Posts: 189
Joined: Wed Apr 03, 2013 16:07

Re: Do nodes have uniqie identification numbers?

by tbillion » Sat Dec 05, 2015 11:11

thanks Rubenwardy.

how do you access the serial of a node?

eventhough i have changed my approach still might be handy for future reference.
 

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

Re: Do nodes have uniqie identification numbers?

by kaeza » Sat Dec 05, 2015 12:20

You don't need a "serial", and as rubenwardy said, it's basically a serialized form of the position (is this even so? don't know much about map serialization).

What you need is to analyze how you are doing things, and find a relevant node callback or similar.

Based on your example, you probably want either `on_construct` (or `after_place_node`), or an ABM.

It's hard to come up with a solution if there's no code shown.

Also, I don't recall how it's called, but you are basically asking "how do I use a hammer to bolt some screws", instead of the more appropriate "what is the best way of bolting some screws". (sorry if I don't make much sense; in dire need of coffee).
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
 

tbillion
Member
 
Posts: 189
Joined: Wed Apr 03, 2013 16:07

Re: Do nodes have uniqie identification numbers?

by tbillion » Sat Dec 05, 2015 12:46

perfect sense made. thank you both for your replies. An ABM worked for a while now i have moved away from that. what i was trying to do is affect a specific node from inside minetest.register_globalstep(function(dtime) which apparently is impossible, and u have to use a node timer or something to that affect. node timer i did not figure out i did end up for now using minetest.after with the time set to 0 which for now is apparently effecticely executing the code repeatedly without any delay other than the amount of time it takes to execute the code.

With the ABM the amount of time to execute the code was in excess of 200ms and after that point (im not sure becasue i have no experience with the minetest core code) it would slow, kill , alter whatever the abm was doing and mess up my mod.

originally i didnt want to use minetest.after because its minimum interval was 1 second. it was by chance i came across the example for it using 0 as the interval.

if it helps you to not be so aggressive :) free coffee is in my kitchen come get you some lol...
 

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

Re: Do nodes have uniqie identification numbers?

by kaeza » Sat Dec 05, 2015 14:47

Was not meant to be aggressive, just a random comment on the nature of your question.

Anyway, from your other topic, the best way would be to either have a formspec in the "source" chest asking for coordinates, or have a way to link "networks" or "channels" of chests easily identfiable by some user-readable name. For the latter, look at the travelnet mod to see one way to do it, but beware that this is not exactly simple.

EDIT: Also, be aware that in your case, the chest may not be in memory at the moment, so you may need to load the block it's in beforehand.
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
 

tbillion
Member
 
Posts: 189
Joined: Wed Apr 03, 2013 16:07

Re: Do nodes have uniqie identification numbers?

by tbillion » Sat Dec 05, 2015 16:31

or have the block forceload itself at all times like the admin anchor. (technic) really just looking for the base code for that will move an item from one position to another. that way my tbm can move items from its inventory to another storage when its onboard inventory is full. your right about the formspec though. i figured a teleport chest system would be the simplest form of teleport. a simple solution is a simple example to follow.
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Do nodes have uniqie identification numbers?

by stu » Sat Dec 05, 2015 17:11

tbillion wrote:or have the block forceload itself at all times like the admin anchor. (technic) really just looking for the base code for that will move an item from one position to another. that way my tbm can move items from its inventory to another storage when its onboard inventory is full. your right about the formspec though. i figured a teleport chest system would be the simplest form of teleport. a simple solution is a simple example to follow.

afaik, you can manipulate node meta even when the block is not loaded, there should be no need to forceload anything. Here is a simple example. Create a flat map (for simplicity) and place a chest at 1000, 4, 1000 then teleport to 0, 4, 0 or wherever you like, go back to the chest a few minutes later and it should contain some apples ;-)
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 timer = 0
local stack = "default:apple"
local metapos = {x=1000, y=4, z=1000}

minetest.register_globalstep(function(dtime)
   timer = timer + dtime
   if timer > 4 then
      local meta = minetest.get_meta(metapos)
      if meta then
         local inv = meta:get_inventory()
         if inv:room_for_item("main", stack) then
            inv:add_item("main", stack)
         end
      end
      timer = 0
   end
end)

Note that you will see a server warning until you actually place a chest at the meta position.

Hope this gives you some ideas, sorry if I totally misunderstood the question.
 

tbillion
Member
 
Posts: 189
Joined: Wed Apr 03, 2013 16:07

Re: Do nodes have uniqie identification numbers?

by tbillion » Sat Dec 05, 2015 19:15

no not really stu you got the just of it, the only thing i dont have is the location. since we are now talking about teleport chests. (which i wasn't when i started this post, but they are a good example) say i dont know the pos of the chest but i know its unique name then i could just say " teleport to chest 14" with your example though i see that if i have the pos it would work, the hang up is imagine this chest can move on its own and its pos is not constant ... then you have the issue of it telling you where it is at, globally.
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Do nodes have uniqie identification numbers?

by stu » Sat Dec 05, 2015 20:02

tbillion wrote:no not really stu you got the just of it, the only thing i dont have is the location. since we are now talking about teleport chests. (which i wasn't when i started this post, but they are a good example) say i dont know the pos of the chest but i know its unique name then i could just say " teleport to chest 14" with your example though i see that if i have the pos it would work, the hang up is imagine this chest can move on its own and its pos is not constant ... then you have the issue of it telling you where it is at, globally.

Indeed, you will need to keep track of the positions some other way, like using a serialized data file or a 3rd party data-storage mod. Alternatively you may be able to use entity 'staticdata' somehow, if you are already using entities but I would not recommend that.
Maybe it is possible that each send/receive pair holds a copy of the each others position, both are updated when either one changes so no need for additional storage? Just some random ideas.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron