User Tools

Site Tools


4rpl:commands:setmsgbutton

Index
Messaging

:!: Available in version 2.3.2 and later.

SetMSGButton

SetMSGButton(<-slot <-enabled <-text <-color <-msgChannel <-msgText)

Description

Sets the state of a MSG Button. MSG Buttons appear on the left of the display and to the right of the unit build pane. Up to 12 MSG buttons are supported. Each MSG button will send a 4rpl message (same as SendMSG) when clicked if the msgChannel and msgText are set.

slot
The slot number for the button. The slots range 0 to 11 inclusive.
enabled
A Boolean indicating if the button is visible. All buttons are disabled by default.
text
The text to appear on the button. Keep it short. It will wrap and the button height will stretch to accommodate the text. This has access to all of CW4's text formatting.
color
The background color of the button, expressed as a V4 vector. Each of the 4 fields is a floating-point value between 0 (zero) and 1 (one) indicating, respectively, the Red, Green, Blue and Alpha component values. Numbers larger than 1 are treated as 1.
msgChannel
The MSG channel to send the message on when clicked.
msgText
The string to send to the MSG channel. You must provide a non-empty string, otherwise the message will not be sent.

MSG buttons persist across save/load. So you can set the MSG buttons once from script and they will be present for the rest of a game, even across saves.

Examples

:once 
   RegisterForMSG("TestChannel" "MessageCallback")
   SetMSGButton(0 true "Thingy 0" V4(1 1 1 1) "TestChannel" "Hello From Thingy0")
   SetMSGButton(5 true LF "<size=125%><color=green>Thingy 5" LF " " concat concat concat V4(1 1 0 1) "TestChannel" "Hello From Thingy5")
 
:MessageCallback
   traceallsp("Message Received: " <-_DATA)

Index

4rpl/commands/setmsgbutton.txt · Last modified: 2024/11/10 00:20 by Vertu