seperating scripts into different files.
Forum rules
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
seperating scripts into different files.
I've written up a shaiya bot, and I've found that the core of it shouldn't rarely needs changing, but the part that has user configurables, and the class custom functions do change.
Is their any way to seperate the code into different files? I'd like to have the main bot script in one file, the class specific functions in another, and finally the character configurables in another. Could this be done, or would it require a hard-code change, to MicroMacro?
Is their any way to seperate the code into different files? I'd like to have the main bot script in one file, the class specific functions in another, and finally the character configurables in another. Could this be done, or would it require a hard-code change, to MicroMacro?
- 3cmSailorfuku
- Posts: 354
- Joined: Mon Jan 21, 2008 6:25 pm
Re: seperating scripts into different files.
You could include a second LUA eg. config.lua etc, or read it from a text file. Though im not sure how wide micromacro supports LUA, but it expect everything to work. But having the config in the header of the file isn't that bad, or is it?zerosignal wrote:I've written up a shaiya bot, and I've found that the core of it shouldn't rarely needs changing, but the part that has user configurables, and the class custom functions do change.
Is their any way to seperate the code into different files? I'd like to have the main bot script in one file, the class specific functions in another, and finally the character configurables in another. Could this be done, or would it require a hard-code change, to MicroMacro?
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: seperating scripts into different files.
Correct. This is a standard feature of Lua. It has not been removed or limited from use in MicroMacro. The function is dofile(filename). If no argument is given, then it will read from standard input (typically, you do not want this -- that means it reads whatever you type in as a command). You should make note that the filename is based on MicroMacro's location; not the location of the script it is called from (basically, just remember to prelude the filename with "scripts/").
Example:
Example:
Code: Select all
dofile("scripts/config.lua");
Re: seperating scripts into different files.
Thanks heaps, the script file was getting kinda large, and heavy to maintain. *Bounces off, to fix up his script*
Re: seperating scripts into different files.
Nice topic ! So if you can separate config file like i always do using AutoIt, Can that config file be edited under micromacro using a GUI controls to edit or its not yet supported? Actually im starting to shift from using AutoIt to MicroMacro
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: seperating scripts into different files.
What do you mean? There is no GUI for MicroMacro, no. Not yet, anyways. You can use LuaEdit as a nice development environment for your lua scripts, though.
- 3cmSailorfuku
- Posts: 354
- Joined: Mon Jan 21, 2008 6:25 pm
Re: seperating scripts into different files.
Make a gui for your config via VB, C++/C or even AutoIt. And why shifting from AutoIt to MicroMacro?spaghett1 wrote:Nice topic ! So if you can separate config file like i always do using AutoIt, Can that config file be edited under micromacro using a GUI controls to edit or its not yet supported? Actually im starting to shift from using AutoIt to MicroMacro
Re: seperating scripts into different files.
Comparing AutoIt and micromacro on reading memory value especially for Health or HP, micromacro and Autoit responded very fast on the first read when HP goes lower than the set point, but on the second read Autoit responded veeery slow and character sometimes almost out of HP before it responded because of a very long long process or script shes reads to get memory new value , unlike micromacro it responded in a blink. Actually right now i use AutoIt for setting/editing config file and i plan use autoit too to launch micromacro and set what Lua file to load.
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: seperating scripts into different files.
Ooh, yes, I see what you mean by GUI now. Just something for changing the config variables, right? Yeah, should be pretty simple to make something like that which would dump out a lua config script. Just have it do something like this:
However, this gives me an idea. I think it might be possible to create GUIs out of MicroMacro scripts with a bit of work, and adding in an additional (lite) library.
And as a final note, most people don't realize this but you can call MicroMacro with it's first (and only -- at the time being) argument being the filename of the script, and it will automatically open that script for you. So if you are trying to open it from AutoIT, you can use something like Execute("./micromacro/micromacro.exe ./scripts/myscript.lua"); The paths in my example might be a little bit off... It's best to use the full path for the lua script to run. This also means that if you right click on one of the lua scripts, and go to Open With, you can open it with MicroMacro and it'll run.
Code: Select all
// untested, probably won't run out of the box.
void save_config(std::string filename, int dumpvars, char **varnames, char **varvalues)
{
std::string output = "";
printf("-- Auto-generated config file.\n\
"-- Do not edit by hand.\n");
for(int i = 0; i < dumpvars; i++)
{
printf("%s = %s;\n", varnames[i], varvalues[i]);
}
std::ofstream:: outfile;
outfile.open(filename);
if( outfile.is_open() )
{
outfile << output;
outfile.close();
}
}
And as a final note, most people don't realize this but you can call MicroMacro with it's first (and only -- at the time being) argument being the filename of the script, and it will automatically open that script for you. So if you are trying to open it from AutoIT, you can use something like Execute("./micromacro/micromacro.exe ./scripts/myscript.lua"); The paths in my example might be a little bit off... It's best to use the full path for the lua script to run. This also means that if you right click on one of the lua scripts, and go to Open With, you can open it with MicroMacro and it'll run.
Re: seperating scripts into different files.
Also under Script folder i make another folder and named it Fiesta and placed all lua files only for Fiesta, to call or load fiesta.lua under micromacro is used "Fiesta/Fiesta.lua" . Do this to organize all lua files under script folder when u began on separating scripts into different files.
Who is online
Users browsing this forum: No registered users and 0 guests