GMCP

A category for whatever! Can be Mudlet-related or offtopic.
User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

GMCP

Post by tsuujin »

GMCP is so frustrating! The way they handle things is just stupid!

For example, when you move into a new room or look in a current room it updates gmcp.Char.Items.List, but when something appears or disappears in a room instead of refreshing gmcp.Char.Items.List, it instead changes gmcp.Char.Items.Add or gmcp.Char.Items.Remove, and leaves gmcp.Char.Items.List inaccurate.

Man it makes gmcp hard to use.

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

Re: GMCP

Post by Vadi »

heiko shares your opinion on GMCP

The room one actually sounds a bit plausible, if I drop 2k items and get them up one by one, imagine how much of a data savings it is to send add/remove lines over whole contents-1 again...

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: GMCP

Post by tsuujin »

If that were the case, it'd be plausible, but in more than ten years of mudding I've never seen anything so extreme.

If they're going to do it that way, it'd be nice if they'd at least give the name part of the ID on items instead of just the number.

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

Re: GMCP

Post by Vadi »

Thinking about using this list more. It seems we need some sort of a state tracker and this script would be useful to everybody.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: GMCP

Post by tsuujin »

Vadi wrote:Thinking about using this list more. It seems we need some sort of a state tracker and this script would be useful to everybody.
I've been pondering writing one for a while. I could probably do this.

By the way, you never commented on my module tracker I wrote for you.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: GMCP

Post by tsuujin »

This is what I'm currently using to track enemies in the room:
using the event gmcp.Room.Info, and lacking the counterpart "areaEnemies" which just tracks a list of known NPCs in given area and returns various information.
Code: [show] | [select all] lua
-- [[ Room Enemies Tracker ]] --

function roomEnemiesEvent(event,args)
	if args:find("Add") then roomEnemies.add(gmcp.Char.Items.Add)
	elseif args:find("Remove") then roomEnemies.remove(gmcp.Char.Items.Remove)
	elseif args:find("List") then roomEnemies.reset(gmcp.Char.Items.List)
	end
end

module("roomEnemies",package.seeall)

local current = {}
local roomTarget = ""
local oldlist = nil

function add(toadd)
	if not toadd then return end
	if toadd.item.name:find("the corpse of") then return end
	if toadd.location ~= "room" then return end
	current[tonumber(toadd.item.id)] = areaEnemies.isAreaEnemy(toadd.item.name)
end

function remove(tosub)
	if not tosub then return end
	if tosub.location ~= "room" then return end
	local subID = tonumber(tosub.item) or 0
	current[subID] = nil 
end

function reset(newlist)
	if not newlist then return end
	if newlist.location ~= "room" then return end
	if newlist == oldlist then return end
	oldlist = newlist
	for i,v in pairs(current) do highlight:remove(v or "") end
	current = {}
	for i,v in pairs(newlist.items or {}) do
		if not v.name:find("the corpse of") then
			current[tonumber(v.id)] = areaEnemies.isAreaEnemy(v.name) or nil
		end
	end
end

function get() return current end

function print()
	msg.print("<yellow>Enemies currently tracked in room:")
	for i,v in pairs(current) do
		msg.print(string.format("%-15s%s",i,v))
	end
end

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

Re: GMCP

Post by Vadi »

That looks neat.

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

Re: GMCP

Post by Vadi »

Adjusted the script a bit to work. To use, import it, walk into a room,
Code: [show] | [select all] lua
roomEnemies.print()
--or
display(roomEnemies.get())
Should display the current state of the tracker. Item IDs are the keys, item longnames are the values.
Attachments
roomEnemies.xml
(1.99 KiB) Downloaded 597 times

traxtin
Posts: 7
Joined: Wed Nov 23, 2011 8:20 am

Re: GMCP

Post by traxtin »

Is there a way to have this output to a different window so that we can view the denizens and items for each room in a seperate more easily viewed window?

Sorry if its a stupid question but i really have no clue what i'm doing with most of Mudlet :P

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: GMCP

Post by tsuujin »

This doesn't handle anything other than managing the connection and modules for GMCP. You can use this in a script to gain access to the information you need, but it doesn't do anything to help you retrieve and format it.

Post Reply