I've got the basic communications figured out (I think... not able to test it yet) but I need to start out by figuring out how I can have a script detect when I press the keypad # 1, #2, #3, etc..., just like the createpath.lua file does.
Because that file does it, I thought I'd use it as a template to get started but when I try to start it, I get the following error: "11:52pm - scripts/rom/classes/pawn.lua:491: attempt to call global 'GetIdName' (a nil value)"
I'm not sure what function I'm calling that's trying to use that, or if it's possible to do the things in this lua file that I want to do. Here's what I have so far (I copied the createpath.lua file and tried to edit it as best I could):
Code: Select all
include("database.lua");
include("addresses.lua");
include("classes/player.lua");
include("classes/camera.lua");
include("classes/waypoint.lua");
include("classes/waypointlist.lua");
include("classes/waypointlist_wander.lua");
include("classes/node.lua");
include("settings.lua");
include("functions.lua");
include("macros.lua");
print("load settings");
settings.load();
database.load();
-- ********************************************************************
-- Change the parameters below to your need *
-- ********************************************************************
-- if you want to create waypoint files with special waypoint types
-- like type=TRAVEL, than you can change the global variables
-- below to your need, see the following example
-- p_wp_gtype = " type=\"TRAVEL\""; -- global type for whole file
-- p_wp_type = " type=\"TRAVEL\""; -- type for normal waypoints
-- p_hp_type = " type=\"TRAVEL\""; -- type for harvest waypoints
p_wp_gtype = ""; -- global type for whole file: e.g. TRAVEL
p_wp_type = ""; -- type for normal waypoints
p_hp_type = ""; -- type for harvest waypoints
p_harvest_command = "player:harvest();";
p_merchant_command = "player:merchant(\"%s\");";
p_targetNPC_command = "player:target_NPC(\"%s\");";
p_choiceOption_command = "sendMacro(\"ChoiceOption(%d);\");";
p_mouseClickL_command = "player:mouseclickL(%d, %d, %d, %d);";
-- ********************************************************************
-- End of Change parameter changes *
-- ********************************************************************
setStartKey(settings.hotkeys.START_BOT.key);
setStopKey(settings.hotkeys.STOP_BOT.key);
mntKey = key.VK_NUMPAD1; -- tell bots to mount
folKey = key.VK_NUMPAD2; -- tell bots to follow
aqKey = key.VK_NUMPAD3; -- tell bots to Accept Quest
cqKey = key.VK_NUMPAD4; -- tell bots to Complete Quest
-- read arguments / forced profile perhaps
local forcedProfile = nil;
for i = 2,#args do
local foundpos = string.find(args[i], ":", 1, true);
if( foundpos ) then
local var = string.sub(args[i], 1, foundpos-1);
local val = string.sub(args[i], foundpos+1);
if( var == "profile" ) then
forcedProfile = val;
else
-- invalid option
local msg = sprintf(language[61], args[i]);
error(msg, 0 );
end
end
-- check the options
if(not foundpos and args[i] ~= "update" ) then
local msg = sprintf(language[61], args[i]);
error(msg, 0 );
end;
end
local wpList = {};
print("loading pointers");
local playerPtr = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
player = CPlayer(playerPtr);
player:update();
-- convert player name to profile name and check if profile exist
local load_profile_name; -- name of profile to load
if( forcedProfile ) then
load_profile_name = convertProfileName(forcedProfile);
else
load_profile_name = convertProfileName(player.Name);
end
attach(getWin());
settings.loadProfile(load_profile_name);
--======================= function to run when accepting a quest===============================--
function waitForQuestAccept()
sendpartychat("getquest");
eventParty();
repeat
yrest(100);
until msg == "ready"
yrest(1000);
eventParty("stop");
RoMScript("SendSystemChat('Safe to get the quest now.');");
EventMonitorStart("newquestid", "ADDNEW_QUESTBOOK");
local QuestStarted = false;
repeat
yrest(500); -- check every half second
local questid = EventMonitorCheck("newquestid", "1");
if questid then
quest = questlog:getQuest(questid);
QuestStarted = true;
acceptquest = quest.Name; -- now I have the quest name of the quest I just accepted.
break
end;
until QuestStarted == true
sendpartychat(acceptquest);
EventMonitorStop("newquestid");
end
function main()
print("starting main function");
local running = true;
while(running) do
local hf_x, hf_y, hf_wide, hf_high = windowRect( getWin());
cprintf(cli.turquoise, language[42], hf_wide, hf_high, hf_x, hf_y ); -- RoM windows size
cprintf(cli.green, language[501]); -- RoM waypoint creator\n
printf("Mount up " .. getKeyName(mntKey) .. " -- tells bot to get mounted");
printf("Follow " .. getKeyName(folKey) .. " -- tells bot to follow leader");
printf("Accept Quest " .. getKeyName(aqKey) .. " -- tells bot to accept quest");
printf("Complete Quest " .. getKeyName(cqKey) .. " -- tells bot to Complete Quest");
attach(getWin())
local hf_key_pressed, hf_key;
while(true) do
hf_key_pressed = false;
if( keyPressed(mntKey) ) then -- mount key pressed
hf_key_pressed = true;
hf_key = "MNT";
end;
if( keyPressed(folKey) ) then -- follow key pressed
hf_key_pressed = true;
hf_key = "FOL";
end;
if( keyPressed(aqKey) ) then -- Accept Quest key pressed
hf_key_pressed = true;
hf_key = "AQ";
end;
if( keyPressed(cqKey ) ) then -- Complete Quest key pressed
hf_key_pressed = true;
hf_key = "CQ";
end;
if( hf_key_pressed == false and -- key released, do the work
hf_key ) then -- and key not empty
player:update();
if( hf_key == "MNT" ) then -- mount command
print("pressed key 1 to mount");
sendpartychat("mount");
if not player.Mounted then
if inventory:itemTotalCount(207204) >= 15 then
if (useGoodie) then
useGoodie("riding");
end;
end;
player:mount();
end;
elseif( hf_key == "FOL") then -- follow command
print("pressed key 2 to follow");
sendpartychat("follow");
elseif( hf_key == "AQ" ) then
RoMScript("SendWarningMsg('Wait for acknowledgement before accepting quest.');");
print("pressed key 3 to accept quest"); -- Accept quest command
waitForQuestAccept();
elseif( hf_key == "CQ" ) then -- Complete quest command
end;
hf_key = nil; -- clear last pressed key
end;
yrest(10);
end; -- End of: while(true)
end; -- End of: while(running)
end
startMacro(main, true);