This script automatically starts a client, clicks the account, selects the character and enters the game. Then it starts the bot and passes any left over arguments to the bot. This script is only required if you want to initially start the game client with a script.
Installation:
- Put login.lua in your 'rom' folder.
- Put shortcut links to your game clients in your 'rom' folder, preferably renamed to something short, eg. rom4u. If you only use one client then name the link "rom" and it will be used by default. No need to use the "client" argument. If you want to change the default then change the variable at the top of the userfunction_login.lua file.
Requirements:
- A Version of my 'fastlogin' addon with the 65 or 108 login buttons.
- The userfunction_login.lua installed in the userfunction folder.
FOR /F "tokens=1 delims=" %%A in ('cd') do SET folder=%%A
START ../../micromacro.exe "%folder%/login.lua" acc:45 char:1 client:rom4u path:path1
START ../../micromacro.exe "%folder%/login.lua" acc:46 char:1 client:rom4u path:path2
START ../../micromacro.exe "%folder%/login.lua" acc:47 char:1 client:rom4u path:path3
Limitations:
As of version 3 there are no limitations. Clients can be started at the same time. The login script keeps track of which bot has the active window.
Features:
- It makes sure it connects to the just-started client. It wont get mixed up if other clients are already open.
- Because __WIN and __PROC are already set, when the bot starts, it doesn't need the 'character' argument to know which client to connect to.
- The mouse clicks are accurate regardless of the window shape or size.
- The shortcuts don't need the NoCheckVersion set. The script handles it.
- It avoids conflicts when multiple logins need the clients active at the same time, so you can start them at the same time.
userfunction_login.lua
This file has all the actual login functions. This is the only file required to make use of the new restart options available in the LoginNextChar userfunction.
Installation:
- Put shortcut links to your game clients in your 'rom' folder, preferably renamed to something short, eg. rom4u. If you only use one client then name the link "rom" and it will be used by default. No need to use the "client" argument. If you want to change the default then change the variable at the top of the file. - New option: I've added support for a server/link list. It will still default to 'rom' link so if you only use the one link you don't need to use the server/link list. But if you do use more than one link, you can include a file in the same folder as userfunction_login.lua, called 'ServerLinkList.lua', for the other links besides 'rom'. So you can still avoid having to use the client argument. Eg. mine looks like this
- The userfunction.login.lua goes in the "userfunctions" folder.
Userfunction "login" syntax:
Changed in version 3 to be more user friendly.
login(charnum, accountnum, "shortcutname")
This userfunction just starts the client. It does not use other bot arguments such as 'path' and 'profile', you can always follow it with a "loadPaths" and "loadProfile". The order of the arguments does matter.
Version 3.5 - Saves current server and character to help with recovering from crashes. - Added ServerLinkList.lua support - Added a few improvements to make starting multiple clients at once. - killClient now makes sure the client dies.
Nice rock
It works fine, I just had to copy the micromacro folder onto the desktop because it errors if the micromacro folder is in a sub folder.
For which situations can this be used? Is it possible the start the client again if the game crashes?
I wanted to do something more complete that could do that but there was no way to match up (well no easy way) to match up account and player names with the account number and character number. If the game crashed you would only potentially know the character name and account name. So after the client crashes you couldn't get the account number and character number.
If you don't change character and just want to reload the same character you might be able to do it. You would have to override the crash handler.
I'll do a bit of testing and get back to you.
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.
This is proving to be too diffcult to do. I can make it restart the client but it immediately has a memory read failure. I'm updating __WIN and __PROC but for some reason local proc variables get reset to nil. I can't figure it out. Maybe the atError function can't be recovered from.
Sorry.
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.
I'm using something similar, to restart the client u can catch the error in rombot, check if client is running and call Rock's login script. Since your in MM u can get hold of account/character I guess, Im using fastlogin which keeps track of it.
-- PSEUDO CODE...
atError(autologErrorCallback)
function autologErrorCallback(script, line, message)
yrest(secondsToTimer(30))
if( not windowValid(getAttachedHwnd()) ) then
printf("No client attached, restarting client!\n")
-- Fill in with correct account/character/client/script
os.exec(rom/login acc:48 char:2 client:rom4u path:cot_tele")
os.exit()
end
end
But there is one cavat, rombot doesnt always trigger an error until the client window closes.
To make sure client closes on crashes I use aseparate lua session running the following to clean up crashed clients:
-- Keep watch for the RoM client Crash window
-- and terminate when detected
repeat
local win = findWindow("Crash Report", "#32770")
if( win > 0 ) then
printf("Found window [%s/%s]\n", getWindowName(win), getWindowClassName(win))
local pid = findProcessByWindow(win)
os.execute("TASKKILL /PID " .. pid .. " /F")
end
yrest(secondsToTimer(5))
until false
The separate session to clean up clients is a good idea. That was one of the problems I was having, the bot either didn't detect the crash or hung in a loop somewhere.
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.
Not at the moment, no. I'm doing other things now and don't have the time for it. The basics are there above so maybe someone else will figure it out. I might post the version of login I made that has the login function in a function that could be called from the error event. That might make it easier for someone to get it to work.
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.
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
Made sure to follow instructions and all files are in the right place.
I didn't say the login function would work, how ever you tried to use it. I did say above that I couldn't get rom to recover from a crashed client. I supplied version 2 so tinkerers would have another way of calling the function and maybe get it working themselves. Only the initial command works as it is at the moment.
It's also possible that you are trying to use the first command but have used an incorrect argument. In that case, just double check your arguments.
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.
local currAcc = RoMScript("LogID")
local currChar = RoMScript("CHARACTER_SELECT.selectedIndex")
local dirPath = getExecutionPath()
local currPath = __WPL.FileName
local Clientlink = false -- specify you client shortcut links name if it not contains *client*
if( Clientlink == false ) then
local romdir = getDirectory(dirPath)
for i,v in pairs(romdir) do
local match = string.match(string.lower(v), "client(.*)%.lnk")
if( match ~= nil ) then
Clientlink = v
end
end
end;
cprintf(cli.white, "Current Acc: %s, Char: %s, Path: %s, dirPath: %s, Client: %s\n", currAcc, currChar, currPath, dirPath, Clientlink)
function AutoRestartAfterCrash()
yrest(secondsToTimer(30))
if( not windowValid(getAttachedHwnd()) ) then
-- Crash Log
local filename = ""..dirPath.."/logs/CrashLog.log";
local file, err = io.open(filename, "a+");
if file then
file:write("Account: "..currAcc.." \tName: " ..string.format("%-10s",player.Name ).." \tDate: "..os.date().." \tPath: "..currPath.." \n")
file:close();
end
-- Restart client and Bot
os.execute("START "..dirPath.."/../../micromacro.exe "..dirPath.."/login acc:"..currAcc.." char:"..currChar.." client:"..Clientlink.." path:"..currPath.."")
os.exit()
end
end;
if( Clientlink ) then
atError(AutoRestartAfterCrash)
end;
Last edited by Bot_romka on Wed Feb 27, 2013 12:54 pm, edited 9 times in total.
I try this.
Code from userfunction_login.lua cant be used because after restart client Bot stops with an error message. Need to completely restart client and Bot with waypoint. Or do something to disable the error messages after restart cient.