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

Wired Modem Function Return

Started by Mr_Programmer, 04 April 2016 - 09:39 PM
Mr_Programmer #1
Posted 04 April 2016 - 11:39 PM
Hi all,

I am wanting to interact with a powered spawner from MFR, when calling "getStackInSlot" it returnes a function eg "Function : 77583f51"
This changes everytime aswell so how can i make this into a readable line so my auto detect function reads what is in the spawner and then dislpays it?

Any help will be appreciated :P/>
Edited on 04 April 2016 - 09:40 PM
Lyqyd #2
Posted 04 April 2016 - 11:48 PM
Please post your code. You are likely not calling the function.
Mr_Programmer #3
Posted 04 April 2016 - 11:50 PM
Please post your code. You are likely not calling the function.
Currently not using my own code, using a test code at the moment but here it is
for i,v in ipairs(peripheral.getMethods("powered_tile_0"))
  do print(i..". "..v)
end

sp = peripheral.wrap("powered_tile_0")



print(sp.getTankInfo)
Lyqyd #4
Posted 04 April 2016 - 11:55 PM
You are not calling the function.


print(sp.getTankInfo())
Mr_Programmer #5
Posted 05 April 2016 - 12:00 AM
You are not calling the function.


print(sp.getTankInfo())

Now it returnes a table number?
Edited on 04 April 2016 - 10:00 PM
KingofGamesYami #6
Posted 05 April 2016 - 12:15 AM
Print the contents of the table.
Mr_Programmer #7
Posted 05 April 2016 - 12:39 AM
Print the contents of the table.

:o/> How? I cant remember LOL!
Bomb Bloke #8
Posted 05 April 2016 - 01:13 AM
http://www.computercraft.info/wiki/Textutils.serialize
Mr_Programmer #9
Posted 06 April 2016 - 09:47 PM
So i managed to sort the table thing out however if i want to print out what the stack name is, what would i do?
Lyqyd #10
Posted 07 April 2016 - 01:04 AM
What do you mean by "stack name"?
Bomb Bloke #11
Posted 07 April 2016 - 01:28 AM
This guide should help you deal with individual table keys. You may also find this thread helpful.
Mr_Programmer #12
Posted 08 April 2016 - 06:44 PM
This guide should help you deal with individual table keys. You may also find this thread helpful.
Ok well i still done understand, let me explain so you full understand and can help :P/>

Im using MFR spawner with networking cable to get the name of the mob in the safari net, the code im using atm to get the data is
for i,v in ipairs(peripheral.getMethods("powered_tile_0"))
  do print(i..". "..v)
end

sp = peripheral.wrap("powered_tile_0")


local test = textutils.serialize(sp.getStackInSlot(1))
print(test)

In which returns this

http://imgur.com/b8FwAGO

when looking at the forum post you linked i tried this
 local test = textutils.serialize(sp.getStackInSlot(1))
print(test[2].captured)

However all this did was "attempt to index ? (a nil value) I really dont understand, i have never done this kind of work with tables before
KingofGamesYami #13
Posted 08 April 2016 - 07:18 PM
That should be

print( test.safari_net.captured )
Mr_Programmer #14
Posted 08 April 2016 - 07:19 PM
That should be

print( test.safari_net.captured )
tried this after i made the last comment and i still get the same error
KingofGamesYami #15
Posted 08 April 2016 - 07:20 PM
*facepalm*

Didn't notice you were attempting to treat the serialized (eg string) table as a table. Try using the table directly.
Mr_Programmer #16
Posted 08 April 2016 - 07:21 PM
*facepalm*

Didn't notice you were attempting to treat the serialized (eg string) table as a table. Try using the table directly.
What do you mean table directly?
KingofGamesYami #17
Posted 08 April 2016 - 07:22 PM

print( sp.getStackInSlot( 1 ).safari_net.captured )
Mr_Programmer #18
Posted 08 April 2016 - 07:26 PM

print( sp.getStackInSlot( 1 ).safari_net.captured )

YES, that worked! thank you!