Jump to content




Thaumcraft Automation Programming

help lua peripheral

49 replies to this topic

#41 the_hyren

  • Members
  • 29 posts

Posted 14 December 2015 - 05:28 PM

Ok, I'm using the interactive sorter to detect the recipe, this is simply a number of cobblestone, in my test case just 1. using
item = sorter.analyze()
should give my a table with values in it but the keys aren't integers and I dont know how to access them properly I guess. How is that done?

list of keys I need:
amount, stringId

#42 the_hyren

  • Members
  • 29 posts

Posted 14 December 2015 - 09:28 PM

An awesome update! I figured out that the keys act like functions eg. item.stringId is what I needed.

It seems my manager program is also working as intended.

And I'm quite close with the infuser program. I just have to write a method to do a little additional parsing since the me bridge needs a slightly different string
"mod:name meta" instead of "mod:name:meta" should be an easy fix!

#43 the_hyren

  • Members
  • 29 posts

Posted 14 December 2015 - 09:59 PM

So turns out I'm having trouble splitting my itemname string and reforming it to be compatible with the me bridge. Specifically:
splititem = split(itemname, ":")
  if #splititem == 3 then
	itemname = tostring(splititem[1])..":"..tostring(splititem[2]).." "..tostring(splititem[3])
  end
using this splitting function:
function split(s, delimiter)
  result = {};
  for match in (s..delimiter):gmatch("(.-)"..delimiter) do
	table.insert(result, match);
  end
  return result;
end

I'm guessing I can't use : as a delimiter, probably because its a standard expression or something.
So could anyone write me a function that takes a string and replaces the second ':' (if it exists) with a space?

Edited by the_hyren, 14 December 2015 - 11:10 PM.


#44 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 15 December 2015 - 12:43 AM

function stripSecondColen( str )
  return table.concat( { str:match( "([^:]+:[^:]+):?(.*)" ) }, " " )
end

Hackies.

#45 the_hyren

  • Members
  • 29 posts

Posted 15 December 2015 - 06:36 PM

Cool thanks! Just to make sure since I dont understand it much, if there isn't a second : what will this function do?

#46 the_hyren

  • Members
  • 29 posts

Posted 15 December 2015 - 07:12 PM

Hmmm. So I'm still crashing...

Spoiler

So my program does send the
"Get "..tostring(quantity).." "..itemname
But at some point between there and the transmit three lines later there is a crash that exits the infuser program.
This is all in the grabitem function and the item Im getting is Thaumcraft:ItemResource:14 which is Salis Mundis.
Could it be the modem.transmit crashing?

Edited by the_hyren, 15 December 2015 - 07:14 PM.


#47 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 December 2015 - 11:52 PM

View Postthe_hyren, on 15 December 2015 - 07:12 PM, said:

Could it be the modem.transmit crashing?

Again, if you aren't getting an error message telling you the problematic line, then you can pinpoint it by distributing print statements throughout your script.

#48 the_hyren

  • Members
  • 29 posts

Posted 16 December 2015 - 12:32 AM

Right I did that. with my modem transmits, I cant really put a moniter on it since it has all its sides used

#49 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 16 December 2015 - 01:21 AM

Then do the smart thing, and print to the screen itself, and not modem.transmit.

#50 the_hyren

  • Members
  • 29 posts

Posted 16 December 2015 - 03:33 AM

It would not be able to do a full infusion since it has a modem on top, needs to output 3 redstone signals and has the bridge on the other side, its also in a cheat free server. I will try a test setup in a ssp creative world





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users