Interactive Lua (perhaps a stupid question)

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Interactive Lua (perhaps a stupid question)

#1 Post by dx876234 » Fri Jan 09, 2015 6:14 am

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Interactive Lua (perhaps a stupid question)

#2 Post by rock5 » Fri Jan 09, 2015 8:10 am

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Interactive Lua (perhaps a stupid question)

#3 Post by Administrator » Fri Jan 09, 2015 12:04 pm

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');

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Interactive Lua (perhaps a stupid question)

#4 Post by dx876234 » Fri Jan 09, 2015 1:55 pm

Both hints are good :) I'd like a copy of your script Rock.

Thx,
Dx

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Interactive Lua (perhaps a stupid question)

#5 Post by dx876234 » Fri Jan 09, 2015 3:45 pm

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
Attachments
commandline.zip
Contains the source and .dll of command line interface, version 0.1
(10.42 KiB) Downloaded 350 times

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Interactive Lua (perhaps a stupid question)

#6 Post by Administrator » Fri Jan 09, 2015 4:03 pm

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.

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Interactive Lua (perhaps a stupid question)

#7 Post by dx876234 » Fri Jan 09, 2015 4:04 pm

Great :)

-dx

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Interactive Lua (perhaps a stupid question)

#8 Post by rock5 » Fri Jan 09, 2015 4:31 pm

dx876234 wrote:Both hints are good :) I'd like a copy of your script Rock.

Thx,
Dx
Cl.lua
(580 Bytes) Downloaded 375 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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Interactive Lua (perhaps a stupid question)

#9 Post by dx876234 » Fri Jan 09, 2015 4:42 pm

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>

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests