Created
June 8, 2015 02:54
-
-
Save kyzentun/32b204061f74a5fb48ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local song_position= false | |
local cheat_code= { | |
"Right", "Down", "Up", "Right", "Right", "Down", "Right", "Right", "Up", | |
"Up", "Down", "Down", "Left", "Right", "Left", "Right", "Right", "Down", | |
"Up", "Right", "Right", "Down", "Right", "Right", "Up", "Up", "Down", | |
"Down", "Left", "Right", "Left", "Right", "Right", "Down", "Up", "Right", | |
"Right", "Down", "Right", "Right", "Up", "Up", "Down", "Down" | |
} | |
local code_len= #cheat_code | |
local code_progress= {} | |
local progress_bar= {} | |
local note_columns= {} | |
local hide_alpha= .3 | |
local show_alpha= 1 | |
local seconds_per_beat= 60 / 142 | |
local rainbow_period= seconds_per_beat | |
local col_name_to_id= { | |
Left= 1, Down= 2, Up= 3, Right= 4 | |
} | |
local function reward(pn) | |
local pcols= note_columns[pn] | |
for i= 1, #pcols do | |
pcols[i]:diffusealpha(1) | |
--pcols[i]:visible(true) | |
:rainbow():effectperiod(rainbow_period) | |
end | |
end | |
local function reveal_all(pn) | |
local pcols= note_columns[pn] | |
for i= 1, #pcols do | |
pcols[i]:diffusealpha(1) | |
--pcols[i]:visible(true) | |
end | |
end | |
local function show_single_column(pn, col) | |
local pcols= note_columns[pn] | |
for i= 1, #pcols do | |
--pcols[i]:visible(true) | |
pcols[i]:diffusealpha(show_alpha) | |
end | |
if col then | |
--pcols[col]:visible(false) | |
pcols[col]:diffusealpha(hide_alpha) | |
end | |
end | |
local hide_info= {} | |
local function make_section_from_list(offset, list) | |
for i= 1, #list do | |
hide_info[#hide_info+1]= {offset+i, list[i]} | |
end | |
end | |
make_section_from_list(15, cheat_code) | |
make_section_from_list(88, { | |
"Right", "Down", "Up", "Right", "Right", "Down", "Right", "Right", "Up", | |
"Up", "Down", "Down", "Left", "Right", "Left", "Right", "Right", "Down", | |
"Up", "Right", "Right", "Down", "Right", "Right", "Up", "Up", "Down", | |
"Down", "Left"}) | |
make_section_from_list(119, { | |
"Right", "Down", "Up", "Right", "Right", "Down", "Right", "Right", "Up", | |
"Up", "Down", "Down", "Left", "Right", "Left", "Right", "Right", "Down", | |
"Up", "Right", "Right", "Down", "Right", "Right", "Up", "Up", "Down", | |
"Down"}) | |
make_section_from_list(151, {"All"}) | |
make_section_from_list(313, { | |
"Right", "Down", "Up", "Right", "Right", "Down", "Right", "Right", "Up", | |
"Up", "Down", "Down", "Left", "Right", "Left", "Right", "Right", "Down", | |
"Up", "Right", "Right", "Down", "Right", "Right", "Up", "Up", "Down", | |
"Down", "Left", "Right", "Left", "Right", "All"}) | |
local hide_pos= 1 | |
local function update_progress(pn, add, finished) | |
if not add then | |
progress_bar[pn]:settext("") | |
else | |
if code_progress[pn] % 12 == 0 then | |
add= "\n"..add | |
end | |
progress_bar[pn]:settext(progress_bar[pn]:GetText()..add) | |
end | |
if finished then | |
progress_bar[pn]:rainbow():effectperiod(rainbow_period) | |
:linear(0.4225352112676056 * 8):diffusealpha(0) | |
code_progress[pn]= 1000 | |
reward(pn) | |
end | |
end | |
local function input(event) | |
local pn= event.PlayerNumber | |
local button= event.button | |
if event.type ~= "InputEventType_FirstPress" or not pn | |
or not button then | |
return | |
end | |
if button == "Select" then | |
local tmp= hide_alpha | |
hide_alpha= show_alpha | |
show_alpha= tmp | |
end | |
if code_progress[pn] <= code_len then | |
if button == cheat_code[code_progress[pn]] then | |
code_progress[pn]= code_progress[pn] + 1 | |
update_progress(pn, button:sub(1, 1), code_progress[pn] > code_len) | |
else | |
code_progress[pn]= 1 | |
update_progress(pn) | |
end | |
end | |
end | |
local function update() | |
local beat= song_position:GetSongBeat() | |
if hide_info[hide_pos] and beat > hide_info[hide_pos][1] then | |
local col= hide_info[hide_pos][2] | |
for i, pn in ipairs(GAMESTATE:GetEnabledPlayers()) do | |
if code_progress[pn] <= code_len then | |
show_single_column(pn, col_name_to_id[col]) | |
end | |
end | |
hide_pos= hide_pos + 1 | |
end | |
end | |
local args= { | |
Def.ActorFrame{ | |
OnCommand= function(self) | |
self:sleep(180):SetUpdateFunction(update) | |
song_position= GAMESTATE:GetSongPosition() | |
local screen= SCREENMAN:GetTopScreen() | |
screen:AddInputCallback(input) | |
for i, pn in ipairs(GAMESTATE:GetEnabledPlayers()) do | |
local player= screen:GetChild("Player" .. ToEnumShortString(pn)) | |
if player then | |
local field= player:GetChild("NoteField") | |
if field then | |
note_columns[pn]= field:get_column_actors() | |
end | |
end | |
end | |
end | |
} | |
} | |
local bar_pos= { | |
[PLAYER_1]= _screen.w*.25, [PLAYER_2]= _screen.w*.75, | |
} | |
for i, pn in ipairs(GAMESTATE:GetEnabledPlayers()) do | |
code_progress[pn]= 1 | |
args[#args+1]= Def.BitmapText{ | |
Font= "Common Normal", InitCommand= function(self) | |
progress_bar[pn]= self | |
self:xy(bar_pos[pn], _screen.h-64):diffuse(color("#93a1a1")) | |
:strokecolor(color("#002b36")):vertalign(bottom) | |
end, | |
} | |
end | |
return Def.ActorFrame(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this code actually work? If yes what screen should I enter this code into to test it out?