Sign in to follow this  
AverageJoeSSU

saving lua function as string

Recommended Posts

Depends on what you mean by string. What you appear to be seeing is a binary string. Which the string.dump (Lua) and lua_dump (C) functions do.

What you seem to be asking, dumping a binary function as a string like you'd see in a Lua source file, then no you can't. That information gets discarded. (Unless you have the Lua source and modify the Lua library in C to save it somewhere as it gets parsed)

Share this post


Link to post
Share on other sites
I see,

Yeah the only thing i found was a lua decompiler.

The point of this is... i have an editor/GUI that allows someone to change the properties of an object (which is a lua table). And in order to allow editing of lua functions, i need to be able to save/load them at any time. Kind of interesting that it is the only first class variable in lua that you cannot truly print. I don't think 0x823597 func counts as printing something =).

anyways, i guess I'll just have to have an IDE for lua on the side of my editor and block out editing of functions in the properties grid =(.

Share this post


Link to post
Share on other sites
Well, if the user enters the function as text in a UI control there's no need to loadstring it immediately. You can just save it exactly as it's written, and when you need to execute it later then you can do loadstring. No need to store it in binary form.

Share this post


Link to post
Share on other sites
yeah good point.

I could always replace the binary form of the function.

on save i would have to dump the contents of all functions, the problem then would lie in getting the string values back from lua to the gui, which would require a parser., unless i started to serialize the C# data with the lua data, which gets a bit crazy.

keeping data persistent across loading and saving multiple times is not as easy as i thought.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this