Register forum user name Search FAQ

Gammon Forum

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 ➜ Scrolling text window plugin

Scrolling text window plugin

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Solara   USA  (59 posts)  Bio
Date Wed 17 Jul 2019 12:56 AM (UTC)

Amended on Wed 17 Jul 2019 01:22 AM (UTC) by Solara

Message
I am trying to get the scrolling text window plugin to work. Nick posted it here: https://www.gammon.com.au/forum/?id=13916

Just experimenting with it, I could NOT get the text to wrap at all. Everything else works as is.

Quote:
require "serialize"

ScrollingPlugin = "a160a0dc029b28fc970a935d"

width = 200
height = 400

CallPlugin (ScrollingPlugin, "SetSize" , width, height)

CallPlugin (ScrollingPlugin, "SetTitle", "Tells")

lines = { }
for x = 1, 300 do
lines [x] = string.format ("Line Line Line Line End %x", x)
end -- for

CallPlugin (ScrollingPlugin, "SetText", serialize.save_simple (lines))


Replacing
CallPlugin (ScrollingPlugin, "SetText", serialize.save_simple (lines))
with
CallPlugin ("ScrollingPlugin, "AddLine", serialize.save_simple (lines), wrap)
does not wrap the line either. How do I get this plugin to wrap the text?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 17 Jul 2019 07:43 AM (UTC)
Message
From the plugin source:


-- if "wrap" is true then long lines are split at the closest space at
-- the RH side of the window (possibly inserting multiple lines) otherwise
-- the line is inserted "as is" possibly truncating it


So you don't put the word "wrap" there like you did, you make it true, ie.


CallPlugin ("ScrollingPlugin, "AddLine", serialize.save_simple (lines), true)


The variable "wrap", if not defined, will be nil and thus considered false.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #2 on Wed 17 Jul 2019 02:03 PM (UTC)

Amended on Wed 17 Jul 2019 09:35 PM (UTC) by Nick Gammon

Message
Ahh, thanks for the fast reponse Nick. That works nicely.

Now I'm trying to clean up the output window a bit and have another question.

The output looks like this when you do an AddLine:

{
  [1] = "the message goes
here",
  }
{
  [1] = "this is another
line added",
  }


I'm looking through the serialize.lua file and I can't figure out how to remove the leading and ending {} to make the display a bit more compact/neater. I would also like to remove the [1] and indentation before it also. Where is this found in the Serialize.Lua file?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 17 Jul 2019 09:40 PM (UTC)
Message
The indenting is done here:


  local iname = string.rep (" ", indent) .. name -- indented name


And here for save_simple:


table.insert (out, string.rep (" ", indent))


So you can replace "indent" by 0 (or remove the string.rep part) to not indent it.

So in the first case it would become:


  local iname = name


And in the second case just omit that line that outputs the indent.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #4 on Wed 17 Jul 2019 10:07 PM (UTC)

Amended on Wed 17 Jul 2019 11:53 PM (UTC) by Solara

Message
Hmm I changed

local iname = string.rep (" ", indent) .. name -- indented name

to
local iname = name

and I still got the indents. And I also replaced the indent in two places with 0, but that didn't change anything. I also removed the lines completely and that did not change anything either.
table.insert (out, string.rep (" ", indent))

And I'm still getting extra lines at the beginning with { and then another line with } for the end.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 17 Jul 2019 10:48 PM (UTC)
Message
Did you reload the plugin? Serialize.lua will stay loaded until the plugin is reloaded.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #6 on Wed 17 Jul 2019 10:50 PM (UTC)
Message
Yeah I reinstall scrolling window plugin and also restarted mushclient.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 17 Jul 2019 11:23 PM (UTC)
Message
Well I don't understand that, as it is (I think) the place where the indenting is done.

Does it matter? It is just internal, you don't actually see the serialized stuff.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #8 on Wed 17 Jul 2019 11:55 PM (UTC)

Amended on Wed 17 Jul 2019 11:56 PM (UTC) by Solara

Message
Well the output window shows it like this:

{
  [1] = "the message goes
here",
  }
{
  [1] = "this is another
line added",
  }
and I"m trying to make it neater and more compact. That's 2 empty lines for every message I get. I'm hoping to get it to look like this:

"the message goes
here"

"this is another
line added"
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #9 on Thu 18 Jul 2019 12:18 AM (UTC)

Amended on Thu 18 Jul 2019 12:23 AM (UTC) by Solara

Message
Okay seems I was making changes to serialize.lua that was in a different directory (copied over so it was in same directory as scrolling_windows). Dumb mistake. So editing the serialize.lua under the lua folder fixed the indent issue. So substituting the indent with 0 and using local iname = name did remove the indent.

My output window now looks like this:
{
[1] = "person: testing
testing 1 2 3 4 5 6 7
8",
}


Is there a way now to remove the leading, ending brackets and the entire line they take up?

EDIT: So I was able to remove the ending bracket (but not the now empty line) by changing this line:
    table.insert (out, string.rep (" ", indent) .. "}")
to
    table.insert (out, string.rep (" ", indent)")
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #10 on Thu 18 Jul 2019 12:51 AM (UTC)

Amended on Thu 18 Jul 2019 02:07 AM (UTC) by Solara

Message
Okay I was able to remove the leading/ending {} and the [1] and indents.

Changed this:
local iname = string.rep (" ", indent) .. name  -->  local iname = name

table.insert (out, iname .. " = {}")  -->  table.insert (out, iname)

table.insert (out, "{\n")  -->  table.insert (out, "")

table.insert (out, string.rep (" ", indent))  -->  table.insert (out, string.rep (" ", 0))

table.insert (out, "[" .. basicSerialize (k) .. "] = ")  -->  table.insert (out, "")


Removed:
table.insert (out, string.rep (" ", indent) .. "}")


FYI: Not sure which line that I changed is critical for SetText but that routine does not work anymore and gives an error that the text was not serialized correctly. AddLine still works fine, and since that's all I use, I'm fine with SetText not working. But I have no idea which line caused it to break.

Edit 2:
Changing these lines caused SetText to break:
table.insert (out, string.rep (" ", indent) .. "}")  --> table.insert (out, string.rep (" ", 0))
table.insert (out, "{\n")  -->  table.insert (out, "")
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #11 on Thu 18 Jul 2019 06:31 AM (UTC)
Message
Solara said:

Well the output window shows it like this:

{
  [1] = "the message goes
here",
  }
{
  [1] = "this is another
line added",
  }
and I"m trying to make it neater and more compact. That's 2 empty lines for every message I get. I'm hoping to get it to look like this:

"the message goes
here"

"this is another
line added"



What? It looks like you are serializing it twice. Surely the output window (that the user sees) should not be showing Lua variables at all?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #12 on Thu 18 Jul 2019 06:32 AM (UTC)

Amended on Thu 18 Jul 2019 06:33 AM (UTC) by Nick Gammon

Message
Sometimes you see on web pages the words "fish & chips" appearing as "fish & chips".

That usually means that they ran the "convert ampersands into HTML" function twice on the same string.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #13 on Thu 18 Jul 2019 06:39 AM (UTC)
Message

The output looks like this when you do an AddLine:

This is starting to look like something for http://snippets-r-us.com/

I think I am trying to solve the wrong problem for you because you didn’t fully specify what you meant by “the output”.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #14 on Sat 20 Jul 2019 03:05 AM (UTC)
Message
My original intention was to get the Scrolling Window plugin working so it would scroll. That was fixed when you pointed out that "CallPlugin ("ScrollingPlugin, "AddLine", serialize.save_simple (lines), wrap)" should be "CallPlugin ("ScrollingPlugin, "AddLine", serialize.save_simple (lines), true)"

Then I wanted to clean up the appearance of the actual window since the output was putting in leading and ending {} and extra line returns, and also having [1] appear with every AddLine.

You pointed me towards the area of serialize.lua that dealt with it, and I was able to remove the {}, [1] and extra line returns to condense the actual scrolling window. It works nicely. But I seemed to have broken the SetText subroutine by changing 2 of those lines. I suspect the brackets {} are important for the SetText subroutine, though the AddLine works perfectly fine without it.

In any case it works well for me now thanks.
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.


41,902 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.