Lua Return Problem

Langues: JP EN DE FR
users online
Forum » Windower » Support » Lua return problem
Lua return problem
Online
By Nsane 2024-04-05 14:59:05
Link | Citer | R
 
Code
ID = {}
local group = {'party1_count', 'party2_count', 'party3_count'}
local position = {{'p0','p1','p2','p3','p4','p5'}, {'a10','a11','a12','a13','a14','a15'}, {'a20','a21','a22','a23','a24','a25'}}


function ADDplayer(list, player)

	if (player == nil) or list:contains(player.name) then return end
	if (player.hpp <= 0) then
	else list[player.name] = player end
	
end

function players()

	local party = windower.ffxi.get_party()
	local zone = party.p0.zone
	local members = S{}
	for g = 1, #group do
		for p = 1, party[group[g]] do
			local party_member = party[position[g][p]]
				if zone == party_member.zone then
				if g == 1 then
					ADDplayer(members, party_member)
				end
			end
		end
	end

	return members

end

ID.players = players

function playerIDs()

	local IDs = S{}
	for name, player in pairs(ID.players()) do
		local ID = player.mob and player.mob.id or player.id
		if ID ~= nil then
			IDs[ID] = true
		end
	end

	return IDs and print(IDs)

end


When I return "IDs" its come's out as {111111, 222222, 333333} etc. I would like it to come out as 111111 or 222222 or 3333333 etc. Trying to get rid of the brackets and commas basically, any input would be greatly appreciated.
 Fenrir.Niflheim
VIP
Offline
Serveur: Fenrir
Game: FFXI
user: Tesahade
Posts: 749
By Fenrir.Niflheim 2024-04-05 15:22:12
Link | Citer | R
 
Questions like this are probably better off on our discord in the development channel.

But a set has a meta method to convert it to a string, if you want a different output formatting you would need to iterate over the values and generate that desired string.
Offline
Posts: 14726
By Pantafernando 2024-04-05 15:37:29
Link | Citer | R
 
Apparently “IDs” is a matrix.

And apparently what you want is each or some elements in that matrix.

Checking the documentation, you can reference them by using IDs[1], IDs[2], etc.
Online
By Nsane 2024-04-06 05:45:26
Link | Citer | R
 
Thanks for the replies.
Log in to post.