• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Replicating conditions in LUA

Using JIT conditional evaluation is highly convenient in Macros, but, how do we do it in Lua?

The MacroQuest INI command supports noparse. Fortunately we don't need to specify that when loading INI anymore. There is a simple load/save lib which will read the contents into a table, where you can then make edits, then save. Back to evaluating conditions.

Here is what I've cooked up. Any suggestions appreciated.

JavaScript:
--[[
    Read the contents of an INI into a table, ex reference: pc.ACond.Cond1
    [ACond]
    ; Cond takes a LUA expression
    ; Cond1 returns false. Cond2 returns true.
    Cond1=mq.TLO.Me.Name ~= mq.TLO.Me.Name
    Cond2=mq.TLO.Me.Name == mq.TLO.Me.Name
--]]

local function Eval_Cond(cond)
    result=false
    local test_cond = load('result=' .. cond)
    test_cond()
    return result
end

local Cond1="mq.TLO.Me.Name ~= mq.TLO.Me.Name"
local Cond2="mq.TLO.Me.Name == mq.TLO.Me.Name"
print (Eval_Cond(Cond1))
print (Eval_Cond(Cond2))
 
you could just do this. forget INI.

Code:
local function Cond1()
    return mq.TLO.Me.Name() ~= mq.TLO.Me.Name()
end

local function Cond2()
    return mq.TLO.Me.Name() == mq.TLO.Me.Name()
end

print(Cond1())
print(Cond2())

Note that in your example you're comparing userdata which always would be not equal.
 
I did test the code before posting. It returns true and false, rather than TRUE FALSE, so the boolean works.

There's appeal to INI in that one can open it up simply in Notepad++ and tinker with it. Replicating the Cond functionality was a goal of mine.

Using LIP I can read it into a table structure, edit it however I like, and save it back to INI. Love it.
 
I did test the code before posting. It returns true and false, rather than TRUE FALSE, so the boolean works.
A Boolean expression wouldn’t ever return TRUE or FALSE

forgot that I added a operator== for testing but I don’t know if it works outside of contrived examples such as this. It’s untested and undocumented
 
I don't understand what you are conveying. It seems counter to everything I've seen and done, and reported here. Shall I try replicate all my work from yesterday to show you what I saw?
 
Replicating conditions in LUA

Users who are viewing this thread

Back
Top
Cart