Using matches[x] to reference a table
Posted: Tue Mar 30, 2021 10:42 pm
I'm trying to make a script to keep track of my opponents' afflictions and what they're curing.
The basic script works fine. It goes through the list of afflictions until it finds the highest priority affliction the target currently has and removes it.
The problem is this part:
The script only works if I specify which list it has to check in the script itself. Ideally, I'd like to run something like this:
So I could make a trigger that runs target_usedcure(matches[4]) and automatically checks the correct table of afflictions. Nothing I've tried so far has worked. Either the alias I'm using to test the script doesn't work or the debug gives me an error message that Mudlet expected a table and got a string instead. Does anyone know if there's anything I can do to make the variable register as a table reference?
The basic script works fine. It goes through the list of afflictions until it finds the highest priority affliction the target currently has and removes it.
Code: Select all
local cure_priority = 1
function target_usedcure(cure)
local aff_check = opiate[cure_priority]
if
table.contains(target_affs, aff_check) == true
then
table.remove(target_affs, tonumber(table.index_of(target_affs, aff_check)))
cure_priority = 1
else
cure_priority = cure_priority + 1
target_usedcure()
end
end
Code: Select all
function target_usedcure()
local aff_check = [b]opiate[/b][cure_priority]
Code: Select all
function target_usedcure(cure)
local aff_check = cure[cure_priority]