diff --git a/README.html b/README.html
index a80cc443..dc7567fd 100644
--- a/README.html
+++ b/README.html
@@ -259,6 +259,18 @@ Loading from a file is done via Globals.loadFile():
LuaValue chunk = globals.loadfile("examples/lua/hello.lua");
+Chunks can also be loaded from a Reader as text source
+
+
+ chunk = globals.load(new StringReader("print 'hello, world'"), "main.lua");
+
+
+or an InputStream to be loaded as text source "t", or binary lua file "b":
+
+
+ chunk = globals.load(new FileInputSStream("examples/lua/hello.lua"), "main.lua", "bt"));
+
+
A simple example may be found in
@@ -271,7 +283,7 @@ You must include the library lib/luaj-jse-3.0-beta2.jar in your class patRun a script in a MIDlet
-The for MIDlets the JmePlatform is used instead: +For MIDlets the JmePlatform is used instead:
import org.luaj.vm2.*; diff --git a/src/core/org/luaj/vm2/Globals.java b/src/core/org/luaj/vm2/Globals.java index 814e958c..bf98bdaf 100644 --- a/src/core/org/luaj/vm2/Globals.java +++ b/src/core/org/luaj/vm2/Globals.java @@ -197,6 +197,15 @@ public class Globals extends LuaTable { return load(new StrReader(script), chunkname); } + /** Convenience function to load a string value as a script. Must be lua source. + * @param script Contents of a lua script, such as "print 'hello, world.'" + * @return LuaValue that may be executed via .call(), .invoke(), or .method() calls. + * @throws LuaError if the script could not be compiled. + */ + public LuaValue load(String script) { + return load(new StrReader(script), script); + } + /** Load the content form a reader as a text file. Must be lua source. * The source is converted to UTF-8, so any characters appearing in quoted literals * above the range 128 will be converted into multiple bytes. */