Forced scroll option?

Ancient
Posts: 6
Joined: Tue Jul 09, 2024 10:31 am

Forced scroll option?

Post by Ancient »

Hi,

I've been using Mudlet for a while now, it is a very versatile client, but one thing is missing that's making it hard to keep up with what's happening while playing: scrolling text.

As it is now, no matter how much text comes in from the mud, the whole block of text just appears at once after the previous prompt, so it sometimes is very hard to notice that something actually happened, as the eyes did not register any movement (at least this old geezer's eyes), and I just keep staring at the screen waiting for a response from the mud. This is true with rooms with similar/same descriptions, e.g. when moving down a road or something, but following combat rounds can be challenging as well, as the number of lines vary round by round and I lose track of where the previous prompt "jumped".

In light of this, would it be possible to add a forced scroll option to Mudlet, where the user could specify a wait time after each (new)line from the mud in milliseconds (ms), before actually outputting the next line of text from the mud? I.e. the desired result would be scrolling (upwards moving) lines of text, by which I mean it would scroll up line by line (not smoothly pixel by pixel, that would be weird).

I have no idea how long the pause would have to be for the result to look like scrolling text, but say e.g. 10ms/line would mean 200ms = 0.2s for 20 lines of text, which doesn't seem that bad given normal reading / reaction times. I realize professional PKers shudder at the thought of adding artificial lag to a mud, but that's why the default forced scroll setting would be 0ms (with a recommended value mentioned to achieve the scrolling effect).

I guess if technically possible, the wait time should only apply when more than 1 line of text comes in (i.e. no wait time added for pressing enter to just get an updated prompt) - though this is likely negligible, if we are talking about a few (?) milliseconds.

Thanks for consideration!

Zooka
Posts: 14
Joined: Thu May 04, 2023 11:44 pm

Re: Forced scroll option?

Post by Zooka »

Hey Ancient, I'd enjoy working on something with you for this.

But perhaps in the mean time you could try turning on the timestamps (lower right hand corner, "I" symbol), at least then you be able to discern changes in the incoming text?

Talk soon.

Zooka
Posts: 14
Joined: Thu May 04, 2023 11:44 pm

Re: Forced scroll option?

Post by Zooka »

Hey Ancient,

I've got a version available at https://zookaongit.github.io/mudlet-pac ... g.mpackage

Download it and install using the Package Manager under Toolbox (Alt+O).

You can change the delay/timer in the script editor timers window to a value that you're comfortable with (default to 0.1 seconds) and turn it on or off by issuing;

Code: Select all

> delay on
> delay off
Let me know how you go!
Last edited by Zooka on Wed Jul 10, 2024 4:26 pm, edited 1 time in total.

Ancient
Posts: 6
Joined: Tue Jul 09, 2024 10:31 am

Re: Forced scroll option?

Post by Ancient »

Hi,

Thanks, though I was thinking this as a built-in option in the client, so that all the basic stuff such as triggers would work normally (which is essential, really). But I hope to be able to at least test the package some time (when I make a new character) to see what might be a suitable delay for the scrolling effect.

The timestamps might help a bit, though not really what I'm looking for with this, but I'll try that too and see how it looks/feels.

Zooka
Posts: 14
Joined: Thu May 04, 2023 11:44 pm

Re: Forced scroll option?

Post by Zooka »

It's all fixed now and works with triggers. You can get the latest at the above link.

Optional packages like this are designed for extending core functionality, because not everyone wants or needs all those features so it's best not to bloat the core program.

Hope this helps.

Ancient
Posts: 6
Joined: Tue Jul 09, 2024 10:31 am

Re: Forced scroll option?

Post by Ancient »

Ok, I played around with it a bit, but it seems buggy, as pretty soon an error message appears "ERROR: invalid line numbe" and no more prompts come in from the mud.

Also the default 0.1s seems way too slow =), I tried a setting of 0.01s, but unsure if it actually took effect before the error messages started appearing.

Here's a log snippet of setting the delay and then setting it on (seemed that maybe the delay has to be off, when you try to set it?):
[Exits: down]
The Academy Prefect is here, welcoming and directing new students.
civilized <100%hp 100%m 100%mv 1750tnl (50.00%) 8 AM>
delay 0.01
Queue delay set to 0.01 seconds.

l
The Great Portal
You have decided to become a hero of Thera. A legend, as it were. You will
become one of the greats, one of the adventurers. Warrior, shadow, cleric,
musician or mage, you know the world has more to offer you than the average
life you lived before this. You cast away your old life and embrace a new
destiny of greatness. Bags packed and ready for the destiny before you, the
first step is to learn how to do it. You arrive at the Great Academy of
Thera. Every legend, every great mortal of both good and evil made their
start here, and you could be the next one emblazoned on the history books.
A portal swirls beneath your feet, leading into the fabled Academy.

[Exits: down]
The Academy Prefect is here, welcoming and directing new students.
civilized <100%hp 100%m 100%mv 1750tnl (50.00%) 8 AM>
delay on
Syntax: delay <seconds>

Recommended values:
0.1 - notes, descriptions and roles
1 - pen
5+ - storytelling

Bear in mind there is no stopping a queue once it begins. Use with caution.

Delayed scrolling ON.
l
civilized <100%hp 100%m 100%mv 1750tnl (50.00%) 9 AM>
The Great Portal
You have decided to become a hero of Thera. A legend, as it were. You will
become one of the greats, one of the adventurers. Warrior, shadow, cleric,
musician or mage, you know the world has more to offer you than the average
life you lived before this. You cast away your old life and embrace a new
destiny of greatness. Bags packed and ready for the destiny before you, the
first step is to learn how to do it. You arrive at the Great Academy of
Thera. Every legend, every great mortal of both good and evil made their
start here, and you could be the next one emblazoned on the history books.
A portal swirls beneath your feet, leading into the fabled Academy.

[Exits: down]
The Academy Prefect is here, welcoming and directing new students.
ERROR: invalid line numbe

Kerchunk
Posts: 1
Joined: Tue Nov 28, 2023 6:10 am

Re: Forced scroll option?

Post by Kerchunk »

Hey Ancient,

I know this isn't exactly the solution you proposed, but if I'm understanding the essence of your request an alternative approach might involve some kind of visual indication of when your client receives new output from the MUD. This is probably less elegant than the scrolling-text effect you're after, but it might also prove a little simpler to get working and maybe less finicky.

If you run the script below, you should see an example of what I mean. It will add a bar to the bottom-left of your main client window (near your command line) which will fill up any time you get output from the MUD then slowly deplete as time passes with no new output eventually disappearing if you're not getting any new lines at all.

You may need to make room for the bar by adding some "Bottom border height" to your window in the settings menu of your profile on the "Main display" tab. At the top of the script are some values you can experiment with including size, position, color, etc.

If you like this solution at all and think it will help you, let me know - I can clean this script up a bit and make it easier to customize to your liking. I could also do something similar with different shapes, icons, or animations. Didn't want to spend too much time on it without getting some feedback.
Code: [show] | [select all] lua
-- Default size & position of the pulse bar; adjust as desired
local pulseH        = 8       -- Height of bar; increase for more visibility
local pulseW        = "50%"   -- Default bar width (number for pixels, string for percentage)
local pulseY        = -pulseH -- Need -pulseH to see the full height of the bar (otherwise its off-screen)
local pulseX        = 0       -- Left edge of the main window

local pulseDuration = 2       -- Duration of each pulse (how long before the bar disappears)
local pulseRate     = 0.01    -- How many times per second to decrement the pulse (lower values will animate more smoothly)
PulseDecrement      = 100 / (pulseDuration / pulseRate)

-- Percentage of the pulse which must be complete before a new pulse can replace it; 100 will prevent overlaps,
-- 0 will trigger a new pulse on every line of output from the MUD (can be quite jumpy/jittery)
Sensitivity         = 25

-- ID of the timer/trigger that create & decrement the pulse
PulseTimer          = PulseTimer or nil
PulseTrigger        = PulseTrigger or nil

-- The value itself (each pulse "fills" this to 100 before decrementing)
PulseValue          = 0

-- The "maximum" and "minimum" color for the pulse bar; by default the bar will interpolate between these two colors
PulseColorMax       = color_table["hot_pink"]
PulseColorMin       = color_table["ansi_black"]

-- If true, the color of the pulse will be interpolated between the min and max colors; otherwise
-- it will just be "on" or "off"
UseInterpolation    = true

-- Create the gauge object
PulseGauge          = Geyser.Gauge:new( {
  name        = "pulseRight",
  x           = pulseX,
  y           = pulseY,
  width       = pulseW,
  height      = pulseH,
  orientation = "horizontal",
} )

-- Initiate a pulse by setting PulseValue to 100 and starting a decrement timer; this is the function
-- that will be called when the "any line" trigger fires.
-- May kill/replace an existing pulse depending on the Sensitivity setting
function setPulse()
  -- Do not reset/set a new pulse if the current pulse is greater than the Sensitivity setting
  if PulseValue > Sensitivity then return end
  PulseValue = 100
  PulseGauge.front:setStyleSheet( f [[ background-color: {getPulseColor()}]] )
  PulseGauge:show()
  if PulseTimer then killTimer( PulseTimer ) end
  PulseTimer = tempTimer( pulseRate, [[decrementPulse()]], true )
end

-- Decrement the pulse bar until it disappears or gets replaced
function decrementPulse()
  if PulseValue > 0 then
    PulseValue = PulseValue - PulseDecrement
    PulseGauge.front:setStyleSheet( f [[ background-color: {getPulseColor()}]] )
    PulseGauge:setValue( PulseValue, 100 )
  else
    PulseGauge:hide()
    killTimer( PulseTimer )
  end
end

-- Define the getPulseColor() function depending on whether or not you want to use interpolation
if UseInterpolation then
  -- Calculate a linerally interpolated color between the min and max colors based on the current PulseValue
  function getPulseColor()
    local r1, g1, b1 = unpack( PulseColorMin )
    local r2, g2, b2 = unpack( PulseColorMax )
    local ratio = PulseValue / 100

    -- Calculate the interpolation based on the adjusted logic
    local r = math.floor( r1 + (r2 - r1) * ratio + 0.5 )
    local g = math.floor( g1 + (g2 - g1) * ratio + 0.5 )
    local b = math.floor( b1 + (b2 - b1) * ratio + 0.5 )

    return string.format( "rgb(%d, %d, %d)", r, g, b )
  end

  PulseGauge.back:setStyleSheet( f [[ background-color: rgb(0,0,0)]] )
else
  -- Return the maximum or minimum color based on the current PulseValue
  function getPulseColor()
    if PulseValue >= 1 then
      return string.format( "rgb(%d, %d, %d)", unpack( PulseColorMax ) )
    else
      return string.format( "rgb(%d, %d, %d)", unpack( PulseColorMin ) )
    end
  end

  PulseGauge.back:setStyleSheet( f [[ background-color: {getPulseColor()}]] )
end
-- Create the trigger to initiate a pulse on any line of output from the MUD

if PulseTrigger then killTrigger( PulseTrigger ) end
PulseTrigger = tempRegexTrigger( "^.*$", [[setPulse()]] )

Ancient
Posts: 6
Joined: Tue Jul 09, 2024 10:31 am

Re: Forced scroll option?

Post by Ancient »

Hi,

Yeah, not really what I'm looking for, though I suppose some kind of indication of new output from the mud might help - however, I could not even test it, since as a Mudlet newbie I don't know how to run a script, sorry! :oops: I tried pasting it (offline) into the script editor (no "run" button there) or making it an alias, but that didn't seem to do anything, either.

The code itself looked well commented, though, if I wanted to tweak something etc.

User avatar
SlySven
Posts: 1034
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Forced scroll option?

Post by SlySven »

You need to select the "Scripts" view by clicking on the relevant button on the main toolbar (or if you already have the editor open you can click the same button on the left in the editor. Then click the "Add Script" button and then copy and paste all of the code above in to the big box on the right hand side - and it would be useful to give it a name by entering that in the "Name:" field at the top - as soon as you save it the code runs (and it will do so again each time it is loaded with the profile) - if you want to remove it you could delete it and then save, close and then reload the profile (I am not sure if Zooka provides an on/off mechanism)!

Note that deactivating the script with the top left "Activate" button does not function like it might seem for "Scripts".
Screenshot_20240718_004044.png
As given it gives me a purple bar that gets to maximum every time it detects input but decreases and fades away over time without any further incoming text::
Screenshot_20240718_004332.png

Ancient
Posts: 6
Joined: Tue Jul 09, 2024 10:31 am

Re: Forced scroll option?

Post by Ancient »

Thanks, I thought scripts had to be called somewhere (trigger, alias...), I did not realize they automatically run by themselves. Anyway, I had done all that, but don't see the bar, I suppose it might be because the game GUI already has extra "windows/panels" at the bottom of the window above the input line?

Post Reply