Discourse Frotz 🧙

¡Guau, un nuevo plugin! :tada: Este es un poco menos serio, aunque. :video_game:

Discourse Frotz


Ya no es necesario mencionar al bot (@) en cada paso. Una vez en juego, simplemente responde a él.

Repositorio de Git: GitHub - merefield/discourse-frotz: A plugin that uses Frotz to give you an interactive fiction experience on your Discourse forum · GitHub

¿Qué es?

Es un ‘bot’ con el que puedes jugar a ficción interactiva, también conocida como juegos de aventuras de texto clásicos, en tu foro de Discourse. Es esencialmente un adaptador para el intérprete Z-machine estándar y asombroso llamado ‘frotz’ en David Griffith / frotz · GitLab

Cómo usarlo

La configuración agrega dos juegos; puedes agregar más en la configuración.

Cada entrada contiene un título y el nombre del archivo de la historia.

Para iniciar la interacción, necesitas mencionar al bot configurado en la configuración. Después de eso, responder a una de sus publicaciones es suficiente.

Para listar los juegos disponibles, primero debes mencionar al bot y preguntar:

@mybot list games

Esto te dará el rango de opciones.

Para iniciar un juego, escribe:

start game x sustituyendo x por el número de opción.

Si deseas cambiar a otro juego, puedes hacerlo; el plugin guarda tu progreso en cada movimiento, por lo que puedes volver a la primera historia en cualquier momento. El plugin mantiene una partida guardada para cada historia para cada usuario que la prueba.

Para continuar un juego existente, escribe:

continue game x sustituyendo x por el número de opción.

NB: Una reconstrucción completa destruirá todos los archivos de guardado. Este es un compromiso necesario.

¿Cómo juego un juego de FI?

Muchos “Meta” habrán crecido con estas cosas. Para aquellos menos familiarizados, consulta esta hoja de trucos: Play Some Interactive Fiction

Configuración

Crear el usuario del bot

(Disculpas, ¡automatizar esto está en mi lista!)

En una sesión ssh, ingresa a tu contenedor y a la consola de rails:

./launcher enter app
rails c

Luego haz esto:

u = User.create!(username: "Frotz", name: "FrotzBot", id:-5, email: "not@really.valid")
u.activate

Tu nuevo bot estará entonces disponible para configurarse en la interfaz de usuario. Ve a la configuración del usuario en la interfaz de usuario a través del botón de administrador y desactiva todas las notificaciones por correo electrónico. Actualiza el avatar a tu gusto.

Instalar Discourse Frotz

Actualizar tu app.yml

Esto es un poco más invasivo que un plugin habitual.

Agrega esto a app.yml:

hooks:
  after_code:
    - exec:
        cd: $home
        cmd:
          - git clone https://gitlab.com/DavidGriffith/frotz
    - exec:
        cd: $home/frotz
        cmd:
          - make dfrotz
    - exec:
        cd: $home/frotz
        cmd:
          - mkdir savegames
    - exec:
        cd: $home/frotz
        cmd:
          - mkdir stories
    - exec:
        cd: $home/frotz/stories
        cmd:
          - wget -O zork1.z3 https://eblong.com/infocom/gamefiles/zork1-r119-s880429.z3
    - exec:
        cd: $home/frotz/stories
        cmd:
          - wget --no-check-certificate http://www.douglasadams.com/creations/hhgg.z3
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/merefield/discourse-frotz

antes de tus otras entradas de plugins.

Ahora también necesitas agregar el plugin Discourse BBCode!!

Reconstruye con el habitual ./launcher rebuild app

Ahora ve a la configuración del plugin y selecciona el usuario del bot que agregaste anteriormente:

image

Historias

Notarás que he incluido un par de historias. Puedes encontrar más en https://ifdb.tads.org/. Sin embargo, ¡cuidado con los límites de velocidad aquí! Obtener demasiadas historias del mismo lugar puede causar un error.

También ten en cuenta que las historias no están alojadas en servidores protegidos con HTTPS (tut tut).

Si insistes en cargar más, agréguelas a app.yml. También podrías agregarlas manualmente desde el símbolo del sistema, pero ten en cuenta que estas se borrarán en la próxima reconstrucción completa.

Habilitar FrotzBot para mensajes privados (se recomienda precaución)

Permite a los usuarios jugar en privado, pero el uso será menos transparente. Si tienes un servidor lo suficientemente grande, esto podría no ser un problema para ti. En cualquier caso, ten en cuenta las implicaciones para la capacidad. Como alternativa, anima a los usuarios a jugar en una Categoría designada.

image
por defecto: OFF

Si no está habilitado allí, el usuario recibirá un mensaje educado:

Restringir FrotzBot por Categoría

Puedes restringir el bot a una (lista de) Categoría para evitar llenar otras áreas:

¡Atajos de teclado!

Esto es realmente importante para mejorar la experiencia de ‘juego’. Y realmente solo necesitas recordar dos:

  • Shift-R para responder al bot

  • Ctrl-Enter para enviar tu siguiente movimiento

Limitaciones y consideraciones

No todos los formatos de historia y juegos son compatibles aún, ni es probable que lo sean. Hay muchos juegos que no funcionan debido a la naturaleza de sus protocolos de llamada y respuesta. Debido a la forma en que interactuamos publicación por publicación, tenemos que pedirle a Frotz que guarde el estado después de cada movimiento. Si un paso del juego no conduce a una indicación en la que el sistema pueda guardar (ignorando las indicaciones de “presiona cualquier tecla” o “Más” que deberían manejarse), entonces la historia no funcionará. Por ejemplo, en Act of Murder (¡gran juego!), la mujer en la puerta pregunta si eres un policía. Desafortunadamente, este es un estado del juego que no se puede guardar, por lo que falla este requisito y no veo una manera de hacer que funcione.

NB: El modo de lista de correo es un desastre con esto, así que asegúrate de que esto no sea algo que uses antes de intentar usar este plugin.

Podría argumentarse que es un poco derrochador de recursos del foro, ya que requiere al menos dos publicaciones por cada ‘movimiento’. Obviamente, a menudo es más apropiado jugar este tipo de juegos usando una interfaz de chat en lugar de un foro, pero podrías argumentar que esto podría usarse para crear guías de juego, ¿verdad? :wink:

Para una solución menos invasiva, considera: Turning a topic into interactive fiction ;)

Comentarios

¡Todos los comentarios son bienvenidos!

Créditos

Este plugin explota David Griffith / frotz · GitLab, el intérprete Z de Frotz, que es clonado y ‘compilado’ por el script de configuración.

Gracias a @P16 por permitirme usar extractos de código de un chatbot de código cerrado en el que trabajamos juntos.

45 Me gusta

Wooah, back again!

New Feature-rettes

Enable FrotzBot for private messages (at your peril! :wink: )

Allows users to play in private, but usage will be less transparent. If you have a big enough server this may not be an issue for you.

image
default: OFF

If (s)he is not enabled there, the user will get a polite message:

Restrict to a list of Categories, or allow all:


default: ON for all Categories

10 Me gusta

Hi Robert! Thank you, I really like this plugin !
I tried to install it on dev environment (without docker) and my system asked for the ncursesw lib when making dfrotz, after installing that it worked, will it be the case with a prod env with docker?

1 me gusta

I tested on Production and building on Docker (to my surpirse) worked out of the box. Feel free to deploy to a Production instance and let me know how you get on.

Glad you like it!!

2 Me gusta

For those like me, who might loose their last few hairs about that:

hhgg.z3,9,7,3
that’s :

  story_header_lines = 9
  story_load_lines = 7
  story_save_lines = 3

and now, how to adapt it… :sweat_smile:, that’s an adventure inside an adventure…!

1 me gusta

I’m currently working with the maintainer of Frotz to see if we can do away with those. It’s an approach I ported from restful-Frotz but hardly perfect :slight_smile:

1 me gusta

Yes ! found it !
kheper.z8,20,15,4 almost works
for this one :

:smiley:

it’s nothing, but there is something weird

) Line-type display OFF
Compression mode MAX, hiding top 0 lines

is displayed once by Pause() with

[Pause notNeeded;
@read_char 1 notNeeded;
rtrue;
];

1 me gusta

Ha, yeah, there are lots of quirks and a considerable amount of variety in the stories. I cannot promise to support all.

Right now my focus is on:

  1. simplifying code
  2. making the code more secure
  3. adding formatting where pragmatic.

#3 is surprisingly hard.

1 me gusta

I’ve pushed some improvements to a feature branch:

This does away with the silly suppression settings, introduces translation to BBCode to support formatting and colour, leverages the Dumb Frotz command line options better, obviates the need to write to a text stream and squashes a vulnerability.

This branch requires the official BBCode plugin to be installed.

I’m still experimenting with it. Feel free to do so too.

I’ll probably merge after some significant trials.

1 me gusta

Does the plugin need the whole frotz repo clone or does it just need $home/frotz/dfrotz to exist? Because I’d rather just compile it once and save the binary between rebuilds.

Not sure why you would care? The resources we are talking about are comparatively tiny. (6MB for the entire repo post make versus Gigabytes for the forum?). It clones the whole repo, then just makes dfrotz. Perhaps that is slightly wasteful, but the simplicity and repeatability is more important I feel. I could go into greater detail and perform a sparse clone, but that would make the build script more complex and less robust. Would it be worth it? Feel free to suggest an optimisation. This is all building inside the container, so will get cleaned whenever the container does.

I’m just trying to optimize for my tiny server, not asking you to change the general install.

1 me gusta

This is a really cool plugin! This reminds me of a “classic” computer game that was created years ago(I forgot the name).

3 Me gusta

It’s a great suggestion for a future optimisation if I can keep it simple and robust. Thanks!

1 me gusta

Yes there are many playable classics. More via the link in the OP.

2 Me gusta

BIG update: :tada: :kiwi_fruit:

(this has taken months of occasional background work and coordination with Frotz team).

Introducing full colour and monospaced formatting for stories

This big update comes with a bunch of improvements:

  • ADDED colour formatting and monospaced text support
  • IMPROVED simplified settings: no longer requires calibration of header and footer, just the desired title and story file, whoop!
  • IMPROVED uses Open3 gem for system commands, reducing risk of abuse/vulnerabilities.
  • IMPROVED internal interaction with command line to remove need for stream files, now copes with more/press any key prompts

Now REQUIRES the Discourse BBCode plugin!!

This required the collaboration of the maintainer of Frotz, David Griffiths and one of the very active members of that community, Borg323 who wrote the BBCode extensions against the BBCode Discourse standard. Many many thanks to them! We had to get a bit creative to get the monospaced text stuff to work, but the solution is really great!

Some examples of the new formatting (I’ve not fully tested these stories, these are just examples of formatting)

and notice the coloured compass here:

KNOWN ISSUES: There are loads of games that don’t work because of the nature of their call and response protocols. If one step of the game doesn’t lead you to a prompt at which you can save (ignoring press any key or More prompts which should be handled), then the story won’t work. e.g. in Act of Murder (great game!) the lady at the door asks if you are a policeman. Unfortunately this is a state of the game that’s unsaveable so fails this requirement and I can’t see a way we would get that to work.

There are probably games that are now compatible with Discourse Frotz that weren’t before … please experiment but note the limitation above!

Let me know if you have any issues getting this to work and I’ll refine the instructions as required.

8 Me gusta

A reminder that you can use keyboard shortcuts to improve your experience with this plugin:

  • Shift-R to reply to the bot

  • Ctrl-Enter to submit your next move

(Standard out of the box keyboard shortcuts).

5 Me gusta

Hi Robert !
finally had time to go further, so far so good, it worked right out of the box in prod env :+1:

Weirdly frotz is not able to respond in private messages unless I also set it in any category :thinking:
Next step : to play :grinning_face_with_smiling_eyes:

1 me gusta

Thanks for the report!

I’ve gone ahead and fixed that: FIX: behaviour of private messages playing permission setting · merefield/discourse-frotz@34b022e · GitHub

NTS: must add some unit tests!

2 Me gusta

I tried to add :grin: in a source,

it’s going to be fun !

1 me gusta