Author Topic: [Release] Send-Message-Alt Lua Sexps  (Read 519 times)

0 Members and 1 Guest are viewing this topic.

Offline mjn.mixael

  • Cutscene Master
  • Moderator
  • 212
  • Chopped liver
    • Steam
    • Twitter
[Release] Send-Message-Alt Lua Sexps
Here is, in my opinion, an absolute life saving script we use heavily in BtA2. Written by Xenocartographer, this script adds several sexps to make sending messages half the chore they used to be while adding a host of features to make the whole messaging system many times more powerful. The core of what they can do can be distilled down into two main things. 1) It gets most of the message data from the message itself, so send-message-list-alt takes only two arguments per message rather than four. 2) It has built-in operators to choose between messages based on the ship being present and/or other conditions you may want to set.

For example, I would use set-message-alias to set Alpha 2 alias to A2, Alpha 3 to A3, and Colossus to Col. I can then do a send-message-list-alt like this. Message sender is grabbed from the message name and priority is always Normal. NOTE: Delay here now refers to the current message rather than the previous message's length, which is a change from the built-in send-message-list. So here, A2: Hello has a message length of 5000ms.


Alternatively, I can have the list automatically choose between ships who are still in the mission. Here, both Alpha 2 and Alpha 3 send a similar message. Alpha 3 has a negative duration which tells the script to pick between it and the previous message with matching duration (in positive).


Arguably send-message-alt is the most powerful sexp here. It accepts an argument to randomize the choice or do it in order, then it takes a message name followed by a boolean to consider if the message is valid to send. It will consider all of the booleans and if the ships are valid and then choose one message to send. Again, the sender is taken from the message name and the priority is Normal.



Sexps included are below. Change -> Messages and Personas

send-message-alt
  • A convenience alternative to send-message. This operator is intended to alleviate the annoyance of writing messages from potentially destructible ships. It accepts a list of "message alternatives", each of which can have different conditions during which it might be played. This operator will choose a message who's condition is valid and play it, if any are valid. If a message's source is a ship, then that ship being present is automatically part of its condition, and does not need to be checked manually.
send-message-list-alt
  • A convenience alternative to send-message-list. This operator is intended to alleviate the annoyance of writing messages from potentially destructible ships.
send-message-chain-alt
  • Like send-message-list-alt, but with a cancellation event like send-message-chain.
set-message-alias
  • send-message-alt and related operators use a convention where a message's source is embedded in its message. This operator allows a shorter alias to used for a ship. Note that this operator will not work properly if the ship is not presently in the mission. To register an alias for a non-ship source, use set-freetext-message-alias.
set-message-freetext-alias
  • send-message-alt and related operators use a convention where a message's source is embedded in its message. This operator allows a shorter alias to used for a ship.
get-last-alt-message-source
  • Write the sender of the last message that was sent with send-message-alt, send-message-list-alt, or send-message-chain-alt. This can be useful to check the result when one of those operators dynamically picks a message. Writes to a string variable.


« Last Edit: November 14, 2021, 03:45:23 pm by mjn.mixael »
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: [Release] Send-Message-Alt Lua Sexps
Pardon me if I fail to understand, but this is just a convience script and does not add a functionality which currently is provided by just making elaborate events?

Because I've done several of the thing described with nested whens and variables (after stopping to use send-message-list since milisecond delays for is-event-true and event chains are niw possible, effecively making send-message-list redundant)

The reduction in required inputs sounds neat...
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline mjn.mixael

  • Cutscene Master
  • Moderator
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Release] Send-Message-Alt Lua Sexps
I suppose you can distill it down to that if you want. No this does not add new functionality to messages. Sending a message is still sending a message.

Sure you can do elaborate events and string messages all together with chains if you'd like. However, these LUA SEXPs make it much easier to do all of that. Not only easier, but way faster because things like checking for a ship being in-mission are built-in. It also puts sending a unique message from a random source right at your fingertips without having to fudge with variables or argument lists. That is all on top of being able to do message-list or message-chain with only two arguments each.

Additionally, let's say you want to change a message source? Now you only have to do that in the message itself. No need to adjust the actual sexp because it gets that data from the message.

These SEXPs allow the FREDer to work much, much faster and more efficiently when it comes to messages.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: [Release] Send-Message-Alt Lua Sexps
Thanks for the clarification.

I am again thinking a lot about more elaborate dialogue between characters, with multiple conditions (e.g. which campaign branch this is in, tracking if a character was deployed for a certain mission & if a "relationship metric" has a minimum value), so you can alter progression of subplots and such through e.g. loadout choices (use whats already there and all that)
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

  

Offline mjn.mixael

  • Cutscene Master
  • Moderator
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Release] Send-Message-Alt Lua Sexps
These sexps will make that idea much easier to implement.  :nod:

Specifically send-message-alt. You can list multiple messages each with their own condition. The sexp chooses the first one (or you can set it to randomly choose one) to match all conditions and sends that message.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.