Jump to content




[mc 1.6.x] Openperipheral


  • This topic is locked This topic is locked
1184 replies to this topic

#701 Sorcelator

  • Members
  • 24 posts

Posted 25 September 2013 - 08:42 AM

Maybe you guys can help me with this. I have some code I want to loop that checks for ore in a chest and moves it if it finds it. However, the code never loops. What am I missing? and can I do this better?

chest.condense() --Organize the Chest
local slotnum = chest.getSizeInventory() --Use the Max Invantory Size to calculate the Slot number and Loop amount
while true do
	sleep(5)
	--push completed items out of the mace and efurn--
	mace.push("north", 1, 64)
	efurn.push("up", 1, 64)
	--start looking for ore--
	for i=1,slotnum do -- LOOP!
		local tableInfo = chest.getStackInSlot(i)
		if tableInfo ~= nil then
			for key, value in pairs(tableInfo) do
				if string.find(value, "Ore") then -- Find Ore
					print("Ore Found! Moving to Macerator!")
					chest.push("north", i, 64)
					
				end
			end
			
		end
	end

end


Also, is it just me, or does OP not understand what a double chest is? I'm pretty sure when you connect it with a ProxyBlock it thinks its a single chest and not a double.

edit:
Ok so I figured out what the issue was and here is how I fixed it.
chest.condense() --Organize the Chest
local slotnum = chest.getSizeInventory() --Use the Max Invantory Size to calculate the Slot number and Loop amount
local i = 0
while true do
	sleep(.5)
	i = i+1
	--push completed items out of the mace and efurn--
	mace.push("north", 1, 64)
	efurn.push("up", 1, 64)
	--start looking for ore--
	local tableInfo = chest.getStackInSlot(i)
	if tableInfo ~= nil then
		if string.find(tableInfo.name, "Ore") then -- Find Ore
			print("Ore Found in slot "..i..". Moving to Macerator!")
			chest.push("north", i, 64)
		else
			shell.run("clear")
			print("Chest contains "..tostring(slotnum).." slots")
			print("Slot "..i.." contains no Ore")				
		end
	else
		i = 0
	end		
	if i == 27 then
		i = 1
	end
end

When the code that finds the ore finds nothing, it starts spits out a nill. My code said "if tableinfo ~=nil then do stuff" so it would work for a while and then die out. I figured out that it was failing right after it hit slots with NO items in it. This would cause a Nil and the code would do the else command. If the code spit out nil to many times the while true do loop would kill itself which is likely a failsafe in Computercraft. The reason I never got an error is that when the code did present me a nil I told it to do something. So it did what I asked and never showed me the nil error.

To fix this i changed what happened in the Else portion of the "if tableinfo ~= nil then". Instead of posting a message, I told it to reset the i variable to 0. This stops it from getting to many nil errors and starts from the beginning again. As long as there is one item in the chest that can't be moved then it will loop forever.

I've cleaned this up a lot, made it only look for the key value of Name in the tableinfo table. This allowed me to get rid of the "for i=1,slotnum do" and the for key, value in pairs(tableInfo) do portion of the code because it was redundant. Now the code works exactly like I need it to. It finds anything that has Ore in its name and moves it to the Macerator and gets the smelting process going. The only downside i've found so far is that it finds items like Cinnabar Ore, which can't be used in a macerator. I'm sure I can figure out a way to add items to a filter or something later.

#702 Imnafoy

  • New Members
  • 2 posts

Posted 25 September 2013 - 01:55 PM

View PostPixelToast, on 24 September 2013 - 04:35 PM, said:

yes, this happens with all of the bools returned by openP
it was confusing at first, now i just put a=="true" in the statements
Ok, what else can I do. :D But it is extremly confusing, especially when documentations says that it returns boolean

#703 ElvishJerricco

  • Members
  • 803 posts

Posted 25 September 2013 - 11:44 PM

getStackInSlot didn't work so I fixed it. Pull request 50

EDIT: Oh wow i misread that code. The function didn't work as I expected, I thought I saw a bug, turns out I just misread things in my tired mind. Apologies.

#704 iconmaster

  • Members
  • 17 posts

Posted 28 September 2013 - 11:15 AM

I want and built the most recent version of this mod from GitHub, and I noticed the robot controller still has no recipe. I'd like to playtest it in Survival as soon as possible! Also, how do you install upgrades? I can't seem to figure it out.

#705 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 28 September 2013 - 11:25 AM

View Posticonmaster, on 28 September 2013 - 11:15 AM, said:

I want and built the most recent version of this mod from GitHub
No need to do that, Jenkins does it for you xD

#706 cja711

  • New Members
  • 1 posts

Posted 29 September 2013 - 04:34 PM

Hopefully you can help me with this, I am trying to use the glasses to create an overview type thing for my base, showing ae system storage, ic2 power, bc power, those kinds of things. How would I do it so that every time something changes it updates the HUD on the glasses?

#707 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 29 September 2013 - 06:22 PM

View Postcja711, on 29 September 2013 - 04:34 PM, said:

Hopefully you can help me with this, I am trying to use the glasses to create an overview type thing for my base, showing ae system storage, ic2 power, bc power, those kinds of things. How would I do it so that every time something changes it updates the HUD on the glasses?
There is no way to know when something changes, you'll just have to go and refresh everything at a certain interval, say 0.8 seconds or so.

#708 ElvishJerricco

  • Members
  • 803 posts

Posted 29 September 2013 - 06:22 PM

View Postcja711, on 29 September 2013 - 04:34 PM, said:

Hopefully you can help me with this, I am trying to use the glasses to create an overview type thing for my base, showing ae system storage, ic2 power, bc power, those kinds of things. How would I do it so that every time something changes it updates the HUD on the glasses?

There's two ways. One, you could clear the glasses and do a generic redraw of the whole HUD.

But the better way would be to call the setter methods on the graphics objects. Any call to the glasses bridge to draw something typically returns an object with setters and getters for all its properties such as x, y, width, height, color, text, etc.

t = bridge.addText( ... )
t.setText("new text")

Just hold on to all of your objects and edit them as needed.

#709 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 29 September 2013 - 06:25 PM

View PostElvishJerricco, on 29 September 2013 - 06:22 PM, said:

One, you could clear the glasses and do a generic redraw of the whole HUD.
This in older versions can cause deadlocks, and in all versions can cause some flicker if done too frequent. this should never even make it into the lists of suggestions. use setters ALWAYS.

#710 ElvishJerricco

  • Members
  • 803 posts

Posted 30 September 2013 - 02:21 PM

View Posttheoriginalbit, on 29 September 2013 - 06:25 PM, said:

This in older versions can cause deadlocks, and in all versions can cause some flicker if done too frequent. this should never even make it into the lists of suggestions. use setters ALWAYS.

Right. Never said it was the good way =P

#711 xypista

  • Members
  • 4 posts

Posted 01 October 2013 - 03:28 PM

I'm using the snapshot 54 and everything is inverted. pushItemIntoSlot is pull, pullItemIntoSlot is push, north is south, east is west (in the parameters), ... Kinda funny. I hope it is a bug in the snapshot.

#712 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 01 October 2013 - 11:10 PM

View Postxypista, on 01 October 2013 - 03:28 PM, said:

I'm using the snapshot 54 and everything is inverted. pushItemIntoSlot is pull, pullItemIntoSlot is push, north is south, east is west (in the parameters), ... Kinda funny. I hope it is a bug in the snapshot.
Cannot reproduce. Please provide more information.

#713 NEOparmen

  • Members
  • 17 posts

Posted 02 October 2013 - 09:05 AM

Is there any way to detect if it's raining in version 0.2.1 ?

#714 xypista

  • Members
  • 4 posts

Posted 02 October 2013 - 03:54 PM

View Posttheoriginalbit, on 01 October 2013 - 11:10 PM, said:

Cannot reproduce. Please provide more information.

Oh sorry my bad. I just not didn't know exactly how it works.

Another thing: Is there any way to push/pull item to an Iron Furnace upper slot from IC2 experimental? Slot 3 works for the fuel slot, but can't find an ID for the upper one. (Normal furnace works fine with ID 1 and 2)

#715 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 02 October 2013 - 04:54 PM

View Postxypista, on 02 October 2013 - 03:54 PM, said:

Another thing: Is there any way to push/pull item to an Iron Furnace upper slot from IC2 experimental? Slot 3 works for the fuel slot, but can't find an ID for the upper one. (Normal furnace works fine with ID 1 and 2)
Furnace http://puu.sh/4G2tW.png
Computer http://puu.sh/4G2x7.png

Based off the information there should slot 1 (input slot) not work?

#716 xypista

  • Members
  • 4 posts

Posted 03 October 2013 - 02:58 PM

View Posttheoriginalbit, on 02 October 2013 - 04:54 PM, said:

View Postxypista, on 02 October 2013 - 03:54 PM, said:

Another thing: Is there any way to push/pull item to an Iron Furnace upper slot from IC2 experimental? Slot 3 works for the fuel slot, but can't find an ID for the upper one. (Normal furnace works fine with ID 1 and 2)
Furnace http://puu.sh/4G2tW.png
Computer http://puu.sh/4G2x7.png

Based off the information there should slot 1 (input slot) not work?

Yes, getAllStacks() shows it just as in your pic, but pullItemIntoSlot() and pushItemIntoSlot() not work with ID 1. Slot 2 (output) and 3 (fuel) works with these functions.

Oh, I see now... It works just as with pipes. It can pull items to slot 1 only from a chest above it. Altough that's not the case with the normal furnace. It can pull items from anywhere.

Edited by xypista, 03 October 2013 - 06:07 PM.


#717 oxinabox

  • Members
  • 5 posts

Posted 03 October 2013 - 08:12 PM

I have found:
Well I wouldn't term it a bug, but it is a cross mod issue.

ForgeIRC is a popular mod for forwarding messages between ingame chat and a IRC channel (and back again).

The $$ chat messages, to terminal glasses are hidden from other players in game,
but not from the people watching on IRC.

My suggested fix is to change it from a Chat that is magically filtered by all the clients, (which is a guess as to how it works)
to a / command.

#718 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 October 2013 - 09:10 PM

View Postoxinabox, on 03 October 2013 - 08:12 PM, said:

My suggested fix is to change it from a Chat that is magically filtered by all the clients, (which is a guess as to how it works)
to a / command.
It's not filtered, the message is intercepted before it goes any further (as far as I can tell) and it then cancelled event.setCanceled(true).

Changing it to a command would be worse, as when registering a command with Minecraft's command handler you must specify a keyword, meaning it would need to be /glasses [your command here] as opposed to $$[your command here]. My suggestion would be for someone to make a ForgeIRC plugin to filter those messages from it.

#719 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 04 October 2013 - 07:34 AM

A few random updates from me:

1) The ForgeIRC thing is not a OpenPeripheral bug.
2) Push/pull item is not inverted. It's working exactly as it should, and always has.
3) OpenPeripheral 0.2.x for 1.6.x was returning strings for booleans and integers, but is fixed in the latest versions
4) Robots still aren't craftable
5) OpenPeripheral respects ISidedInventory, so for things like furnaces you'll have to push/pull from a certain direction for it to work

Sorry if I don't update this thread as much as I should - NeverCast, Foone and theoriginalbit have been doing a great job of keeping the project active when I don't have time to. I'm pretty stretched right now across work, life, other mods.etc.

#720 karelmikie3

  • Members
  • 112 posts

Posted 05 October 2013 - 06:01 PM

sgcraft connecting and disconnecting doesn't seem to work is this a bug or did i just miss something





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users