Page 1 of 1
bug default start location.
Posted: Thu Jun 11, 2015 12:58 pm
by beanybabe
i ran into a bug that i think needs changed.
This waypoint demonstrates it. if you run it you char will start running to 0 0 0 I think it needs to be changed that it runs to the location were you currently are at. This would prevent characters running off and getting stuck some where. I know this if not a likely bit of code but it can happen if you are testing new waypoints.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
print ("help i am running to impossible location")
</onLoad>
<waypoint>
</waypoint>
</waypoints>
Re: bug default start location.
Posted: Thu Jun 11, 2015 1:33 pm
by rock5
You added an empty waypoint. What do you expect it to do?
Re: bug default start location.
Posted: Sat Jun 13, 2015 4:41 am
by Celesteria
I agree with beanybabe: an empty waypoint should have the current location of a char, not {x=0,z=0,y=0}. this makes a lot of things smarter

Re: bug default start location.
Posted: Sat Jun 13, 2015 5:09 am
by lisa
A while a go I did a lot of testing with Waypoints that had current location as the only waypoint, the bot kind of spins and shudders a bit because it is constantly trying to get to the exact spot it is standing in.
Only way you would not have any waypoints in the file is if you created it manually and if you can do that then you can add in a loop in the onload so it doesn't even get to using any waypoints.
In my opinion anyway =)
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
print ("help i am running to impossible location")
while(true) do
yrest(100)
end
</onLoad>
<waypoint>
</waypoint>
</waypoints>
Re: bug default start location.
Posted: Sat Jun 13, 2015 6:14 am
by BlubBlab
beanybabe wrote:i ran into a but that i think needs changed.
This waypoint demonstrates it. if you run it you char will start running to 0 0 0 I think it needs to be changed that it runs to the location were you currently are at. This would prevent characters running off and getting stuck some where. I know this if not a likely bit of code but it can happen if you are testing new waypoints.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
print ("help i am running to impossible location")
</onLoad>
<waypoint>
</waypoint>
</waypoints>
I would say this should give a error message and not do anything, taking the current coordinates are the second best option. I think the problem is that in earlier days Rombot had no z-coordinates because of this the bot handles the other 2 in a similar way.
Re: bug default start location.
Posted: Sat Jun 13, 2015 5:27 pm
by lisa
BlubBlab wrote:I would say this should give a error message and not do anything,
Except some WP don't have any waypoints at all, like the AT or commandline scripts where everything is dealt with inside the onload, so if having no waypoints made the WP error then those scripts would no longer work.
Do I agree that running off into the distance to try to get to 0,0,0 is not good, for sure.
Q. Would someone creating a WP using createpath make a WP with no waypoints?
A. Very unlikely.
So this issue is only an issue with people who create WP manually by typing in the code, they should understand how the coding currently works.
In waypoint.lua it has the CWaypoint class, if there are no X or Z cords in the information given to the class it sets the values to 0.
Code: Select all
if( not self.X ) then self.X = 0.0; end;
if( not self.Z ) then self.Z = 0.0; end;
Maybe you could try playing around with this code and seeing if you can improve it, test the changes and report how the changes worked and what didn't work.
Re: bug default start location.
Posted: Sun Jun 14, 2015 5:11 am
by BlubBlab
lisa wrote:BlubBlab wrote:I would say this should give a error message and not do anything,
Except some WP don't have any waypoints at all, like the AT or commandline scripts where everything is dealt with inside the onload, so if having no waypoints made the WP error then those scripts would no longer work.
Do I agree that running off into the distance to try to get to 0,0,0 is not good, for sure.
Q. Would someone creating a WP using createpath make a WP with no waypoints?
A. Very unlikely.
So this issue is only an issue with people who create WP manually by typing in the code, they should understand how the coding currently works.
In waypoint.lua it has the CWaypoint class, if there are no X or Z cords in the information given to the class it sets the values to 0.
Code: Select all
if( not self.X ) then self.X = 0.0; end;
if( not self.Z ) then self.Z = 0.0; end;
Maybe you could try playing around with this code and seeing if you can improve it, test the changes and report how the changes worked and what didn't work.
The problems is it to say it loud is not we haven't a waypoint we have a waypoint with no coordinates.
By the way when you run a waypointfile and you have no waypoint(s) so far I remember it gives an error at the moment you are past the onload section.
You can either do this:
Code: Select all
if( not self.X ) then self.X = player.X; end;
if( not self.Z ) then self.Z = player.Z; end;
or
Code: Select all
if( not self.X ) then error("some message") end;
if( not self.Z ) then error("some message") end;
Re: bug default start location.
Posted: Sun Jun 14, 2015 9:32 am
by rock5
lisa wrote:Except some WP don't have any waypoints at all, like the AT or commandline scripts where everything is dealt with inside the onload, so if having no waypoints made the WP error then those scripts would no longer work.
I think the point is, not that it would error just because it has no waypoints but to error if the onload completes and there are no waypoints. What's the point of continuing to the waypoints when there are no weaypoints? If it's an 'onload' only waypoint then it should stay in the onload and error out when finished (or load another file).
As it is, it works if there are no waypoints. It displays the error that there are no waypoints and ends. This assumes that someone created an onload only waypoint but forgot to exit it properly when finished. The bug, if you want to call it that, is that when you have an empty <waypoint> it still adds it to the __WPL list even though it's empty. This just means the user didn't create the waypoint properly. There is no real need to support faulty waypoint like that but it would be extremely easy to add a check before adding the waypoint. Something along the lines of "if x and z then add the waypoint". That should avoid empty waypoints from being added and should solve the OPs original query.
Re: bug default start location.
Posted: Sun Jun 14, 2015 2:03 pm
by BlubBlab
If you simple skip it I would at least give a message out.
Re: bug default start location.
Posted: Sun Jun 14, 2015 3:43 pm
by beanybabe
This came up when I was making a new waypoint in a public area and testing it and the character just took off running. lucky no one seen it. I thought id post about it in case it might cause others grief.
Re: bug default start location.
Posted: Wed Jun 17, 2015 3:25 am
by rock5
It shouldn't cause anyone grief. If you manually created a waypoint file and then tested it, if it takes off unexpectedly, you will see it and stop it. No one who sees it will think anything of it. All they will see is a character start to run, stop, then return.
Re: bug default start location.
Posted: Wed Jun 17, 2015 4:30 am
by Celesteria
rock5 wrote:There is no real need to support faulty waypoint like that but it would be extremely easy to add a check before adding the waypoint. Something along the lines of "if x and z then add the waypoint". That should avoid empty waypoints from being added and should solve the OPs original query.
the definition of "faulty waypoint" is relative. an empty waypoint is not a faulty waypoint if you want to use the bot as it is supposed to do (in my understanding). the event-section (onload) is to set variables, define functions and check start properties of the script. the waypoint-section is to handle the bot using the functions defined above. i know, everybody uses the onload-section if there is no need of waypoints, but this is a workaround, not the correct way. from this point of view it should be the correct way to add an empty waypoint to the __WPL as the current location and not to avoid them from being added. this makes the bot perfect and makes sense to everyone who understand a "real programing style"

Re: bug default start location.
Posted: Wed Jun 17, 2015 4:56 am
by rock5
Waypoint events are for executing code when you reach a specific location. There is no point in having a waypoint with no coordinates. If you want to execute code where ever you are and don't care about the location then you just do the code in the onload.
You just have to decide; do you want code to run when you reach a location then you put it in a waypoint, or do you want code to run when you load a file then you put it in the onload.
Re: bug default start location.
Posted: Thu Jun 18, 2015 6:58 pm
by BlubBlab
Celesteria wrote:rock5 wrote:There is no real need to support faulty waypoint like that but it would be extremely easy to add a check before adding the waypoint. Something along the lines of "if x and z then add the waypoint". That should avoid empty waypoints from being added and should solve the OPs original query.
the definition of "faulty waypoint" is relative. an empty waypoint is not a faulty waypoint if you want to use the bot as it is supposed to do (in my understanding). the event-section (onload) is to set variables, define functions and check start properties of the script. the waypoint-section is to handle the bot using the functions defined above. i know, everybody uses the onload-section if there is no need of waypoints, but this is a workaround, not the correct way. from this point of view it should be the correct way to add an empty waypoint to the __WPL as the current location and not to avoid them from being added. this makes the bot perfect and makes sense to everyone who understand a "real programing style"

The problem is an 'empty' waypoint is not defined doing something with it is just guessing what the user maybe meant.
If you want to stay there it is like Rock5 said make a waypoint there and it isn't so that an not defined waypoint had ever worked. On top you can also control the bot with out waypoint manually.
Re: bug default start location.
Posted: Sat Jun 20, 2015 5:39 pm
by BlubBlab
Rock? So what will you do ? I don't want to be impatient but it happened that the last time I left the work on my bot-framework for MM2 . I was building the XML-tree for the waypoint file. Today I got it to work so you can do it either the old way or xml.load(file).
So it would be cool how your code looks like

, so I can change mine also.
Re: bug default start location.
Posted: Sat Jun 20, 2015 10:25 pm
by rock5
I just changed line 59 of waypointlist.lua from
Code: Select all
if( string.lower(name) == "waypoint" ) then
to
Code: Select all
if( string.lower(name) == "waypoint" ) and x and z then
That should stop it from adding empty waypoints to the waypoint list. Then it should trigger the "no waypoints" error message as it's supposed to instead of running off to 0,0.
I'll do a review of my current changes and see about doing a commit.