• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - Strange problem breaks lua

Soandso2

Well-known member
Joined
Mar 13, 2023
RedCents
937¢
I keep getting:
bad argument #3 to'?' (no value)

in the following function on line 9 (highlighted):

[CODE lang="Lua" highlight="9"]local function checkEndurance()
if me.PctEndurance() < 25 and aSkill == "tc" then
mq.cmd("/autoskill eagle strike")
aSkill = "es"
printf("[%s] \ayEndurance low, switching to Eagle Strike",mq.TLO.Time.Time24())
elseif me.PctEndurance() > 50 and aSkill == "es" then
mq.cmd("/autoskill tiger claw")
aSkill = "tc"
printf("[%s] \ayEndurance over 50%, switching back to Tiger Claw",mq.TLO.Time.Time24())
end
end[/CODE]

but I cant see what is wrong. I removed the first space (between ] and \ay) once and then the function did not break. I thought I had got some strange invisible character in there that for some reason broke everything, but when adding the space back the problem started again. I cant see a difference between the syntax on lines 5 and 9, and line 5 never causes a problem.
 
Last edited:
I'd guess either the second % in that second printf, maybe try escaping with %% i think is the escape in Lua or maybe that was imgui i forget. Or does mq.TLO.Time.Time24 explode into more than one argument?
 
I'd guess either the second % in that second printf, maybe try escaping with %% i think is the escape in lua or maybe that was imgui i forget. Or does mq.TLO.Time.Time24 explode into more than one argument?
Hmm I will see what happens if I remove the % after 50, but it feels strange that line 9 did not cause a crash when I removed the space after the first right bracket and the backslash. I think backslash is the escape character in Lua.

Time24() returns a string formated as HH:MM:SS (in 24 hour time format)

Edit: Well, that fixed it. Using %% is the way to go when printing literal % in formated strings. Thanks for the advice.
 
Last edited:
For future clarity can you share what actually fixed it?
using %% instead of just % would have fixed it.
Formatted text uses %s, %i, %d etc to indicate the type of value it would receive when using a printf. So in order to indicate that you would like to use a % in a string you have to have a way for it to know it's not looking to accept a value as a parameter, which would be %% to indicate that you just want a %.

From Wikipedia because I'm lazy today.

1694449765882.png
 
also use Lua time stuff, and dont make it use macrolanguage time stuff


example of getting the 24hour format using Lua, and not tlo macro stuff
printf("24 hour time - %s", os.date('%H:%M:%S'))
 
also use lua time stuff, and dont make it use macrolanguage time stuff


example of getting the 24hour format using lua, and not tlo macro stuff
printf("24 hour time - %s", os.date('%H:%M:%S'))
Oh well, sure. (I never considered the above since I noticed that there was a macroquest TLO for time and once I found it, I did not think any further)
I want to stress that am not trying to be smart here... but why? Of course, I don't know how stuff works, but what is wrong with the "macroquest TLO stuff"? Does Lua time stuff decrease the workload for the computer? Is it more accurate? Is it faster? If there is Lua stuff for something already, why is there a macroquest time tlo thing?
 
using %% instead of just % would have fixed it.
Formatted text uses %s, %i, %d etc to indicate the type of value it would receive when using a printf. So in order to indicate that you would like to use a % in a string you have to have a way for it to know it's not looking to accept a value as a parameter, which would be %% to indicate that you just want a %.

You escape characters using backslash in Lua, just like in many other languages like PHP for example. But when it comes to literal % in formated strings, you use % instead. I wonder why you cannot just use \%
 
Oh well, sure. (I never considered the above since I noticed that there was a macroquest TLO for time and once I found it, I did not think any further)
I want to stress that am not trying to be smart here... but why? Of course, I don't know how stuff works, but what is wrong with the "macroquest TLO stuff"? Does lua time stuff decrease the workload for the computer? Is it more accurate? Is it faster? If there is lua stuff for something already, why is there a macroquest time tlo thing?
Lua code is i believe less intensive than calling TLO so where we can use Lua code instead of some old TLO the better you are off.
 
Ah. Very good call then. I will change my code. Many thanks for the advice! :)
 
Question - Strange problem breaks lua

Users who are viewing this thread

Back
Top
Cart