Room List

Post Reply
spoofmanbob
Posts: 9
Joined: Sat Oct 25, 2014 4:49 am

Room List

Post by spoofmanbob »

I would like to know how to display what enemies are all in the room with me. I see the data in gmcp.Char as a list i'm just not sure how to go about it. Anyone have any examples i can work off?

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Room List

Post by Silvine »

You just want to loop through the table and echo it somewhere. Something like this
Code: [show] | [select all] lua
demonnic.chat.windows["Me"]:clear()

if gmcp.char.permaff ~= nill then
	for i = 1, #gmcp.char.permaff do
		demonnic.chat:cecho("Me", "<green>(perm) "..gmcp.char.permaff[i].."\n")
	end --for
end --if
where demonnic.chat.windows["Me"] is where it echos
and gmcp.char.permaff would be your table of enemies
Mapper of Bedlam

spoofmanbob
Posts: 9
Joined: Sat Oct 25, 2014 4:49 am

Re: Room List

Post by spoofmanbob »

This is what I'm using currently but it doesn't stay up to date.
Code: [show] | [select all] lua
function roomTracker()

local t = {}
for k,v in pairs(gmcp.Char.Items.List.items) do
  table.insert(t, v.name)
	GUI.Box6:setFontSize(10)
end

GUI.Box6:echo(table.concat(t, "<br>"))
end

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Room List

Post by Jor'Mox »

What do you have calling the function? You would need to call it whenever it changed, if you wanted it to stay up to date. So there would need to be a trigger or an event that called your function to refresh it when the list changed.

spoofmanbob
Posts: 9
Joined: Sat Oct 25, 2014 4:49 am

Re: Room List

Post by spoofmanbob »

Which trigger(s) are required to keep the list up to date?

User avatar
Angie
Posts: 51
Joined: Fri May 02, 2014 11:43 pm

Re: Room List

Post by Angie »

Do you have the function hooked up to an event handler for gmcp.Char.Items?
Angie @ Midnight Sun 2
Alayla @ God Wars 2

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: Room List

Post by phasma »

Yeah. You basically just need to write handler functions for gmcp.Char.Items.Add as well as for .Remove and .Update (The latter being the most troublesome).

Post Reply