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

reading pointers

Started by JokerRH, 25 February 2013 - 12:39 AM
JokerRH #1
Posted 25 February 2013 - 01:39 AM
Tables, functions, etc. in lua are pointers that refer to a memory slot, therefor they should be saved as binary code.
What i've been searching for is a way to "read" that pointer as an array of bytes, but i haven't found any solutions for this anywhere (even not in the lua users forum).
I want to use this for example to send and receive tables and functions, as bytes are numbers and you can send or receive them via rednet or redpower bundled cables…

I hope anyone knows if or how this is possible…:D/>
-JokerRH
Eric #2
Posted 25 February 2013 - 01:43 AM
String.dump(f) will allow you to send simple functions which contain no upvalues.
theoriginalbit #3
Posted 25 February 2013 - 01:59 AM
Rednet doesn't work with string dump. just use the textutils api specifically serialize and unserialize to send your tables as strings.

Just a side note. if you're using CC1.5+ you can no longer use the RP2 bundled cables for Rednet.
JokerRH #4
Posted 25 February 2013 - 03:09 AM
Using the textutils api I cannot serialize functions, that's why I hoped you could read the machine code directly…:(/>
And to the RP2 bundled cables: I didn't know it was possible to use them as rednet…I just thought about creating a serial comunication :D/>
Eric #5
Posted 25 February 2013 - 03:15 AM

More accurately, Events don't work with string.dump
theoriginalbit #6
Posted 25 February 2013 - 03:19 AM
You could write a custom serialisation. but sadly, since the rednet api doesn't support some of the chars that would exist when dumping a function…….. pastebin, then send the paste bin link over rednet, anyone? :P/> (please don't take that seriously)… maybe encoding the dump to base64 could work, since rednet is designed, kinda, for ASCII and not binary…



Same difference, still doesn't work.