Jump to content




Get item ID inside blood magic altar.


  • You cannot reply to this topic
28 replies to this topic

#21 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 01:12 AM

Those give me

Posted Image

Posted Image

Posted Image

This one could probably say something, but how do I write it to a file like you did just now. It returns so much at once.

Posted Image

Bump: found this under getStaclnSlot(1)

I got a blood orb in the altar so this seem to work.

Posted Image

#22 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 01:16 AM

Writing files using code: Tutorial

As for what I'm thinking here, lets check out
drive.getStackInSlot(1) --# IT actually occurs to me, this probably gives us the exact table that allStacks does, but only the [1] table.
and
drive.getAllStacks()[1].listMethods("properties")
And maybe
drive.getInventoryName()

Edited by Dragon53535, 17 January 2016 - 01:17 AM.


#23 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 01:22 AM

Running the drive.getStackInSlot(1) and then printing the ID part of the table seem to give me the correct ID of what is in the slot. But running this and taking something out gives me 216.

while true do

tbl = drive.getStackInSlot(1)
message = tbl.id
print(message)
sleep(0.2)
end

Posted Image

Posted Image


From here on out I'm pretty sure i now know what I need to finish this :) and make it faster, and need no clunky BC pipes and redpower wiring. I kinda led you on a wild goose chase there, but I learned a thing or two about how tables work. ^^ Though why does it return 216 and stops the program when nothing is in the altar?

Edited by fanzypantzy, 17 January 2016 - 01:24 AM.


#24 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 01:26 AM

216 sounds like it's just either nothing, or the altar's numerical id. With that information though, that means that you can easily know what's inside.
local item = drive.getStackInSlot(1)
if type(item) ~= "table" then --#HA! I remembered the " 's
  print(item.id)
  print(item.qty) --#The amount inside.
end

Edited by Dragon53535, 17 January 2016 - 01:27 AM.


#25 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 01:33 AM

I guess I'll just have to make sure I never use getStackInSlot while nothing is inside the altar. Or else the program stops. But I have no need to do so either, so np for me. Thank you very much dragon. Now onto the rewriting.

#26 Pyuu

  • Members
  • 203 posts

Posted 17 January 2016 - 01:34 AM

You could use a pcall to prevent erroring from happening.
Here is an example:
st,er = pcall(turtle.getStackInSlot,value)
if er then
-- Yay, no broken program.
else
val = turtle.getStackInSlot(value)
end


#27 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 01:37 AM

View PostMayushii, on 17 January 2016 - 01:34 AM, said:

You could use a pcall to prevent erroring from happening.
Here is an example:
st,er = pcall(turtle.getStackInSlot,value)
if er then
-- Yay, no broken program.
else
val = turtle.getStackInSlot(value)
end
First, good catch, second, your code can be shortened to this:
local noError,returnVal = pcall(drive.getStackInSlot,1)
if noError then
  --#There was no error, returnVal is now your table, in which it's good.
end


#28 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 01:46 AM

Tiny question: If I wrap a peripheral and then turn a turtle, then turn it back to the original position. Do I then need to rewrap the peripherals?

#29 Pyuu

  • Members
  • 203 posts

Posted 17 January 2016 - 01:48 AM

No you don't have to rewrap the peripherals.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users