Jump to content
Nymall

Need help targeting items on a specific tile, specific fixture or tile itself

Recommended Posts

Hey guys, I'm hoping there's a quick fix to this problem. Right now I'm making a mod that uses getModData to store a "charge", and access this tile from other blocks("consumers"). There's also some other mod data i'd like to reference as well. I'm having some trouble referencing the tile or object that I want to store the charges. There's two ways I could think of doing it:

 

1.)Referencing the tile the object that stores the charges is on by X and Y coords. Problem is I'm not quite sure how to pull that data from a tile.

2.)Referencing the instance of the "charger" item in question using it's index and storing it as mod data on the consumer. The only thing I'm afraid of is that the reference would be lost on Save/load, and recouping up the network might be a pain after every load.

 

So, to summarize:

 

  • What would be the best way to locate a instance of a item, fixture or tile?
  • Could a item be targeted in Lua using just the raw XY coords?
  • I'm also looking for a way to store "network" data. An ideal would allow each unique network to store an amount of power and have that be stored in one place(say on the player using getModData or some kind of fake item that spawns off map when a new network is created). What would be the best way of doing this?

Thanks!

Share this post


Link to post
Share on other sites
  • Solution
What would be the best way to locate a instance of a item, fixture or tile?

you can iterate over the list of objects on a tile

Could a item be targeted in Lua using just the raw XY coords?

yes, assuming by item you mean object in the world, then by locating the gridsquare (tile) via XY and doing the above.

 

take a look on this page:

http://theindiestone.com/forums/index.php/topic/8249-tutorial-world-objects/

 

its covers some basics on how to do stuff like that.

I'm also looking for a way to store "network" data. An ideal would allow each unique network to store an amount of power and have that be stored in one place(say on the player using getModData or some kind of fake item that spawns off map when a new network is created). What would be the best way of doing this?

i think you could draw inspiration on how RJ has done the farming in vanilla, works mp/sp, he uses gameTime moddata as a sort of global data depot, as do many other mods. Afaik theres no real global data class or something (yet).

 

goodluck and if anything unclear shoot! :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...