Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gui.opacity(0.8)
- --
- ---
- function Set(list)
- local set = {}
- for _, l in ipairs(list) do set[l] = true end
- return set
- end
- function addToSet(set, key)
- set[key] = true
- end
- function removeFromSet(set, key)
- set[key] = nil
- end
- function setContains(set, key)
- return set[key]
- end
- ---
- ---
- -- function lag_frame_display()
- -- lag_minutes = math.floor(current_level_lag_time/3600)
- -- lag_seconds = math.floor((current_level_lag_time - lag_minutes*3600)/60)
- -- lag_frames = math.floor(current_level_lag_time - lag_seconds*60 - lag_minutes*3600)
- -- lag_tenths_seconds = math.floor(lag_frames/0.6)
- -- gui.register(gui.text(10,17, lag_minutes .. ":" .. lag_seconds .. "." .. lag_tenths_seconds .. " (" .. lag_frames .. ")"))
- -- end
- --
- --
- first_stage_in_world_list = Set({0, 12, 24, 36, 48, 60})
- last_stage_in_world_list = Set({7, 19, 31, 43, 55, 67})
- final_level_time = 0
- instage = 0
- current_level_time = 0
- current_world_time = 0
- stage_string = "S: "
- world_string = "W: "
- current_level_lag_time = 0
- --
- --
- function read_memory()
- game_mode = memory.readbyte(0x7E0118)
- bowser_completed = memory.readbyte(0x7E026D)
- entering_stage = memory.readbyte(0x7E111D)
- titlescreen = memory.readbyte(0x7E011C)
- starting_file = memory.readbyte(0x7E112E)
- stage_value = memory.readbyte(0x7E021A)
- boss_explosion = memory.readbyte(0x7E096C)
- end
- in_world = false
- function check_world_start()
- if titlescreen == 12 and entering_stage == 1 and in_world == false and first_stage_in_world_list[stage_value] == true then
- start_world_frame = emu.framecount()
- in_world = true
- print("I started it all")
- end
- end
- function check_world_end()
- if in_world == true and (boss_explosion == 55 or boss_explosion == 52) and last_stage_in_world_list[stage_value] == true then
- stop_world_timer = true
- in_world = false
- print("I stopped time")
- end
- end
- -- function check_file_start()
- -- if starting_file == 1 and titlescreen == 6 then
- -- start_game_frame = emu.framecount()
- -- end
- -- end
- -- function check_game_completion()
- -- if bowser_completed == 1 then
- -- end_frame = emu.framecount()
- -- final_run_time = end_frame - start_game_frame
- -- end
- -- end
- function convert_and_display_level_time(timertime, timertype, yoffset)
- local minutes = math.floor(timertime/3600)
- local seconds = math.floor((timertime - minutes*3600)/60)
- local frames = math.floor(timertime - seconds*60 - minutes*3600)
- local tenths_seconds = math.floor(frames/0.6)
- return gui.text(5, yoffset, timertype .. minutes .. ":" .. seconds .. "." .. tenths_seconds .. " (" .. frames .. ")")
- end
- function check_level_start()
- if game_mode == 15 and instage == 0 and (boss_explosion ~= 55 and boss_explosion ~= 52) then
- level_start_frame = emu.framecount()
- level_start_lag_frame = emu.lagcount()
- instage = 1
- print("check_level_start()")
- end
- end
- function in_level_time_display()
- if instage == 1 then
- current_level_time = emu.framecount() - level_start_frame
- if game_mode == 15 then
- current_level_lag_time = emu.lagcount() - level_start_lag_frame
- end
- end
- end
- function in_world_time_display()
- if in_world == true then
- current_world_time = emu.framecount() - start_world_frame
- end
- end
- function check_level_end()
- if instage == 1 then
- if game_mode == 16 or boss_explosion == 55 or boss_explosion == 52 then
- level_end_frame = emu.framecount()
- level_end_lag_frame = emu.lagcount()
- -- final_level_time = level_start_frame - level_end_frame
- -- store_stage_time(currentstage,final_level_time)
- -- check_best_times_and_replace(currentstage, final_level_time)
- instage = 0
- print("check_level_end()")
- elseif game_mode == 34 or game_mode == 61 or game_mode == 53 then
- instage = 0
- end
- end
- end
- while true do
- read_memory()
- check_level_start()
- check_world_start()
- check_world_end()
- check_level_end()
- in_level_time_display()
- in_world_time_display()
- gui.register(convert_and_display_level_time(current_level_time, "S: ", 10))
- gui.register(convert_and_display_level_time(current_world_time, "W: ", 18))
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement