Page 1 of 1
Error elves daily
Posted: Mon Sep 16, 2013 12:52 pm
by sitw97
Hello:)
After starting waypoint gives me this error what can I do? I do not know
Did not find any crashed game clients.
7:47pm - ...p/rombot/rombot/scripts/rom/classes/waypointlist.lua:83: Failed to c
ompile and run Lua code for waypointlist onLoad event.
Re: Error elves daily
Posted: Mon Sep 16, 2013 1:35 pm
by rock5
It means there is an error in the onload section of your waypoint file. You'll need to post it if you want us to help you find the error.
Re: Error elves daily
Posted: Mon Sep 16, 2013 2:02 pm
by sitw97
Code: Select all
WPT_FORWARD = 1;
WPT_BACKWARD = 2;
CWaypointList = class(
function(self)
self.Waypoints = {};
self.CurrentWaypoint = 1;
self.LastWaypoint = 1;
self.Direction = WPT_FORWARD;
self.OrigX = player.X;
self.OrigZ = player.Z;
self.Radius = 500;
self.FileName = nil;
self.Mode = "waypoints";
self.KillZone = {};
self.ExcludeZones = {}
self.Type = 0; -- UNSET
self.ForcedType = 0; -- Wp type to overwrite current type, can be used by users in WP coding
end
);
function CWaypointList:load(filename)
local root = xml.open(filename);
if( not root ) then
error(sprintf("Failed to load waypoints from \'%s\'", filename), 0);
end
local elements = root:getElements();
local type = root:getAttribute("type");
if( type ) then
if( type == "TRAVEL" ) then
self.Type = WPT_TRAVEL;
elseif( type == "NORMAL" ) then
self.Type = WPT_NORMAL;
elseif( type == "RUN" ) then
self.Type = WPT_RUN;
else
self.Type = WPT_NORMAL;
end
else
self.Type = WPT_NORMAL;
end
self.FileName = string.match(filename,"waypoints/(.*)");
self.Waypoints = {}; -- Delete current waypoints.
self.ForcedType = 0; -- delete forced waypoint type
local onLoadEvent = nil;
for i,v in pairs(elements) do
local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
local type = v:getAttribute("type");
local action = v:getValue();
local name = v:getName() or "";
local tag = v:getAttribute("tag") or "";
if( string.lower(name) == "waypoint" ) then
local tmp = CWaypoint(x, z, y);
if( action ) then tmp.Action = action; end;
if( type ) then
if( type == "TRAVEL" ) then
tmp.Type = WPT_TRAVEL;
elseif( type == "RUN" ) then
tmp.Type = WPT_RUN;
elseif( type == "NORMAL" ) then
tmp.Type = WPT_NORMAL;
else
-- Undefined type, assume WPT_NORMAL
tmp.Type = WPT_NORMAL;
end
else
-- No type set, assume Type from header tag
tmp.Type = self.Type;
end
if( tag ) then tmp.Tag = string.lower(tag); end;
table.insert(self.Waypoints, tmp);
elseif( string.lower(name) == "onload" ) then
if( string.len(action) > 0 and string.find(action, "%w") ) then
self.onLoadEvent = loadstring(action);
assert(self.onLoadEvent, sprintf(language[152]));
if( _G.type(self.onLoadEvent) ~= "function" ) then
self.onLoadEvent = nil;
end;
end
end
end
self.Mode = "waypoints"
if #self.Waypoints > 0 then
self:setWaypointIndex(self:getNearestWaypoint(player.X, player.Z, player.Y));
self.LastWaypoint = self.CurrentWaypoint -1
if self.LastWaypoint < 1 then self.LastWaypoint = #self.Waypoints end
end
if( self.onLoadEvent ) then
self.DoOnload = true
end
end
function CWaypointList:getFileName()
if( self.FileName == nil ) then
return "<NONE>";
else
return self.FileName;
end
end
function CWaypointList:setMode(mode)
self.Mode = mode;
end
function CWaypointList:setForcedWaypointType(_type)
if( _type == nil or _type == "" or _type == 0 ) then
self.ForcedType = 0;
cprintf(cli.green, "Forced waypoint type cleared.\n" );
return;
end;
if( _type == "NORMAL" or _type == WPT_NORMAL ) then
self.ForcedType = WPT_NORMAL;
elseif( _type == "TRAVEL" or _type == WPT_TRAVEL) then
self.ForcedType = WPT_TRAVEL;
elseif( _type == "RUN" or _type == WPT_RUN) then
self.ForcedType = WPT_RUN;
else
cprintf(cli.yellow, "You try to force an unknown waypoint type \'%s\'. Please check.\n", _type);
error("Bot finished due to error above.", 0);
end
player.Current_waypoint_type = self.ForcedType
cprintf(cli.green, "Forced waypoint type \'%s\' set by user.\n", _type );
end
function CWaypointList:getMode()
return self.Mode;
end
function CWaypointList:getRadius()
return self.Radius;
end
function CWaypointList:advance()
self.LastWaypoint = self.CurrentWaypoint
if( self.Direction == WPT_FORWARD ) then
self.CurrentWaypoint = self.CurrentWaypoint + 1;
if( self.CurrentWaypoint > #self.Waypoints ) then
self.CurrentWaypoint = 1;
end
else
self.CurrentWaypoint = self.CurrentWaypoint - 1;
if( self.CurrentWaypoint < 1 ) then
self.CurrentWaypoint = #self.Waypoints;
end
end
end
function CWaypointList:backward()
self.LastWaypoint = self.CurrentWaypoint
if( self.Direction == WPT_FORWARD ) then
self.CurrentWaypoint = self.CurrentWaypoint - 1;
if( self.CurrentWaypoint < 1 ) then
self.CurrentWaypoint = #self.Waypoints;
end
else
self.CurrentWaypoint = self.CurrentWaypoint + 1;
if( self.CurrentWaypoint > #self.Waypoints ) then
self.CurrentWaypoint = 1;
end
end
end
function CWaypointList:getNextWaypoint(_num)
if( not _num ) then _num = 0; end;
local hf_wpnum;
if( self.Direction == WPT_FORWARD ) then
hf_wpnum = self.CurrentWaypoint + _num;
else
hf_wpnum = self.CurrentWaypoint - _num;
end
if( hf_wpnum > #self.Waypoints ) then
hf_wpnum = hf_wpnum - #self.Waypoints;
elseif( hf_wpnum < 1 ) then
hf_wpnum = hf_wpnum + #self.Waypoints;
end
local tmp = CWaypoint(self.Waypoints[hf_wpnum]);
tmp.wpnum = hf_wpnum;
-- check if forced type is set, that could be done by users
-- within lua coding in the waypoint tags
if(self.ForcedType ~= 0 ) then
tmp.Type = self.ForcedType;
end
if( settings.profile.options.WAYPOINT_DEVIATION < 2 ) then
return tmp;
end
local halfdev = settings.profile.options.WAYPOINT_DEVIATION/2;
tmp.X = tmp.X + math.random(halfdev) - halfdev;
tmp.Z = tmp.Z + math.random(halfdev) - halfdev;
return tmp;
end
-- Sets the "direction" (forward/backward) to travel
function CWaypointList:setDirection(wpt)
-- Ignore invalid types
if( wpt ~= WPT_FORWARD and wpt ~= WPT_BACKWARD ) then
return;
end;
if( wpt ~= self.Direction ) then
self.Direction = wpt
if( wpt == WPT_BACKWARD ) then
self.CurrentWaypoint = self.CurrentWaypoint - 2;
if( self.CurrentWaypoint < 1 ) then
self.CurrentWaypoint = #self.Waypoints + self.CurrentWaypoint;
end
else
self.CurrentWaypoint = self.CurrentWaypoint + 2;
if( self.CurrentWaypoint > #self.Waypoints ) then
self.CurrentWaypoint = self.CurrentWaypoint - #self.Waypoints;
end
end;
end
end
-- Reverse your current direction
function CWaypointList:reverse()
if( self.Direction == WPT_FORWARD ) then
self:setDirection(WPT_BACKWARD);
else
self:setDirection(WPT_FORWARD);
end;
end
-- Sets the next waypoint to move to to whatever
-- index you want.
function CWaypointList:setWaypointIndex(index)
if( type(index) ~= "number" ) then
error("setWaypointIndex() requires a number. Received " .. type(index), 2);
end
if( index < 1 ) then index = 1; end;
if( index > #self.Waypoints ) then index = #self.Waypoints; end;
self.LastWaypoint = self.CurrentWaypoint
self.CurrentWaypoint = index;
end
-- Returns an index to the waypoint closest to the given point.
function CWaypointList:getNearestWaypoint(_x, _z, _y)
local closest = 1;
for i,v in pairs(self.Waypoints) do
local oldClosestWp = self.Waypoints[closest];
if( distance(_x, _z, _y, v.X, v.Z, v.Y) < distance(_x, _z, _y, oldClosestWp.X, oldClosestWp.Z, oldClosestWp.Y) ) then
closest = i;
end
end
return closest;
end
function CWaypointList:findWaypointTag(tag)
tag = string.lower(tag);
for i,v in pairs(self.Waypoints) do
if( v.Tag == tag ) then
return i;
end
end
return 0;
end
function CWaypointList:setKillZone(_zone)
-- Reset Kill Zone
if _zone == nil or _zone == "" or (type(_zone) == "table" and #_zone == 0) then
self:clearKillZone()
return
end
-- Check argument
if type(_zone) == "table" then
-- check table values
for k,v in pairs(_zone) do
if (not v.X) or (not v.Z) then
error("SetKillZone: Invalid table.",0)
end
end
elseif type(_zone) == "string" then
if not string.find(_zone,".xml", 1, true) then
_zone = _zone .. ".xml"
end
local filename = getExecutionPath() .. "/waypoints/" .. _zone
if not fileExists(filename) then
filename = getExecutionPath() .. "/../romglobal/waypoints/" .. _zone
end
local file, err = io.open(filename, "r");
if file then
file:close();
local tmpWPL = CWaypointList();
tmpWPL:load(filename);
_zone = table.copy(tmpWPL.Waypoints)
else
error("SetKillZone: invalid file name.",0)
end
else
error("SetKillZone: Invalid argument.",0)
end
-- Set kill zone
self:clearKillZone()
for i = 1, #_zone do
self.KillZone[i] = {X=_zone[i].X, Z=_zone[i].Z}
end
end
function CWaypointList:clearKillZone()
self.KillZone = {}
end
function CWaypointList:addExcludeZone(_zone,_zonename)
-- Check argument
if type(_zone) == "table" then
-- check table values
for k,v in pairs(_zone) do
if (not v.X) or (not v.Z) then
error("AddExcludeZone: Invalid table.",0)
end
end
elseif type(_zone) == "string" then
if not string.find(_zone,".xml", 1, true) then
_zone = _zone .. ".xml"
end
local filename = getExecutionPath() .. "/waypoints/" .. _zone
if not fileExists(filename) then
filename = getExecutionPath() .. "/../romglobal/waypoints/" .. _zone
end
local file, err = io.open(filename, "r");
if file then
file:close();
local tmpWPL = CWaypointList();
tmpWPL:load(filename);
_zone = table.copy(tmpWPL.Waypoints)
else
error("AddExcludeZone: invalid file name.",0)
end
else
error("AddExcludeZone: Invalid argument.",0)
end
local tmp = {}
for i = 1, #_zone do
tmp[i] = {X=_zone[i].X, Z=_zone[i].Z}
end
-- Add Exclude Zone
if _zonename then
self.ExcludeZones[_zonename] = table.copy(tmp)
else
table.insert(self.ExcludeZones,tmp)
end
end
function CWaypointList:deleteExcludeZone(_zonename)
for name,zone in pairs(self.ExcludeZones) do
if name == _zonename then
self.ExcludeZones[name] = nil
return
end
end
end
function CWaypointList:clearExcludeZones()
self.ExcludeZones = {}
end
-- After a pullback, use this function to find the waypoint you were pulled before.
function CWaypointList:findPulledBeforeWaypoint()
local WPCount = #self.Waypoints
-- If 1 or 2 then it can't change.
if WPCount < 3 then
return self.CurentWaypoint
end
local DistLimit = 1000 -- Limits distance to look back from current waypoint.
local wptotest = self.CurrentWaypoint
local bestwaypointindex = self.CurrentWaypoint -- Best waypoint index so far
local bestdist -- Best distance to path so far
local disttotal = 0 -- Tally of distance so far
repeat
local towp = self.Waypoints[wptotest]
local fromwp = self.Waypoints[wptotest-1]
if fromwp == nil then fromwp = self.Waypoints[#self.Waypoints] end
-- First find segment point
local segpoint = getNearestSegmentPoint(player.X, player.Z, towp.X, towp.Z, fromwp.X, fromwp.Z)
-- if segpoint = towp or fromwp then it isn't between the wps
if not (segpoint.X == towp.X and segpoint.Z == towp.Z) and not (segpoint.X == fromwp.X and segpoint.Z == fromwp.Z) then
-- Get player distance to segment
local tmpdist = distance(player, segpoint)
-- See if it's a better match
if bestdist == nil or tmpdist < bestdist then -- Compare
bestdist = tmpdist
bestwaypointindex = wptotest
end
end
-- Check how far we have come from curentwaypoint
disttotal = disttotal + distance(towp, fromwp)
if disttotal > DistLimit then -- Exceeded limit. Return best score
return bestwaypointindex
end
wptotest = wptotest - 1
if wptotest < 1 then wptotest = #self.Waypoints end
until wptotest == self.CurrentWaypoint -- Gone through all points
return bestwaypointindex
end
Re: Error elves daily
Posted: Mon Sep 16, 2013 2:04 pm
by sitw97
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
-- Elf daily script - V1.2 - written by Jandrana
-- thanks to rock5 for help regarding relog
-- relog features requires fastLogin and userfunction_LoginNextChar.lua
-- changes:
-- *if char is not in Valley of Preparation, try to use transport
-- *if inventory is full, you cannot complete the quest - try to delete
-- newbie egg pet
function relog()
SetCharList({
-- enter account number and char numbers that you like to run this script
{account=1 , chars= {1,2}},
{account=2 , chars= {1}},
{account=3 , chars= {1}},
{account=4 , chars= {1}},
{account=5 , chars= {1}},
{account=6 , chars= {1}},
{account=7 , chars= {1}},
{account=8 , chars= {1}},
{account=9 , chars= {1}},
{account=10, chars= {1}},
{account=11, chars= {1}},
{account=12, chars= {1}},
}account=13, chars= {1}},
}account=14, chars= {1}},
}account=15, chars= {1}}.
}account=16, chars= {1}},
}account=17, chars= {1}},
}account=18, chars= {1}},
}account=19, chars= {1}},
LoginNextChar()
loadProfile()
loadPaths("ElfDaily");
end
questEndNpcID1 = 112794
questName1 = "Helping Them Grow"
</onLoad>
<!-- # 1 --><waypoint x="31847" z="4592" tag ="Main">
local queststate = getQuestStatus(questName1);
if queststate == "complete" then
player:target_NPC(questEndNpcID1);
CompleteQuestByName(questName1);
yrest(300);
end
local dqCount, dqPerDay = RoMScript("Daily_count()");
if dqPerDay == dqCount then
relog()
else
player:target_NPC(questEndNpcID1);
AcceptQuestByName(questName1,questEndNpcID1);
yrest(300);
end
</waypoint>
<!-- # 3 --><waypoint x="31860" z="4646" y="9"> </waypoint>
<!-- # 2 --><waypoint x="31742" z="5070" y="-11"> </waypoint>
<!-- # 1 --><waypoint x="31416" z="5715" y="-33" tag = "Item1">
queststate = getQuestStatus(questName1)
if queststate == "incomplete" then
player:target_Object(112976,300);
yrest(2500);
__WPL:setWaypointIndex(__WPL:findWaypointTag("Item1"));
end
</waypoint>
<!-- # 1 --><waypoint x="31416" z="5715" y="-33"> </waypoint>
<!-- # 2 --><waypoint x="31742" z="5070" y="-11"> </waypoint>
<!-- # 3 --><waypoint x="31860" z="4646" y="9"> </waypoint>
<!-- # 4 --><waypoint x="31847" z="4583" y="9"> </waypoint>
</waypoints>
Re: Error elves daily
Posted: Mon Sep 16, 2013 2:34 pm
by rock5
Accounts 13 onwards, the initial brackets are back to front. Also you didn't close the initial brackets of the function. Try this.
Code: Select all
<onLoad>
-- Elf daily script - V1.2 - written by Jandrana
-- thanks to rock5 for help regarding relog
-- relog features requires fastLogin and userfunction_LoginNextChar.lua
-- changes:
-- *if char is not in Valley of Preparation, try to use transport
-- *if inventory is full, you cannot complete the quest - try to delete
-- newbie egg pet
function relog()
SetCharList({
-- enter account number and char numbers that you like to run this script
{account=1 , chars= {1,2}},
{account=2 , chars= {1}},
{account=3 , chars= {1}},
{account=4 , chars= {1}},
{account=5 , chars= {1}},
{account=6 , chars= {1}},
{account=7 , chars= {1}},
{account=8 , chars= {1}},
{account=9 , chars= {1}},
{account=10, chars= {1}},
{account=11, chars= {1}},
{account=12, chars= {1}},
{account=13, chars= {1}},
{account=14, chars= {1}},
{account=15, chars= {1}}.
{account=16, chars= {1}},
{account=17, chars= {1}},
{account=18, chars= {1}},
{account=19, chars= {1}},
})
LoginNextChar()
loadProfile()
loadPaths("ElfDaily");
end
questEndNpcID1 = 112794
questName1 = "Helping Them Grow"
</onLoad>
Re: Error elves daily
Posted: Mon Sep 16, 2013 2:54 pm
by sitw97
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
-- Elf daily script - V1.2 - written by Jandrana
-- thanks to rock5 for help regarding relog
-- relog features requires fastLogin and userfunction_LoginNextChar.lua
-- changes:
-- *if char is not in Valley of Preparation, try to use transport
-- *if inventory is full, you cannot complete the quest - try to delete
-- newbie egg pet
function relog()
SetCharList({
-- enter account number and char numbers that you like to run this script
{account=1, chars= {1,2}},
{account=2, chars= {1}},
{account=3, chars= {1}},
{account=4, chars= {1}},
{account=5, chars= {1}},
{account=6, chars= {1}},
{account=7, chars= {1}},
{account=8, chars= {1}},
{account=9. chars= {1}},
{account=10, chars= {1}},
{account=11, chars= {1}},
{account=12, chars= {1}},
{account=13, chars= {1}},
{account=14, chars= {1}},
{account=15, chars= {1}},
{account=16, chars= {1}},
{account=17, chars= {1}},
{account=18, chars= {1}},
{account=19, chars= {1}},
LoginNextChar()
loadProfile()
loadPaths("ElfDaily");
end
.
I did like you said and it is still the same error as above written
Re: Error elves daily
Posted: Mon Sep 16, 2013 3:10 pm
by rock5
Did you copy the whole onload that I posted?
Re: Error elves daily
Posted: Mon Sep 16, 2013 3:45 pm
by sitw97
I copied and pasted your post to waypoint now such a thing pops up:Loaded waypoint path ElfDaily.xmlNo return path with default naming ElfDaily_return.xml found.We use the normal waypoint path ElfDaily.xml now.haltOnError: falseThe game client did not crash.10:44 pm - ... p / rombot / rombot / scripts / rom / classes / waypointlist.lua 24: XML ParseError.File: ... top / rombot / rombot / scripts / rom / waypoints / ElfDaily.xmlLine: 41Column: 13Pos: 1321Message: junk after document element
Re: Error elves daily
Posted: Mon Sep 16, 2013 11:10 pm
by rock5
If you look at my code you can see that it starts with <onLoad> and ends with </onLoad>. That is the whole of the onload section. You were supposed to replace the whole of the onload in your waypoint file. Here, I'll do it for you.
Re: Error elves daily
Posted: Tue Sep 17, 2013 10:15 am
by sitw97
I downloaded the file and wkeiĆem pops up when you start waypoint:Loaded waypoint path ElfDaily.xmlNo return path with default naming ElfDaily_return.xml found.We use the normal waypoint path ElfDaily.xml now.The game client did not crash.5:12 pm - ... p / rombot / rombot / scripts / rom / classes / waypointlist.lua: 83: Failed to compile and run Lua code for waypointlist onLoad event.
Re: Error elves daily
Posted: Tue Sep 17, 2013 11:17 am
by rock5
When we get an onload error like that, it doesn't give us a line number for the error. So what we do is put all the onload code into an lua file and load that from the onload of the waypoint file. Then the error should include the line number and a better description. You can then put the code back into the waypoint file onload when the error has been fixed.
Eg.
Put both files into the waypoints folder.
The error was because at the end of account15 line there was a dot (.) instead of a comma (,).
Re: Error elves daily
Posted: Tue Sep 17, 2013 11:45 am
by sitw97
Thank you all been working on, you can close