Mudlet features and API requests

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

Re: Mudlet API requests

Post by Vadi »

Add a table.update function:
Code: [show] | [select all] lua
function update(t1, t2) 
	for k,v in pairs(t2) do 
		if type(v) == "table" then 
			t1[k] = update(t1[k] or {}, v) 
		else 
			t1[k] = v 
		end 
	end 
	return t1 
end
merges contents of t2 into t1 in place.

Code: Select all

> printr(f, 1000, a)
{
	a = true,
	c = true,
	b = true,
}
> printr(f, 1000, b)
{
	a = false,
	c = false,
}
> update(a,b)
> printr(f, 1000, a)
{
	a = false,
	c = false,
	b = true,
}
> 

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Mudlet API requests

Post by demonnic »

+1

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

Re: Mudlet API requests

Post by Vadi »

closures for temp triggers ala temptimer style, so we can operate with upvalues:
Code: [show] | [select all] lua
local data
tempRegexTrigger("my pattern", function() data = "whatever" end)

Denarii
Posts: 111
Joined: Thu Dec 03, 2009 10:54 pm

Re: Mudlet API requests

Post by Denarii »

You know, I think I did that at one point but it didn't end up getting merged into git.

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

Re: Mudlet API requests

Post by Vadi »

See if you can dig up the patch, and email it again...

/me also needs to get the patch that fixes mudlet api error messages to say which function they come from in as well

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

Re: Mudlet API requests

Post by Vadi »

See if you can dig up the patch, and email it again...

/me also needs to get the patch that fixes mudlet api error messages to say which function they come from in as well

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: Mudlet API requests

Post by Iocun »

Vadi wrote:closures for temp triggers ala temptimer style, so we can operate with upvalues:
Code: [show] | [select all] lua
local data
tempRegexTrigger("my pattern", function() data = "whatever" end)
This would be awesome.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Mudlet API requests

Post by naftali »

Vadi wrote:/me also needs to get the patch that fixes mudlet api error messages to say which function they come from in as well
As that would be. Also, if you could maybe look at the way debug messages sometimes get the line wrong (saying the error comes from line 2 in a 1-line script is the one that made me sure I wasn't imagining this)

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Mudlet API requests

Post by naftali »

New request - if a multiline/and trigger has only one pattern of type 'perl regexp' whose number is num, the matches table should equal multimatches[num].

Most of the time when i use multiline/and triggers I'm really just making a shielded regexp. In such a case I always have the first line in my script be 'matches = multimatches[2]' or whatever the number of the regexp pattern is, because it's alot simpler to think of things like that. I never care about the other contents of the multimatches table anyway in such cases, and even if I did I COULD still get at them - this isn't about not using multimatches, it's about also using matches for the part that most people use.

EDIT: Bloody hell. Is this understandable? This is one of those days when communication is a struggle.

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

Re: Mudlet API requests

Post by Vadi »

I don't see this being necessary, personally. It'll just clutter the interface if we get more and more such 'workarounds'.

Post Reply