• 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

Lua - Function Call from EQ

Joined
Jan 29, 2021
RedCents
193¢
I have my buffing routines setup like the following. 1 buffing file for each class. I am showing the Druid one. I am leaving out all the details of each function as it's not important

[CODE title="druid.petBuff = function()"]local mq = require('mq')
local casting = require('casting')
local buffing = require('buffing')

local druid = {}

druid.selfBuff = function()
druid.partyBuff = function()
druid.petBuff = function()
druid.resistBuff = function()
druid.invisBuff = function()
return druid[/CODE]

When I want to have my party invis themselves, I do the following

From EQ
Code:
/bcga //lua run invis_routine

And my invis_routine file looks like
Code:
local class_name = mq.TLO.Me.Class.Name()
print(class_name)

if(class_name == "Druid") then
    druid.invisBuff()
elseif (class_name == "Beastlord") then
    beastlord.invisBuff()
elseif (class_name == "Enchanter") then
    enchanter.invisBuff()
elseif (class_name == "Magician") then
    mage.invisBuff()
else
    print('No invis buff routine for this ' .. class_name)
end

I was wondering if there was a way to do away with the invis_routine file and somehow call the functions directly from EQ. Something like
Code:
/bct Druid //lua run druid.invisBuff
/bct Mage //lua run mage.invisBuff
/bct Enchanter //lua run enchanter.invisBuff
/bct Beastlord //lua run beastlord.invisBuff
 
Last edited:
You can pass parameters to your script. For example:

Code:
/bct DruidName //lua run buffs druid invis

In your code, you have access to parameters like so:

[CODE lang="Lua" title="args.Lua"]local arguments = {...}

for index, value in ipairs(arguments) do
print(index..', '..value)
end
[/CODE]


[CODE title="Output"]> /Lua run args foo bar foobar
Running Lua script 'args' with PID 1
1, foo
2, bar
3, foobar
Ending Lua script 'args' with PID 1 and status 0[/CODE]
 
Right!!!!! I should have know that!
You might want to try not running the Lua from scratch each time. Not sure about your overall design, but you could consider something like:
Code:
function print_error()
  print('Invis not supported for this class!')
end
function do_invis()
  print('Casting invis!')
end

local invis_routine = print_error

if mq.TLO.Me.Class.ShortName() == 'BRD' then
  invis_routine = do_invis
end

local function invis_all()
  mq.cmd('/bcga //dinvis')
end

mq.bind('/binvis',invis_routine)
mq.bind('/binvisa',invis_all)

while true do
  mq.delay(1000)
end

You could then type /dinvis to invis current character, or /dinvisa to invis everyone running the invis Lua.
 
You might want to try not running the Lua from scratch each time. Not sure about your overall design, but you could consider something like:
Code:
function print_error()
  print('Invis not supported for this class!')
end
function do_invis()
  print('Casting invis!')
end

local invis_routine = print_error

if mq.TLO.Me.Class.ShortName() == 'BRD' then
  invis_routine = do_invis
end

local function invis_all()
  mq.cmd('/bcga //dinvis')
end

mq.bind('/binvis',invis_routine)
mq.bind('/binvisa',invis_all)

while true do
  mq.delay(1000)
end

You could then type /dinvis to invis current character, or /dinvisa to invis everyone running the invis Lua.
Let me think on this ... sounds intriguing ...
 
Lua - Function Call from EQ

Users who are viewing this thread

Back
Top
Cart