MiscPeripheral + Applied Energistics @ ME Bridge

Slackerony

New Member
Jul 29, 2019
67
0
0
Can someone explain how this works? - I want a simple program, that, spits out a list of items on a bunch of monitors above it.
However, i seem to not be able to make it work - Help is appreciated.

Here's what i got:

To start with, i just wanted it, to spit out the list on the computer at hand. Putting it up on the monitor, i believe i know how to do.

m = Peripheral.wrap("left") -- The ME Bridge was on the left side.
m.listAll()

I run the program, and nothing happens, What am i missing?


Note: I havn't used MiscPeripherals much. and my lua isn't noteworthy either :p
 

ratchet freak

Well-Known Member
Nov 11, 2012
1,198
243
79
you may wish to do

Code:
for ID,amount in pairs(m.listAll())do
  print(id..": "..amount)
end

also was it connected to a (powered) ME network
 

Slackerony

New Member
Jul 29, 2019
67
0
0
Yes, it's powered. test:6: attempt to concatenate nil and string

Line 6 is the ...print(id..": "..amount)

However, I tried adding another dot, so it's ... print(id...": "...amount)

This made the error msg, change to "bios:337: [string "test"]:6: ')' expected

I realise it's a ) that's missing, but where, i don't know.
 

Platinawolf

New Member
Jul 29, 2019
147
0
0
Hmm,,, Sure its just not capitalized the (ID.. ": " ..amount) ? Mind you, I speak JAVA and not LUA so i might be way off in that computers are bloody stupid and can't tell that id and ID are the same thing ^^*
 

Slackerony

New Member
Jul 29, 2019
67
0
0
Negative - I tried changing the ID to id, and still have the same problem. Nothing has changed :-(
 

Hydra

New Member
Jul 29, 2019
1,869
0
0
Can you post the entire blob of code in code tags? Can't help you if we can't see if you messed something up.

The string concatenation operator is two dots by the way, don't just add dots and hope it works.
 

Slackerony

New Member
Jul 29, 2019
67
0
0
Can you post the entire blob of code in code tags? Can't help you if we can't see if you messed something up.

The string concatenation operator is two dots by the way, don't just add dots and hope it works.

Hence why i mentioned what i changed, so that if i was wrong, he could tell me, :) - Also i believe it was one of direwolfs video's where i saw him use 3 dots, And thus i thought that might fix it.
Code:
m = peripheral.wrap("left")
m.listAll()
s = peripheral.wrap("top") -- top is the monitor, havn't actually used this line for anything yet though
 
for ID, amount in pairs (m.listAll())do
  s.print(id..": "..amount)
end

And with that we're back to "test:6: attempt to call concatenate nil and string

edit: Also, Trial and error is the only way forward, if u don't know what you're doing :) or ask for help - Which i am.
 

Hydra

New Member
Jul 29, 2019
1,869
0
0
I had to check the API docs but monitors actually don't have a "print" function, and that's also not what's in the example the other guy gave you. Monitors are written to through the write function.

When learning any programming stuff it's important not to try everything at the same time. Seperate the thing in separate subproblems and work them out one by one. Learn how to write to a monitor and how to interface with the AE bridge separately and when you have figured both out combine them.
 

paulwood15

New Member
Jul 29, 2019
2
0
0
ok thanks for the help above^^^
but now im having problems with the retrieve method and i always get an error of just 3
heres my code:
m = peripheral.wrap("left")
m.retrieve(1, 100, 1)
i want to just for testing purposes retrieve 100 stone and output it through side 1.
 

Hydra

New Member
Jul 29, 2019
1,869
0
0
I have no experience with that part of the mod, what you could try:
- Make sure the id you have is actually in the list you get from listAll. I believe they're not block IDs but some kind of internal ID.
- I don't know if you can actually get more than a stacksize at a time, try a number less than 100 (1 or so as a start ;)).
- Make sure you have the right direction
 

Hydra

New Member
Jul 29, 2019
1,869
0
0
Actually: I just tried it and I think the thing is just broken at the moment.
 

snooder

New Member
Jul 29, 2019
363
0
0
OP, try putting a "".. in front of id. So it's like (""..id.." : "..amount).

What's probably happening, not 100% sure about lua, but it happens in other languages, is that the concatenation operator takes it's functionality from the argument to the left of the operator. In languages where this is an issue, putting an empty string "" all the way to the left forces an initial string concatenation and then that cascades forward so the entire expression is evaluated as a series of string concatenations.
 

voidreality

New Member
Jul 29, 2019
117
0
0
Force what's printed to be a string. Will stop the type errors given from print.

Code:
print(tostring(k)..": "..tostring(v))

As far as the monitor. It works exactly like the term API. The API can be found here. http://computercraft.info/wiki/Term_(API)
So in this case you could do something like
Code:
m = peripheral.wrap("left")
mon = peripheral.wrap("top")
myList = m.listAll()
 
mon.clear()
y = 1
for k, v in pairs (myList) do
  mon.setCursorPos(1, y)
  mon.write(tostring(k)..": "..tostring(v))
  y = y + 1
end
 
  • Like
Reactions: Slackerony

paulwood15

New Member
Jul 29, 2019
2
0
0
Ok thanks. I had a cool jdea tho where i had a second base somewhere and have my main storage at my main base and i would request an item over rednet and it would send it over on a railcart.
Is there any other way to do this?