Jump to content




Disk API


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

#1 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 08 February 2013 - 11:49 AM

I am building a theme park in Tekkit, and I want to make it so the ticket is made so that the computer check the label. I know what the disk API is, but how do I use it?

#2 ChunLing

  • Members
  • 2,027 posts

Posted 08 February 2013 - 11:53 AM

Knowing what it is would include knowing how to use it. In this particular case you want to use disk.getLabel() somehow.

#3 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 08 February 2013 - 12:01 PM

What do you mean by how to use it?

OK. In a nutshell...

When you insert a disk, CC mounts it. YOu can reach its data in disk/ directory, or disk2/ if that's the second mounted disk, or disk3/, etc.

So opening a file from a disk is like
local handle = fs.open("disk/myfile", "r")

When you have only one disk drive, that's easy like that. But what's up with multiple disk drives?

You can get the path ("disk" or "disk2" etc.) using
disk.getMountPath(side)
where side is the side where the disk drive you want to use is.

EDIT: Sorry, I misunderstood - I thought you haven't ever used disk API.

#4 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 08 February 2013 - 12:36 PM

 LBPHacker, on 08 February 2013 - 12:01 PM, said:

What do you mean by how to use it?

OK. In a nutshell...

When you insert a disk, CC mounts it. YOu can reach its data in disk/ directory, or disk2/ if that's the second mounted disk, or disk3/, etc.

So opening a file from a disk is like
local handle = fs.open("disk/myfile", "r")

When you have only one disk drive, that's easy like that. But what's up with multiple disk drives?

You can get the path ("disk" or "disk2" etc.) using
disk.getMountPath(side)
where side is the side where the disk drive you want to use is.

EDIT: Sorry, I misunderstood - I thought you haven't ever used disk API.

I want it to automatically check for the label.

So, can you get this to work:

if disk.getLabel("top") == "SFTTicket" then
blah blah blah code
end

Idk how to get it to work. It always says "returned nil"

EDIT: GOT IT! THE ERROR WAS WHERE I PUT BLAH BLAH BLAH CODE





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users