Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Plugin Request: Zombies
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #15 on Sat 27 Jan 2018 05:27 AM (UTC) |
| Message
| I've just gone to bed, I'll work on this in the morning
Thank you for spending so much time helping me get this working. | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #16 on Sat 27 Jan 2018 03:54 PM (UTC) Amended on Sat 27 Jan 2018 05:42 PM (UTC) by Fevix
|
| Message
| Alright, it's the morning now. And somehow, it's working just fine with zero changes between last night and now.
Now my only issue is the commands adding to the main menu (Ex., when I use "Kei Look" it adds a line with only "Kei Look" to the main screen (Same thing happens when I use the sub-world's plugin))
Other than the above, which is perfectly tolerable, it's working perfectly. Thank you SO MUCH for helping me out!
Edit: And now even that issue is resolved! Thank you again!
Edit2: I'm now wondering if there's some way to strip off the trigger (the "puppet1> " part) before sending it to the chat_world (So that I can set all the windows to 80 columns, the default for this MUCK, and not have the triggers turn that into more than 80 and cause linebreaks where there shouldn't be some)
I COULD just add the length of the trigger to the columns, but then I'd have a buncha different-sized windows.
This is what I'm trying, but it's not changing what's sent to the world:
<script>
<![CDATA[
chat_world = ""
function redirect (name, line, wildcards, styles)
chat_world = string.sub (string.match (line, "[^ ]->"), 1, -2) -- figure out which world is the chat_world
line = string.sub(line, string.len(string.match (line, "[^ ]->"))+2, -1) -- Attempt to separate the actual line from the trigger
-- try to find "chat" world
local w = GetWorld (chat_world) -- get "chat" world
-- if not found, try to open it
if not w then
local filename = GetInfo (67) .. chat_world .. ".mcl"
Open (filename)
w = GetWorld (chat_world) -- try again
if not w then
ColourNote ("white", "red", "Can't open chat world file: " .. filename)
end -- can't find world
end -- can't find world first time around
if w then -- if present
for _, v in ipairs (styles) do
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
w:Note ("") -- wrap up line
end -- world found
end -- function redirect
]]>
</script>
Then only reason I'm calling the redirect function by defining it into a variable is because I couldn't find hide nor hair about just CALLING a function in lua, every site I tried to look up only had information about using functions as variable, not just outright calling them. So rather than experiment and get it wrong 20 times I just used something I knew would work.
Edit3: Changed the script, merged both sub-functions into the main function (Why did I even MAKE them sub-functions?)
Edit4: I tried modifying the colortell to wrap it in an "if not" to just not send the message if v.text was the prefix but then it wouldn't send anything at all
for _, v in ipairs (styles) do
if not v.text == chat_world .. "> " then
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end
end -- for each style run
Edit5:
Slight issue, not exactly critical but ANSI styles aren't moving over. For example, the OOC command is supposed to render in italics.
Main window (correct): https://gyazo.com/6a81ba8e5dc9f0ac171e21d9ccf6f2a4
Keith's window (incorrect): https://gyazo.com/f5ac650ba7cbd13c2d0a0e69ed95ded0
So to recap (Neither of these are critical)
- Strip the prefix from messages ("Keith> ")
- Transfer ANSI styles (Italics, bold, underline) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #17 on Sat 27 Jan 2018 10:13 PM (UTC) Amended on Sat 27 Jan 2018 10:14 PM (UTC) by Nick Gammon
|
| Message
|
Quote:
I'm now wondering if there's some way to strip off the trigger (the "puppet1> " part)
You would need to identify how many style runs it takes (ie. are there multiple colours there?). If it is always in the first style run you could modify that before looping and sending the styles. eg.
styles [1] = string.gsub (styles [1], "^[^>]+", "")
Quote:
I couldn't find hide nor hair about just CALLING a function in lua
Same as in many languages:
function foo (bar)
print (bar)
end -- function foo
foo (42) --> call foo
You use the function name and put the arguments after it in parentheses. If there are no arguments you still use the parentheses, eg.
Also, if you have an assignment it works like this:
a = foo --> function foo is copied into 'a'
a () --> call 'a' (which effectively calls foo)
a = foo () --> foo is called, and the result of the call copied into 'a'
Quote:
Slight issue, not exactly critical but ANSI styles aren't moving over.
The styles can't be directly output using ColourTell, however you can use NoteStyle at the start of each sequence to change the style.
You can easily do that by adding one line:
if w then -- if present
for _, v in ipairs (styles) do
w:NoteStyle (v.style) --> change to the appropriate style
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
w:Note ("") -- wrap up line
end -- world found
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #18 on Sun 28 Jan 2018 (UTC) Amended on Sun 28 Jan 2018 12:14 AM (UTC) by Fevix
|
| Message
|
Nick Gammon said:You would need to identify how many style runs it takes (ie. are there multiple colours there?). If it is always in the first style run you could modify that before looping and sending the styles. eg.
styles [1] = string.gsub (styles [1], "^[^>]+", "")
Yes, the whole prefix is always the same color (In my case I just leave it the default white, and I confirmed by adding a debug line "print(v.text)" into the loop and observint the output, the first style in each line is always the prefix and the space) This would go in the for/do loop? Or before it to change the first style before it enters the loop?
[EDIT] I just tried both places and it gave me this error:
[string "Plugin"]:23: bad argument #1 to 'gsub' (string expected, got table)
stack traceback:
[C]: in function 'gsub'
[string "Plugin"]:23: in function <[string "Plugin"]:3>
I inserted a similar debug line ("print(styles [1])") just before the loop and got this:
-----
Nick Gammon said:The styles can't be directly output using ColourTell, however you can use NoteStyle at the start of each sequence to change the style.
(function=NoteStyle)
You can easily do that by adding one line:
if w then -- if present
for _, v in ipairs (styles) do
w:NoteStyle (v.style) --> change to the appropriate style
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
w:Note ("") -- wrap up line
end -- world found
Thanks! I'll try this! | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #19 on Sun 28 Jan 2018 12:13 AM (UTC) |
| Message
|
Fevix said:
Or before it to change the first style before it enters the loop?
Before the loop. If it is in the first style, and that is all the first style has in it, just delete the style:
table.remove (styles, 1) -- remove first style run
(Before the loop). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #20 on Sun 28 Jan 2018 12:19 AM (UTC) Amended on Sun 28 Jan 2018 12:29 AM (UTC) by Fevix
|
| Message
| That last one only works when the style changes right after the prefix. It'll remove the entire line if there's no style changes anywhere.
Again, this change isn't critical and I'm perfectly fine without it.
Could we make a script for the sub-windows that does this? Every line coming in WILL have the prefix (The line doesn't get sent unless it does) so we can just search it for the first instance of "> " and erase that and anything before it. | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #21 on Sun 28 Jan 2018 01:39 AM (UTC) Amended on Sun 28 Jan 2018 01:55 AM (UTC) by Fevix
|
| Message
| Okay I'm lost. Suddenly I'm getting errors:
Trigger function "chattrigger" not found or had a previous error.
But no plugin currently loaded even has the word "chattrigger" in it.
How can I see all currently loaded files? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #22 on Sun 28 Jan 2018 01:49 AM (UTC) |
| Message
| | Yes, but does one of your triggers have that word? Try turning on Trace. Game menu -> Trace |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #23 on Sun 28 Jan 2018 01:57 AM (UTC) |
| Message
| None of the plugins visible on EITHER window (main or sub) have the word "chattrigger" anywhere in the file (Opened it up in ST3 and searched, even searched the entire plugins directory for it, no match)
Trace output:
TRACE: Matched trigger "Rylami> *"
TRACE: Matched trigger "Rylami> "
Trigger function "chattrigger" not found or had a previous error.
TRACE: Executing trigger script "redirect"
This doesn't help me at all. | | Top |
|
| Posted by
| Fevix
(15 posts) Bio
|
| Date
| Reply #24 on Sun 28 Jan 2018 01:59 AM (UTC) |
| Message
| I forgot that when installing the first one I added triggers to the main world file. That's what's calling this.
Sorry for forgetting that. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #25 on Sun 28 Jan 2018 03:40 AM (UTC) Amended on Sun 28 Jan 2018 03:41 AM (UTC) by Nick Gammon
|
| Message
|
Fevix said:
Trace output:
TRACE: Matched trigger "Rylami> *"
TRACE: Matched trigger "Rylami> "
Trigger function "chattrigger" not found or had a previous error.
TRACE: Executing trigger script "redirect"
This doesn't help me at all.
Actually:
- Two triggers matched (and they are different). That is a clue.
- The second one caused the error message but not the first
Another clue would have been to disable all your plugins and see if it still happened. (I had guessed you had a rogue trigger in your mail world file, as you said that the trigger was not in the plugin).
Had you done that, it would have confirmed the issue was somewhere other than the plugins. And where else could that be?
(I know you worked it out, but I am showing the debugging process). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
78,573 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top