GetBagCount() getting -sometimes- "compare number with nil"
GetBagCount() getting -sometimes- "compare number with nil"
"GetBagCount();"
leads in some cases to following error:
[string "..."]:3: attempt to compare number with nil
it's a once every 3-4 hour error ~ approximatley
"GetBagCount();" is done every circle (5min)
is this because of a special item in the inventar?
or a special number of items?
no idea :/
hope someone can help
leads in some cases to following error:
[string "..."]:3: attempt to compare number with nil
it's a once every 3-4 hour error ~ approximatley
"GetBagCount();" is done every circle (5min)
is this because of a special item in the inventar?
or a special number of items?
no idea :/
hope someone can help
Re: GetBagCount() getting -sometimes- "compare number with n
RoMScript sometimes fails and returns nil. That's why in a lot of my scripts I will do something like this
This, of course, can only be used if nil is not a possible expected answer.
RoMScript sometimes returns nil because of a 'time out'. I often wondered what would happen if there was no time out but I need someone who can reliably get that error. Would you be willing to try a little experiment for me? If so, please do the following.
Around line 573 of functions.lua you'll see the 'time out' code.Comment out the 'return' and see what happens.
If anyone else wants to test this for me please feel free to do so.
Code: Select all
repeat var = RoMScript("function()") until var ~= nilRoMScript sometimes returns nil because of a 'time out'. I often wondered what would happen if there was no time out but I need someone who can reliably get that error. Would you be willing to try a little experiment for me? If so, please do the following.
Around line 573 of functions.lua you'll see the 'time out' code.
Code: Select all
if( deltaTime(getTime(), startWaitTime) > 800 ) then
if( settings.options.DEBUGGING_MACRO ) then
cprintf(cli.yellow, "[DEBUG] TIMEOUT in RoMScript ... \n");
end;
return default; -- Timed out
end;Code: Select all
-- return default; -- Timed out- 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.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: GetBagCount() getting -sometimes- "compare number with n
I figured I never get the nil error because I always use those 'repeat' tricks so I thought I could still test it myself. I also added a bit of code that records what happens for extra info.
The results so far after about 1.5 hours with 2 clients running:
The results so far after about 1.5 hours with 2 clients running:
- 1 got stuck because it didn't action the macro ie. didn't click the action key. This happened twice. I was able to get the bot to continue by clicking the macro key manually. I'm not sure yet what we can do about that. Maybe keep clicking the macro until it works?
- The second one passed the 800ms threshold twice at around 1150ms but continued on afterward. Both times I would have got the "compare to nil" error if I hadn't done the change above. So in this situation, bypassing the "timeout" worked.
- 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.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: GetBagCount() getting -sometimes- "compare number with n
thanks rock5!
I dont know how to use
this 
at the moment I use:
:/ do I simply change it to
anyway,
I commented the timeout thing out, and will test it right now!
thx again!
I'll report back
I dont know how to use
Code: Select all
repeat var = RoMScript("function()") until var ~= nilat the moment I use:
Code: Select all
occupiedSlots, totalSlots = sendMacro("GetBagCount();");
if( occupiedSlots > 52 ) then
__WPL:setWaypointIndex(__WPL:findWaypointTag("SELL"));
end
Code: Select all
repeat var = RoMScript("GetBagCount();") until var ~= nilanyway,
I commented the timeout thing out, and will test it right now!
thx again!
I'll report back
Re: GetBagCount() getting -sometimes- "compare number with n
#reports#
-- will be edited on every news --
#1 runntime ~4min
#2 runntime 29min
#3 runtime 4min
I change the settings back again, and see how long they run until the nil value error now
-- will be edited on every news --
#1 runntime ~4min
Code: Select all
died in bossfight, script just kind of aborted,
couldnt even end the micromacro script with strg+l
very strange, no errors, bot both players died
never had something like this before
- sadly didnt watch what exactly happendCode: Select all
bot1 stopped working on "LeaveParty()" --> didnt left, didnt continue
bot2 stopped working while "GetNumPartyMembers()"
maybe both stopped parallel, didnt see it happening live...Code: Select all
one loop , both chars walked out of the instance, bot2 left the group
and startet inviting bot1 again, while bot1 got stuck after leaving the instance
on "GetNumPartyMembers()" again. so he isnt replying, no error, no continue... I change the settings back again, and see how long they run until the nil value error now
Re: GetBagCount() getting -sometimes- "compare number with n
Example:top1 wrote:thanks rock5!
I dont know how to usethisCode: Select all
repeat var = RoMScript("function()") until var ~= nil
If you have
Code: Select all
occupiedSlots, totalSlots = sendMacro("GetBagCount();");Code: Select all
repeat occupiedSlots, totalSlots = sendMacro("GetBagCount();"); until (occupiedSlots ~= nil and totalSlots ~= nil)Thanks for the testing you did. With the testing I was able to do, it looks like sometimes, especially while using the computer yourself to do other things, the results can take longer than the 800ms to return, as much as 6 or 8 seconds. Leaving out the timeout fixes that but sometimes it fails to return a value at all because the macro fails to execute. That's when it gets stuck waiting for a response that never comes. We could fix this by trying again but there is the danger that the command could get executed twice and in some situations you wouldn't want that, eg. using an expensive item, but I'm not sure how often that would occur.
I don't know if it would actually execute twice. I'll have to do more testing to find out. But in the mean time, the above should work for 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.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: GetBagCount() getting -sometimes- "compare number with n
thx!
no nil error anymore!!!!!!!!!!!!!!
but took me a while figuring out how to modifie codes like this:
no nil error anymore!!!!!!!!!!!!!!
but took me a while figuring out how to modifie codes like this:
Code: Select all
repeat groupcheck = sendMacro('GetNumPartyMembers()'); until groupcheck ~= nil;
if groupcheck == 0 then
repeat
yrest(2000);
sendMacro('InviteByName("Spidermann")');
yrest(1000);
sendMacro('SetInstanceLevel("easy")');
repeat groupcheck = sendMacro('GetNumPartyMembers()'); until groupcheck ~= nil;
until groupcheck == 2
endRe: GetBagCount() getting -sometimes- "compare number with n
Ok, after extensive testing it looks like I can remove the timeout in RoMScript and have it retry the macro if it fails. It works 100% of the time. The fear I had that it might actually often execute the command more than once in game didn't happen. It will only actually repeat the ingame command 1 in hundreds of retries.
This is looking good to commit. I'll do some cleaning up and maybe just a bit more testing and then I'll release it.
So from now on we wont get 'compare to nil' error any more.
This is looking good to commit. I'll do some cleaning up and maybe just a bit more testing and then I'll release it.
So from now on we wont get 'compare to nil' error any more.
- 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.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan