Jump to content

[SOLVED]propper use of unserialize to run functions?

2 replies to this topic

#1 qwerty

  • Members
  • 72 posts
  • LocationThe Sand Dunes

Posted 23 February 2020 - 11:43 AM

A new problem I've run into is: how do I run scripts that have been unserialized.

I understand how
works, how ever my issue is that, not only do I not know how to pass commands to the lua prompt, but also the problem that when calling
it trhows a nill error, but it prints just fine.

I'm using plethora's chat recorder with the standard script running code but slightly altered to run the lua code entered in chat.
the original plethora's code found here
(It's the third code snippet)

and my code that I'm using-

--[[irrelevant code

local function clear()


local chat = peripheral.wrap("right")

while true do

--message catching
  local _, player, message, uuid = os.pullEvent("chat_message")

--message parsing
  local tempmsg = string.sub(message,2)
  tempvar = textutils.unserialize(tempmsg)

  print(tempvar) --pre edit: print(tempmsg)

--atempted function call


With regards

Edited by qwerty, 25 February 2020 - 08:43 AM.

#2 Lupus590

  • Members
  • 2,027 posts
  • LocationUK

Posted 23 February 2020 - 02:27 PM

you want loadstring not textutils.unserialise, functions and coroutines can't be serialised in the version of lua that CC has.

#3 qwerty

  • Members
  • 72 posts
  • LocationThe Sand Dunes

Posted 24 February 2020 - 09:26 AM

View PostLupus590, on 23 February 2020 - 02:27 PM, said:

you want loadstring not textutils.unserialise...
Thanks man! woorks like a charm now!

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users