Forums » General Questions » CodeNames SM5

1
I would like to know how to use this function in stepmania 5, the
idea is to enter a menu of options through some code in ScreenTitleJoin, in
stepmania 3.95 / OpenITG is achieved easily using something like this:

[ScreenTitleJoin]
CodeNames=Options
CodeOptions=Left,Down,Right,Up
CodeOptionsAction=screen,ScreenOptions2

[ScreenOptions2]
Fallback=ScreenArcadeOptions
NextScreen=@ScreenTitleBranch()
LineNames=1,2
Line1=
Line2=

I assumed it was similar in stepmania 5 but nothing I've done works: '(

This is my humble request u-u
Plz help me <3

Last edited: 6 October 2014 2:57am

Reply
You have the metrics mostly right. Only the CodeOptionsAction metric is wrong.
The difference is that in SM5, instead of having the CodeOptionsAction metric, you need to have an actor on that screen that listens for CodeMessageCommand.
So you'd have something like this in the overlay.lua for the screen (added to the ActorFrame for screen of course):

Def.Actor{
CodeMessageCommand= function(self, param)
-- Print that it happened to Logs/log.txt, mainly to show you the stuff in param.
Trace("Code entered by " .. param.PlayerNumber .. " is: " .. param.Name)
if param.Name == "Options" then
local top_screen= SCREENMAN:GetTopScreen()
-- SetNextScreenName and StartTransitioningScreen added in Beta 4. Check the thread in the Releases forum if you're not using Beta 4 yet.
top_screen:SetNextScreenName("ScreenOptions2")
top_screen:StartTransitioningScreen("SM_GoToNextScreen")
end
end
}


If you don't know how to add an actor to a screen, Docs/Themerdocs/Examples/Example_Themes/One_Screen_Example_Theme/BGAnimations/ScreenSimpleExample overlay.lua has a basic explanation of how a screen is made.

Last edited: 6 October 2014 10:33am

< cybik> til Kyzentun fixes bugs for breakfast
--
< maxvg1> shakesoda: then why do i still play lol
<@shakesoda> because you're an ITG player. And thus, a masochist
--
<@shakesoda> Kyzentun: I think you might need to put down the meshes for a bit
Reply
thanks for reply, I followed your instructions but still does not work
I think my inexperience with stepmania made ​​something does not work haha I did this:

in BGAnimations/ScreenTitleJoin overlay/Default.lua :

 local t = Def.ActorFrame{

LoadActor("press_start")..{
InitCommand=cmd(CenterX;y,SCREEN_CENTER_Y+172);
BeginCommand=cmd(playcommand,"Set");
SetCommand=function(self)
-- check for free play, event mode
local coinMode = GAMESTATE:GetCoinMode()
if coinMode == 'CoinMode_Free' then
self:visible(true)
else
self:visible(GAMESTATE:EnoughCreditsToJoin())
end
end;
OnCommand=cmd(diffuseblink);
CoinInsertedMessageCommand=cmd(playcommand,"Set");


};
};


Def.Actor{
CodeMessageCommand= function(self, param)
Trace("Code entered by " .. param.PlayerNumber .. " is: " .. param.Name)
if param.Name == "Options" then
local top_screen= SCREENMAN:GetTopScreen()
top_screen:SetNextScreenName("ScreenOptionsHome")
top_screen:StartTransitioningScreen("SM_GoToNextScreen")
end
end
}

return t;


I just made a change in ScreenOptions2 as it was initially for go to ScreenOptionsHome.

And metrics theme:

[ScreenTitleJoin]
CodeNames="Options"
CodeOptions="Left,Down,Right,Up"

just that.

but did not work, then I made 2 lua in ScreenTitleJoin overlay with codes separately:

ScreenTitleJoin overlay/Default.lua :


local t = Def.ActorFrame{
LoadActor("press_start")..{
InitCommand=cmd(CenterX;y,SCREEN_CENTER_Y+172);
BeginCommand=cmd(playcommand,"Set");
SetCommand=function(self)
-- check for free play, event mode
local coinMode = GAMESTATE:GetCoinMode()
if coinMode == 'CoinMode_Free' then
self:visible(true)
else
self:visible(GAMESTATE:EnoughCreditsToJoin())
end
end;
OnCommand=cmd(diffuseblink);
CoinInsertedMessageCommand=cmd(playcommand,"Set");


};
};

return t;



ScreenTitleJoin overlay/Options.lua :

 local t = Def.Actor{

CodeMessageCommand= function(self, param)
Trace("Code entered by " .. param.PlayerNumber .. " is: " .. param.Name)
if param.Name == "Options" then
local top_screen= SCREENMAN:GetTopScreen()
top_screen:SetNextScreenName("ScreenOptionsHome")
top_screen:StartTransitioningScreen("SM_GoToNextScreen")
end
end
}

return t;




But not work :/

I probably did something wrong, but i don't know what can be u_u

Last edited: 9 October 2014 1:56am

Reply
Your Actor that processes the code and performs the action isn't inside the ActorFrame for the screen, so it never gets created.
"local t= Def.ActorFrame{ ... }" creates an ActorFrame with some children and stores it in "t".
"return t" returns that ActorFrame so the engine can create a screen out of it.

Everything inside the braces is either a child of the ActorFrame or a command for the ActorFrame or an attribute of the ActorFrame. (this applies to every actor, though only actor types derived from ActorFrame can have children)
Since the braces mean that a table is being created, the elements of the table need to be separated by commas.
Right now, you only have the "press_start" actor inside the table, so that is the only child the ActorFrame has.
You want to add the actor that processes the codes as another child, so you add it to the table the same way you would add an element to any other table, by separating it from the previous element with a comma and putting it inside the brace that closes the table.

This is slightly complicated because semicolons can also serve as separators, which is what your code uses them for. So you could separate the elements of the table with semicolons instead of commas. I prefer to avoid semicolons as separators because they have a dual meaning (when not separating elements, they do nothing), and can be replaced by commas for separating elements.
< cybik> til Kyzentun fixes bugs for breakfast
--
< maxvg1> shakesoda: then why do i still play lol
<@shakesoda> because you're an ITG player. And thus, a masochist
--
<@shakesoda> Kyzentun: I think you might need to put down the meshes for a bit
Reply
Well, I did it in two different ways:


local t = Def.ActorFrame{
LoadActor("press_start")..{
InitCommand=cmd(CenterX;y,SCREEN_CENTER_Y+172);
BeginCommand=cmd(playcommand,"Set");
SetCommand=function(self)
-- check for free play, event mode
local coinMode = GAMESTATE:GetCoinMode()
if coinMode == 'CoinMode_Free' then
self:visible(true)
else
self:visible(GAMESTATE:EnoughCreditsToJoin())
end
end;
OnCommand=cmd(diffuseblink);
CoinInsertedMessageCommand=cmd(playcommand,"Set");
};

Def.Actor{
CodeMessageCommand= function(self, param)
-- Print that it happened to Logs/log.txt, mainly to show you the stuff in param.
Trace("Code entered by " .. param.PlayerNumber .. " is: " .. param.Name)
if param.Name == "Options" then
local top_screen= SCREENMAN:GetTopScreen()
-- SetNextScreenName and StartTransitioningScreen added in Beta 4. Check the thread in the Releases forum if you're not using Beta 4 yet.
top_screen:SetNextScreenName("ScreenOptionsService")
top_screen:StartTransitioningScreen("SM_GoToNextScreen")
end
end

};
};

return t;




And:



return Def.ActorFrame{
LoadActor("press_start")..{
InitCommand=cmd(CenterX;y,SCREEN_CENTER_Y+172);
BeginCommand=cmd(playcommand,"Set");
SetCommand=function(self)
-- check for free play, event mode
local coinMode = GAMESTATE:GetCoinMode()
if coinMode == 'CoinMode_Free' then
self:visible(true)
else
self:visible(GAMESTATE:EnoughCreditsToJoin())
end
end;
OnCommand=cmd(diffuseblink);
CoinInsertedMessageCommand=cmd(playcommand,"Set");
};

Def.Actor{
CodeMessageCommand= function(self, param)
-- Print that it happened to Logs/log.txt, mainly to show you the stuff in param.
Trace("Code entered by " .. param.PlayerNumber .. " is: " .. param.Name)
if param.Name == "Options" then
local top_screen= SCREENMAN:GetTopScreen()
-- SetNextScreenName and StartTransitioningScreen added in Beta 4. Check the thread in the Releases forum if you're not using Beta 4 yet.
top_screen:SetNextScreenName("ScreenOptionsService")
top_screen:StartTransitioningScreen("SM_GoToNextScreen")
end
end

}
};




does not work either,
what else can I do? :/

Last edited: 14 October 2014 10:15am

Reply
Since you never specified, what version of SM5 are you using?
Reply
There's a fair chance there's a mistake in my example because I didn't test it and haven't used that kind of thing in months. If you see any on-screen error, that's probably the problem.
The message printed with Trace() is saved to %APPDATA%/StepMania 5.0/Logs/log.txt when the log is flushed by holding F3 and hitting W. It's really meant more as a marker so you know to put the code you actually want in its place, but also so you can see that the code did something. An alternative to using Trace is to have an actor that starts out hidden and is revealed when the code is entered.
Unfortunately, I'm embroiled in last minute preparations for a convention I'm staffing this weekend and won't have time to write up a better example until next week.

Until then, describe in more detail how it doesn't work. Include whether you see an error message on the screen, whether the screen transition fails, or whether nothing happens at all.
< cybik> til Kyzentun fixes bugs for breakfast
--
< maxvg1> shakesoda: then why do i still play lol
<@shakesoda> because you're an ITG player. And thus, a masochist
--
<@shakesoda> Kyzentun: I think you might need to put down the meshes for a bit
Reply
Here some details:

Version: Stepmania 5 beta 4 (some days ago beta 3)
Theme: DDR 5mix (now changed to default, but I guess it should be the same)

if there are any other details you want to know, tell me

actually, nothing happens when I do the code, dont have any error, nothing
if there is an error in what I did, please if can tell me how to do it literally xdd

because this does not work :(

Last edited: 16 October 2014 12:47pm

Reply