how does loadstring work?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

how does loadstring work?

Post by the underminer »

How do I get this to work?

Code: Select all

assert(loadstring("response = 15"))
print(1,response)
The result is 1,nil

here's what the lua 5.1 reference has to say:
loadstring (string [, chunkname])

Similar to load, but gets the chunk from the given string.

To load and run a given string, use the idiom

assert(loadstring(s))()
Behold! The Underminer got hold of a PSP
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

ow excuse me, I forgot an extra ()

assert(loadstring("response = 15"))()
print(1,response)
Behold! The Underminer got hold of a PSP
Post Reply