Configuring CodeMessageCommand AKA CodeNames - RhythmLunatic/stepmania GitHub Wiki
Aka the 'easier' way of input handling in your screen.
CodeMessageCommand activates when you have the CodeNames section in metrics filled out and you've filled out the correct buttons.
Fun fact: These are called 'CodeSet' internally.
Step 1. Add it to metrics.ini
First add a CodeNames section listing all the codes you want. You can also have multiple codes with the same name by using = to set the name. Examples for both methods are provided.
Example 1: Regular button codes
In this example the below code is named GoFullMode
, then the button combination is listed in the metric CodeGoFullMode
.
# For Future Reference:
# @ = Holding
# - = In Conjuction With / Then
# ~ = Released
# + = At The Same Time
CodeNames="GoFullMode"
CodeGoFullMode="DownLeft,UpLeft,Center,UpRight,DownRight,UpRight,Center,UpLeft,DownLeft"
Example 2: Multiple codes with the same name
This is useful when you want to map menu buttons and pad buttons to the same code. DownLeft is used here because SM-RIO is for pump, but in dance mode CodeDLeft="Left"
would also work.
CodeNames="Left,DLeft=Left,Right,DRight=Right,Start,Center=Start,Back"
CodeLeft="MenuLeft"
CodeDLeft="DownLeft"
CodeRight="MenuRight"
CodeDRight="DownRight"
CodeCenter="Center"
CodeStart="Start"
CodeBack="Back"
Step 2. Add your handler code
Add a CodeMessageCommand function. You can put it in any actor you want.
Parameters | Description | Return Type |
---|---|---|
Name | the name of the code you specified. So if you have Codeleft="Left" in metrics.ini and you press Left, params.Name would be "left" |
String (CodeName) |
PlayerNumber | PLAYER_1 or PLAYER_2 | PlayerNumber enum |
Example of it being used to move an ActorScroller (this same example is used in the ActorScroller example):
CodeMessageCommand=function(self, param)
if param.Name == "Left" then
if self:GetDestinationItem() > 0 then
self:SetDestinationItem(self:GetDestinationItem()-1);
SOUND:PlayOnce(THEME:GetPathS("Common", "value"), true);
end;
elseif param.Name == "Right" then
if self:GetDestinationItem() < self:GetNumItems()-1 then
self:SetDestinationItem(self:GetDestinationItem()+1);
SOUND:PlayOnce(THEME:GetPathS("Common", "value"), true);
end;
end;
end;