ComputerCraft

ComputerCraft

21M Downloads

Turtle Peripherals

hilburn opened this issue · 4 comments

commented

My current issue is that with my ITurtleUpgrade it appears that all upgrades are instances of the same IPheripheral, this makes it difficult/nearly impossible to store data on the peripheral unique to each turtle, or even a reference to the turtle who "owns" the peripheral - to allow for use of the turtle's location and inventory when executing commands

If there is a workaround that I am just not seeing I'd really appreciate some advice, but it does seem unnecessarily difficult as it currently stands

commented

That's not true, createPeripheral() is called per-turtle

commented

You can also store data using ITurtleAccess->getUpgradeNBT(), from a tool or a peripheral.

commented

Unless there is a major bug in the system (in which case turtle modems
wouldnt work), the problem is with your code. An ITurtleAccess unique to
each turtle is passed into the createPeripheral call

On Thu, Nov 6, 2014 at 12:54 PM, Charlie [email protected] wrote:

Then why does my non-static reference to ITurtleAccess in my peripheral
always only ever return the last placed turtle?
Why does my non-static list duplicate across all placed turtles with the
peripheral?
Storing data using the NBT save functionality is impractical as you can't
access it with the IComputerAccess you are given with the callMethod
function


Reply to this email directly or view it on GitHub
#8 (comment).

commented

you're probably doing something dumb like creating a single IPeripheral
instance and caching it

On Thu, Nov 6, 2014 at 2:25 PM, Daniel Ratcliffe [email protected]
wrote:

Unless there is a major bug in the system (in which case turtle modems
wouldnt work), the problem is with your code. An ITurtleAccess unique to
each turtle is passed into the createPeripheral call

On Thu, Nov 6, 2014 at 12:54 PM, Charlie [email protected] wrote:

Then why does my non-static reference to ITurtleAccess in my peripheral
always only ever return the last placed turtle?
Why does my non-static list duplicate across all placed turtles with the
peripheral?
Storing data using the NBT save functionality is impractical as you can't
access it with the IComputerAccess you are given with the callMethod
function


Reply to this email directly or view it on GitHub
#8 (comment).