Jump to content




reading pointers


  • You cannot reply to this topic
5 replies to this topic

#1 JokerRH

  • Members
  • 147 posts

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

#2 Eric

  • Members
  • 92 posts
  • LocationUK

Posted 25 February 2013 - 01:43 AM

String.dump(f) will allow you to send simple functions which contain no upvalues.

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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.

#4 JokerRH

  • Members
  • 147 posts

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

#5 Eric

  • Members
  • 92 posts
  • LocationUK

Posted 25 February 2013 - 03:15 AM

View PostTheOriginalBIT, on 25 February 2013 - 01:59 AM, said:


More accurately, Events don't work with string.dump

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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...



View PostEric, on 25 February 2013 - 03:15 AM, said:

Same difference, still doesn't work.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users