This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
XMrPotatoX's profile picture

Error in simple code

Started by XMrPotatoX, 18 February 2014 - 05:51 PM
XMrPotatoX #1
Posted 18 February 2014 - 06:51 PM
I have OpenPeripherals and Applied Energistics installed and I'm trying to automate some crafting using a computer. My setup is fine, this code works with other blocks its the colon in the ID that is messing things up.

controller = peripheral.wrap("bottom")
controller.requestCrafting({ id=35:1, qty=1 })

the error I'm getting is

bios:339: [string "test"]:2: '}' expected


Theres probably a very simple fix for this, but I just don't know enough about this stuff to see it.
Bubba #2
Posted 18 February 2014 - 07:58 PM
Lua does not recognize 35:1 as a number - it doesn't recognize it as anything, actually, except an error. I don't know how OpenPeripheral interfaces with AE, but if you're supposed to pass metadata like that it would have to be in quotes ("35:1") or in decimal format (35.1).
theoriginalbit #3
Posted 18 February 2014 - 08:05 PM
I don't know how OpenPeripheral interfaces with AE
neither do I… I'll look it up :)/> :P/>
Bubba #4
Posted 18 February 2014 - 08:10 PM
I don't know how OpenPeripheral interfaces with AE
neither do I… I'll look it up :)/> :P/>

Hang on. I thought you wrote code for OpenP? Or am I getting it wrong and you actually worked on OpenBlocks. Or was it OpenXP?

Too many Open[insert noun] for me to keep track of.
XMrPotatoX #5
Posted 18 February 2014 - 08:19 PM
Lua does not recognize 35:1 as a number - it doesn't recognize it as anything, actually, except an error. I don't know how OpenPeripheral interfaces with AE, but if you're supposed to pass metadata like that it would have to be in quotes ("35:1") or in decimal format (35.1).

Using 35.1 seems to "work", no errors are produced but the system doesn't react. Putting it in quotes produces this error

test:2: java.lang.String cannot be cast to java.lang.Double
I'll just try to find another way to go about this.

I don't know how OpenPeripheral interfaces with AE
neither do I… I'll look it up :)/> :P/>

I'm going off the info I found here http://www.dnacraft....liedenergistics
theoriginalbit #6
Posted 18 February 2014 - 08:22 PM
Hang on. I thought you wrote code for OpenP? Or am I getting it wrong and you actually worked on OpenBlocks. Or was it OpenXP?
I'm in the OpenMods team, I could work on anything I like, but so far I've only been working on OpenP… just 'cause I work on that project though doesn't mean I know everything about everything, the AE module was already made when I joined :P/> I just tweaked how all the modules worked a little and went back to working on bugs and terminal glasses and TODO's

I'm going off the info I found here http://www.dnacraft....liedenergistics
ah yes, well if you're using a 1.6.4 version of OpenPeripheral those may be different.

okay so after some investigating, in the latest version of OpenP (well really any 1.6.4 version) when invoking extractItem on the AE network it requires two arguments, the ItemStack and the direction to extract it. The direction is pretty straight forward, give it "up", "down", etc… however the ItemStack actually requires a table that represents the ItemStack, from what I can tell this table needs to be one that you've gathered from one of the several methods provided that allows you to get information about the items in the system.
Edited on 18 February 2014 - 07:23 PM
XMrPotatoX #7
Posted 18 February 2014 - 08:34 PM
ah yes, well if you're using a 1.6.4 version of OpenPeripheral those may be different.

okay so after some investigating, in the latest version of OpenP (well really any 1.6.4 version) when invoking extractItem on the AE network it requires two arguments, the ItemStack and the direction to extract it. The direction is pretty straight forward, give it "up", "down", etc… however the ItemStack actually requires a table that represents the ItemStack, from what I can tell this table needs to be one that you've gathered from one of the several methods provided that allows you to get information about the items in the system.

I wasn't even aware that extractItem existed. That solves most, if not all, of my problems. Thanks a billion :D/>
theoriginalbit #8
Posted 18 February 2014 - 08:50 PM
I wasn't even aware that extractItem existed. That solves most, if not all, of my problems. Thanks a billion :D/>
no problems… well it seems the second edit I made didn't go through, I added saying that requestCrafting could work the same, but the way you're doing it is potentially correct too. the only thing I can suggest is making a change and trying


peripheral.call("bottom", "requestCrafting", { id=35, metadata=1, qty=1 })

'cause I'm not entirely positive on how AE creates ItemStacks, I'll have to try and investigate further for you :)/>

EDIT: oh leaving out the metadata should give you a meta of 1 btw. derp it'd give 0, I've spent too long away from real languages, time to stop coding in Lua it seems.
Edited on 18 February 2014 - 08:04 PM
theoriginalbit #9
Posted 18 February 2014 - 09:01 PM

peripheral.call("bottom", "requestCrafting", { id=35, metadata=1, qty=1 })
Okay so i read AE's implementation and found that its definitely all done in our converters, so I read those and I was close…


peripheral.call("bottom", "requestCrafting", { id=35, dmg=1, qty=1 })

obviously the above table will also work for extractItem too, or you can use one of the ones you get elsewhere!
Edited on 18 February 2014 - 08:02 PM
XMrPotatoX #10
Posted 18 February 2014 - 09:17 PM

peripheral.call("bottom", "requestCrafting", { id=35, metadata=1, qty=1 })
Okay so i read AE's implementation and found that its definitely all done in our converters, so I read those and I was close…


peripheral.call("bottom", "requestCrafting", { id=35, dmg=1, qty=1 })

obviously the above table will also work for extractItem too, or you can use one of the ones you get elsewhere!

Oh man, you've helped me so much and given me new things to play with, I feel like a kid at Christmas. With what you've said a lot of the other methods make more sense now too. I love the work you and your team does :D/>
theoriginalbit #11
Posted 18 February 2014 - 09:25 PM
haha! you're welcome.