Page 1 of 1

Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 6:14 am
by dx876234
Is there a way to run an interactive Lua interpreter in the Micromacro window, i.e. just like when we start Lua with no arguments but with the full Micromacro functionality available?

Best regard
DX

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 8:10 am
by rock5
You mean like the bots commandline.xml script? I have a version that doesn't require Runes of magic to be running if you are interested.

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 12:04 pm
by Administrator
You can also use the exec command at the script prompt to run single statements. The only thing is that you shouldn't use double quotes ("") or it will confuse the parser.

example:

Code: Select all

Script> exec print('hello world');

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 1:55 pm
by dx876234
Both hints are good :) I'd like a copy of your script Rock.

Thx,
Dx

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 3:45 pm
by dx876234
Building new scripts (not rombot) and probing processes I always wanted an interactive environment to test in.

To get a 'normal' Lua interpreter to work in with full functionality of Micromacro I used the lua.c file from Lua 5.2 distribution and built it as a .dll for loading into Micromacro.

This leaves me with a session like:
MicroMacro v1.04.167
SolarStrike Software
http://www.solarstrike.net
Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> lua
Opening lua.lua...
Starting script execution - Press CTRL+C to exit.
Press CTRL+L to cancel execution and load a new script.
-------------------------------------------------------
Press the (F6) key to stop/pause the script.
You can resume with the (F5) key.
Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
>
I have attached the files used, please re-compile to build your own and don't rely on my binaries.
  • I use MinGW32 for compilation.
  • The lua.lua script I put in micromacro/scripts
  • The cmd.dll I put in micromacro/lib/mods/cmd.dll
Best Regards
DX

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 4:03 pm
by Administrator
I've added this as built-in with MM2 now and it will be included with future releases. It works much the same way. Just use the 'exec' command without any parameters to enter interactive mode, and 'exit' to quit:

Code: Select all

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> exec
> print("hello world!");
hello world!
> abc = "test";
> print(abc);
test
> exit


Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script>
Thanks for your input.

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 4:04 pm
by dx876234
Great :)

-dx

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 4:31 pm
by rock5
dx876234 wrote:Both hints are good :) I'd like a copy of your script Rock.

Thx,
Dx
Cl.lua
(580 Bytes) Downloaded 386 times
Just place it in "micromacro/scripts" then type "cl" in micromacro.
Administrator wrote:I've added this as built-in with MM2 now and it will be included with future releases. It works much the same way. Just use the 'exec' command without any parameters to enter interactive mode, and 'exit' to quit:
That sounds excellent.

Re: Interactive Lua (perhaps a stupid question)

Posted: Fri Jan 09, 2015 4:42 pm
by dx876234
Btw, by adding a waypoint as below you will also get a Lua interpreter with full Rom bot functionality and can manually control your client.

-DX

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>
		<![CDATA[
			cmd = require "cmd"
			cmd.LuaInterpreter()
		]]>
	</onLoad>
</waypoints>