Identifying and Selecting Targets from a List

Post Reply
Puckster
Posts: 24
Joined: Fri Jul 30, 2021 11:51 pm

Identifying and Selecting Targets from a List

Post by Puckster »

Ok, let me see if I can explain this. It's a bit hard because I don't know exactly what I want until I tinker with it a little bit, but I'll give it a shot.

First part - target slots:

I want to have a list of 4 primary targets.
I want to bind 4 keys (one for each target) to attack the selected target
I want a gyser element to show the four targets and which 'slot' they are in (so I know which key maps to whcih target)

Second part - potential targets:

I want to parse text to identify potential targets (I know how to do this).
I want to be able to add potential targets to a list, adding new targets to the 'bottom' of the list.
I want to automatically remove any previous entries for the same target (so there are no duplicates).
I want the potenital targets to show in gyser element.
I want to be able to select a potential target and move it to one of the target slots identified in part one.
Ideally, I would like to use bound keys to scroll through the list to select a target rather than, say, typing a number from the list.

Lastly, I also want to be able to manually add a target to a slot via the command line (i.e. set target 1 to wolf).

I hope I have described this well enough.
Last edited by Puckster on Mon Aug 09, 2021 1:25 am, edited 1 time in total.

Puckster
Posts: 24
Joined: Fri Jul 30, 2021 11:51 pm

Re: Identifying and Selecting Targets.

Post by Puckster »

By the way, I'll take partial solutions or ideas to get me started. :-)

Puckster
Posts: 24
Joined: Fri Jul 30, 2021 11:51 pm

Re: Identifying and Selecting Targets.

Post by Puckster »

Ok, starting to work some of this out for myself. Completely new to LUA and Mudlet and Geyser, so ... on the learning curve here.

So populating either list is easy enough with "insert", so that part is straightfoward.

moblist = {}
targets = {}

Then why my trigger identifies a potential target:

table.insert(moblist, 1)

and when I figure out how to select a target in the moblist a similar table insert into slot 1, 2, 3, or 4 in the targets array should do the trick there.

Next thing i have to figure on is how to remove any duplicates from moblist. That's probably not hard.

then maybe limit the length of the moblist so it doesn't become unwieldy.

with something like

while table.getn(moblist) > 10 do
table.remove(moblist, table.getn(moblist)) --maybe I should define a dummy var here for this?

Then to update the Geyser window for moblist, do I just refresh the window with the whole list (since maybe we removed one or two from the top and maybe removed a duplicate)?

and I still don't know how to cycle throuhg moblist (perferable visible in the Geyser window) to select one to add to the target list.

Hope my stream of conscousness problem-solving is somewhat followable ...

Puckster
Posts: 24
Joined: Fri Jul 30, 2021 11:51 pm

Re: Identifying and Selecting Targets from a List

Post by Puckster »

Getting closer, but I am sure there are problems with my code and there are still a couple of gaps that I am stuck on.

Code: Select all

-- Initialize list at login
moblist = {} -- List of potential targets.
targets = {} -- List of actual targets mapped to one of 4 slots

--[[
In code that parses game output to identify potential targets, the following
code adds the potential (newmob) to the potential target to the list,
removes duplicates, and trims the list to a managable length.
]]

table.insert(moblist, 1, newmob)

hash = {}
nodup = {}

for _,v in ipairs(moblist) do
   if (not hash[v]) then
       nodup[#nodup+1] = v
       hash[v] = true
   end
end

moblist = nodup

while #moblist > 10 do
	table.remove(moblist, #moblist)
end

--[[
Write the moblist table to a message window. I modified code I found in a
couple of different places, so I may not have correct or consistent syntax
]]

mobWindow = mobWindow or Geyser.UserWindow:new({
  name = "mobWindow",
  titleText = "Possible Targets",
  x = 0,
  y = 240,
  width = 648,
  height = 210,
 })

mobWindow:setFontSize(10)

clearUserWindow("mobWindow")

for _, v in moblist do
	moveCursor("mobWindow",0,10-_)
	echo("mobWindow",v)
end

--How to highlight a line in mobWindow based on keybinding (i.e. up/down)

????

--How to select the highlighted line and move add that element to

????

target -- defines the target to be placed in the target slot
slot -- defines in which of the four target slots to place the target

mobWindow = targWindow or Geyser.UserWindow:new({
  name = "targWindow",
  titleText = "Targets",
  x = 0,
  y = 240,
  width = 648,
  height = 210,
 })

mobWindow:setFontSize(10)

-- Add target to correct position on the target list.

	moveCursor("targetWindow",0,slot)
	echo("targetWindow",target)

-- Separate keys are bound to each of the four target slots, so no need to select

User avatar
Vadi
Posts: 4979
Joined: Sat Mar 14, 2009 3:13 pm

Re: Identifying and Selecting Targets from a List

Post by Vadi »

Sorry for the late reply, did you manage to get this solved?

Post Reply