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

use 'converter' env argument

Started by DjTranceFire, 27 January 2015 - 09:29 AM
DjTranceFire #1
Posted 27 January 2015 - 10:29 AM
Hey guys.
I'm still experimenting with CC and AE2 stuff to learn everything about lua and CC and it seems like its going into the right direction.
This time i'm trying to request the crafting of an item. The ME knows the recipe and everything should work.
The command to request some items is "requestCrafting". Infos from the documentation:
Spoiler

requestCrafting: Request the specified item to get crafted.
source: me_interface
returns:
args:
- (table)item: Details of the item you want to craft: { id, [ dmg, [nbt_id]] }
- (number)qty?: The quantity of items you want to craft
- (string)cpu?: The name of the CPU you want to use

The item and qty are no problem, but the CPU seems to be one.
First i need the name. It should not be a big deal because there is "getCraftingCPUs"
But the problem starts because none of the attached crafting CPU's have a name.

Spoiler

lua> me = peripheral.wrap("bottom")
lua> me.getCraftingCPUs()
{
	{
		name = "",
		coprocessors = 0,
		busy = false,
		storage = 65536,
	}
}
lua>

So because "requestCrafting" needs a name and the CPU doesnt have one, it cant work.
I tested to rename the CPU in an anvil and that seems to work.


Spoiler

lua> me = peripheral.wrap("bottom")
lua> me.getCraftingCPUs()
{
	{
		name = "test",
		coprocessors = 0,
		busy = false,
		storage = 65536,
	}
}
lua>

But now i still cant use "requestCrafting".
This is my current code:
Spoiler

me = peripheral.wrap("bottom")
list = me.getAvailableItems()

for number, item in pairs(list) do
	if item.nbt_id == "4b6ccebf85c96dde4d085c3c4f064878" then
		if item.qty >= 1 then
			me.exportItem(list[number], 1, 0)
			print("Exported")
		else
			me.requestCrafting(list[number], 1, "test")
			print("Crafting")
		end
	end
end

If atleast one item with the correct nbt_id is inside the me everything works fine and it gets exported.
If not i just get that error and i cant find anything about it in this board/google.


test:11: use 'converter' env argument

I hope that someone here knows how to fix this error.
Sorry for my bad english, i hope its not to hard to understand.
Edited on 27 January 2015 - 01:07 PM
Bomb Bloke #2
Posted 27 January 2015 - 02:04 PM
Try running this in the shell. If you're lucky, it'll give you some info:

openp/docs bottom requestCrafting
Dragon53535 #3
Posted 27 January 2015 - 02:05 PM
Test is not the same as test, see if by changing

me.requestCrafting(list[number],1,"test")
to

me.requestCrafting(list[number],1,"Test")
See if that fixes it
DjTranceFire #4
Posted 27 January 2015 - 02:09 PM
Try running this in the shell. If you're lucky, it'll give you some info:

openp/docs bottom requestCrafting

Thats the content in the first spoiler of my post.

Test is not the same as test, see if by changing

me.requestCrafting(list[number],1,"test")
to

me.requestCrafting(list[number],1,"Test")
See if that fixes it

Already fixed, fixed it into my first post too so it doesnt confuse.
It does not solve the problem.
Dragon53535 #5
Posted 27 January 2015 - 07:28 PM
Can you show us how the item table is formatted?
So can you have it print out one of the items so we can see how it looks?
DjTranceFire #6
Posted 27 January 2015 - 08:05 PM
Can you show us how the item table is formatted?
So can you have it print out one of the items so we can see how it looks?


1:
    dmg: 0
    display_name: Mana Bean
    raw_name: item.itemmanabean
    qty: 0
    ench:
    max_size: 64
    name: ItemManaBean
    ore_dict:
    nbt_id: 4b6ccebf85c96dde4d085c3c4f064878
    max_dmg: 0
    id: Thaumcraft:ItemManaBean
    mod_id: Thaumcraft
    is_craftable: true
2:
    display_name: Mana Bean
    qty: 59
    dmg: 0
    max_dmg: 0
    raw_name: item.itemmanabean
    name: ItemManaBean
    id: Thaumcraft:ItemManaBean
    ench:
    ore_dict:
    nbt_id: a48486be825d662a858a1c09ad41a858
    max_size: 64
    mod_id: Thaumcraft
3:
    display_name: Mana Bean
    qty: 59
    dmg: 0
    max_dmg: 0
    raw_name: item.itemmanabean
    name: ItemManaBean
    id: Thaumcraft:ItemManaBean
    ench:
    ore_dict:
    nbt_id: d458a442d7760e5e40c17efc5d7fc9e2
    max_size: 64
    mod_id: Thaumcraft

Seems like there is a different sorting method if the item is craftable or not.. o.O
Edited on 27 January 2015 - 08:33 PM
Dragon53535 #7
Posted 27 January 2015 - 09:34 PM
I think that the problem you've got is that when passing the tables that are the items, is that it's probably looking for numerically indexed tables. Instead of

me.requestCrafting(list[number],1,"test")
try using

me.requestCrafting({item.id},1,"test")
DjTranceFire #8
Posted 27 January 2015 - 09:58 PM
I think that the problem you've got is that when passing the tables that are the items, is that it's probably looking for numerically indexed tables. Instead of

me.requestCrafting(list[number],1,"test")
try using

me.requestCrafting({item.id},1,"test")


Tested but it does not work.


Failed to convert arg 'item' value '{1.0=Thaumcraft:ItemManaBean}' to 'SearchNeedle'
Edited on 27 January 2015 - 08:58 PM
Bomb Bloke #9
Posted 28 January 2015 - 11:11 PM
Personally, I've never even made an ME system, so at the moment I'm only equipped to throw guesses at you.

But try:

me = peripheral.wrap("bottom")
list = me.getAvailableItems()

for number, item in pairs(list) do
        if item.nbt_id == "4b6ccebf85c96dde4d085c3c4f064878" then
                if item.qty >= 1 then
                        me.exportItem(list[number], 1, 0)
                        print("Exported")
                else
                        me.requestCrafting({id = list[number].id, dmg = list[number].dmg, nbt_id = list[number].nbt_id}, 1, "test")
                        print("Crafting")
                end
        end
end
DjTranceFire #10
Posted 28 January 2015 - 11:19 PM
Personally, I've never even made an ME system, so at the moment I'm only equipped to throw guesses at you.

But try:

me = peripheral.wrap("bottom")
list = me.getAvailableItems()

for number, item in pairs(list) do
		if item.nbt_id == "4b6ccebf85c96dde4d085c3c4f064878" then
				if item.qty >= 1 then
						me.exportItem(list[number], 1, 0)
						print("Exported")
				else
						me.requestCrafting({id = list[number].id, dmg = list[number].dmg, nbt_id = list[number].nbt_id}, 1, "test")
						print("Crafting")
				end
		end
end


This throws the exact same error.


test:10: use 'converter' env argument

But for now the problem seems to be solved in some way. Atleast for now.
I updated all the mods and now the complete table changed.
Because of that i have another problem first before i can hope that this problem is fixed then.
For now.. Thank you all! :)/>
Dragon53535 #11
Posted 29 January 2015 - 01:11 AM
I figured that something in the mod was off, as i've never heard of the kind of error you were receiving. I do hope you do well in your future endeavors.