Forums » Themes » Making a theme from scratch

The CodeMessageCommand part should be in a BGAnimation-side lua script, e.g.

local t = Def.ActorFrame{

Def.Actor{
Name="CodeController";
CodeMessageCommand=%function(self, param)
Trace("CodeMessageCommand received.")
local codeName = param.Name -- code name, matches the one in metrics
local pn = param.PlayerNumber -- which player entered the code
end
};
};


Can I hide or show stepinfos as I wish by using this code and other little add-ons?
(Press a button,then they hide.Press again,they show again~)

And more,who can help me with a small function?
I want to let my theme load a special named image in every song folder(e.g. There is a "title.png" in every single song folder.And it will be load by ScreenSelectMusic overlay every time the musicwheel changed.)
I added this in 99 xxx.lua,but it often shows"Dialog: "Lua runtime error: /Themes/Sigma1 -The Blue Dasher-/Scripts/99 xxx.lua:1: unexpected symbol near '?" [LUA_ERROR]"

function HasTitle()
local song = GAMESTATE:GetCurrentSong();
local course = GAMESTATE:GetCurrenCourse();
if song then
local path=song:GetSongDir();
if FILEMAN:DoesFileExist(path.."../title.png") then
return true
else
return false
end
elseif course then
local path=course:GetCourseDir();
if FILEMAN:DoesFileExist(path.."../title.png") then
return true
else
return false
end;
end;
end;

function GetTitlePath()
local song = GAMESTATE:GetCurrentSong();
local course = GAMESTATE:GetCurrenCourse();
local st;
if song then
local path=song:GetSongDir();
if FILEMAN:DoesFileExist(path.."../title.png") then
st = path.."../title.png"
else
st = ~nil
end
elseif course then
local path=course:GetCourseDir();
if FILEMAN:DoesFileExist(path.."../title.png") then
st = path.."../title.png"
else
st = ~nil
end;
end;
return st;
end;

Last edited: 9 February 2014 5:02am

Welcome,Thememaniaians./来吧,主题狂们。
Contact me!QQ:1030110910/欢迎与我联系,QQ:1030110910
Reply
Gotta be more specific than that on what's confusing you on theming

like how do you make BGAnimations,Fonts,and Graphics? and how to put in the sounds and scripts? im not sure if i need to put anything in the languages folder. lol i know i should have been known all of this stuff but im xtremely new to theming from scratch.
Reply

Can I hide or show stepinfos as I wish by using this code and other little add-ons?
(Press a button,then they hide.Press again,they show again~)

Yes, you can. Freem actually had a typo in his example, that "%" should not be there, if this is in a lua file.


And more,who can help me with a small function?
I added this in 99 xxx.lua,but it often shows"Dialog: "Lua runtime error: /Themes/Sigma1 -The Blue Dasher-/Scripts/99 xxx.lua:1: unexpected symbol near '?" [LUA_ERROR]"


"~nil" is not valid lua. You want to just set st to nil.

Last edited: 9 February 2014 7:32pm

< 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

Can I hide or show stepinfos as I wish by using this code and other little add-ons?
(Press a button,then they hide.Press again,they show again~)

Yes, you can. Freem actually had a typo in his example, that "%" should not be there, if this is in a lua file.


And more,who can help me with a small function?
I added this in 99 xxx.lua,but it often shows"Dialog: "Lua runtime error: /Themes/Sigma1 -The Blue Dasher-/Scripts/99 xxx.lua:1: unexpected symbol near '?" [LUA_ERROR]"


"~nil" is not valid lua. You want to just set st to nil.


I had a try:Added these in the [ScreenSelectMusic] metrics:
CodeNames="ShowInfo"
CodeShowInfo="Select"

And put this in ScreenSelectMusic overlay.lua:

local t = Def.ActorFrame{
Def.Actor{
Name="CodeController";
CodeMessageCommand=function(self, param)
Trace("CodeMessageCommand received.")
local codeName = param.ShowInfo
local pn = param.PlayerNumber_P1
end
};

LoadActor(THEME:GetPathB("","_Materials/cover"))..{
InitCommand=cmd();
OnCommand=cmd(horizalign,left;y,SCREEN_BOTTOM-70;zoomto,854,200;diffusealpha,0;accelerate,0.2;diffusealpha,0.9;cropleft,0.5);
OffCommand=cmd(sleep,0.1;accelerate,0.3;diffusealpha,0;);
CodeMessageCommand=function(self)
local a;
a=true
if a then
self:diffusealpha(0);
a=false
else
self:diffusealpha(1);
a=true
end;
end;

};
...
};


When I press "Select",It disappeared correctly.but when I press again.....nothing happened.Is there some thing wrong?Or the codes can only be typed one time?

EDIT:alright....I found the problem-every time the CodeMessageCommand is run."a" will be "true"......I fixed it and it works.Now I just need someone fix my 99 xxx.lua....:

function HasTitle(song)
local path=song:GetSongDir();
if FILEMAN:DoesFileExist(path.."../title.png") then
return true
else
return false
end;
end;
function GetTitlePath(song)
local st;
if HasTitle(song) then
local path=song:GetSongDir();
st=path.."../title.png"
else
st=a
end;
return st;

end;

Last edited: 10 February 2014 4:19am

Welcome,Thememaniaians./来吧,主题狂们。
Contact me!QQ:1030110910/欢迎与我联系,QQ:1030110910
Reply


function GetTitlePath(song)
local st;
if HasTitle(song) then
local path=song:GetSongDir();
st=path.."../title.png"
else
st=a
end;
return st;
end;

Why are you setting st to a? That looks like a mistake.
< 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


function GetTitlePath(song)
local st;
if HasTitle(song) then
local path=song:GetSongDir();
st=path.."../title.png"
else
st=a
end;
return st;
end;

Why are you setting st to a? That looks like a mistake.


Should I just set st=nil? QUQ,I tried but failed.I even delete that whole function (GetTitlePath(song)).But it still has bugs....
Welcome,Thememaniaians./来吧,主题狂们。
Contact me!QQ:1030110910/欢迎与我联系,QQ:1030110910
Reply
Should I just set st=nil? QUQ,I tried but failed.I even delete that whole function (GetTitlePath(song)).But it still has bugs....
I spent a couple minutes adding this to my theme so see what problems there might be, and I didn't run into any.

Inside one of my Scripts/ lua files:
function GetTitlePath(song)

local path=song:GetSongDir()
if FILEMAN:DoesFileExist(path.."../title.png") then
return path.."../title.png"
end
return nil
end


Inside ScreenSelectMusic overlay.lua, in the ActorFrame that it returns:
	Def.Sprite{

InitCommand= cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y),
Name="title_img",
CurrentSongChangedMessageCommand=
function(self)
Trace("title_img changing.")
local song= GAMESTATE:GetCurrentSong()
if song then
local title_path= GetTitlePath(song)
Trace("Path: " .. tostring(title_path))
if title_path then
self:Load(title_path)
self:diffusealpha(1)
else
Trace("No path.")
self:diffusealpha(0)
end
else
Trace("No song.")
self:diffusealpha(0)
end
end
},


And it works. I decided HasTitle was superfluous, so I didn't use it.
< 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
I created another new lua file,and write these codes.This time I didn't get bugs. Thanks Kyzentun~
Hope our discussion can help other people.
Welcome,Thememaniaians./来吧,主题狂们。
Contact me!QQ:1030110910/欢迎与我联系,QQ:1030110910
Reply