Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
--Written by Brandon Evans
|
|
|
|
|
|
|
|
--You can change the position of the text here.
|
|
|
|
local x = 0
|
|
|
|
local y = 36
|
|
|
|
|
-As much as I dislike the new joypad.set() setup, the least I could do is make it consistent with joypad.get().
--If there is no controller parameter, then all of the buttons are returned as they are stored in the system, just like joypad.set(input) takes button names as is.
--If there is a controller parameter, all of the buttons for that controller are returned without the "PX ", just like joypad.set(input, controller) takes button names without the "PX " and assigns them to the matching buttons for that controller.
--No one approved this change, but seriously, this is common sense. I expect some "change denied" April Fool's stuff tomorrow...
-Implemented a blacklist for ButtonCount. By default, Lag, Pause, and Reset are blacklisted. I don't think any of these buttons should be tracked.
2012-04-01 08:08:40 +00:00
|
|
|
--You can blacklist buttons from being recorded here.
|
|
|
|
local blacklist = {'Lag', 'Pause', 'Reset'}
|
|
|
|
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
local data = {}
|
|
|
|
local registered = false
|
|
|
|
local state = {}
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
local states = {}
|
|
|
|
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
function deepcopy(object)
|
|
|
|
local lookup_table = {}
|
|
|
|
local function _copy(object)
|
-As much as I dislike the new joypad.set() setup, the least I could do is make it consistent with joypad.get().
--If there is no controller parameter, then all of the buttons are returned as they are stored in the system, just like joypad.set(input) takes button names as is.
--If there is a controller parameter, all of the buttons for that controller are returned without the "PX ", just like joypad.set(input, controller) takes button names without the "PX " and assigns them to the matching buttons for that controller.
--No one approved this change, but seriously, this is common sense. I expect some "change denied" April Fool's stuff tomorrow...
-Implemented a blacklist for ButtonCount. By default, Lag, Pause, and Reset are blacklisted. I don't think any of these buttons should be tracked.
2012-04-01 08:08:40 +00:00
|
|
|
if type(object) ~= 'table' then
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
return object
|
|
|
|
elseif lookup_table[object] then
|
|
|
|
return lookup_table[object]
|
|
|
|
end
|
|
|
|
local new_table = {}
|
|
|
|
lookup_table[object] = new_table
|
|
|
|
for index, value in pairs(object) do
|
|
|
|
new_table[_copy(index)] = _copy(value)
|
|
|
|
end
|
|
|
|
return setmetatable(new_table, getmetatable(object))
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
return _copy(object)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
|
|
|
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
function counts(obj)
|
2012-04-25 04:56:48 +00:00
|
|
|
gui.text(x, y, 'Pressed: ' .. obj.pressed)
|
|
|
|
gui.text(x, y + 14, 'Inputted: ' .. obj.inputted)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
|
|
|
|
2012-03-28 03:41:46 +00:00
|
|
|
function frames()
|
|
|
|
if not movie.isloaded() then
|
2014-02-14 01:27:38 +00:00
|
|
|
console.log('No data loaded from frames')
|
2012-03-28 03:41:46 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
reset()
|
|
|
|
--Get data from every frame but this one. This frame's data will be decided
|
|
|
|
--in real-time.
|
|
|
|
for frame = 0, emu.framecount() - 1 do
|
|
|
|
record(movie.getinput(frame))
|
|
|
|
end
|
2014-02-14 01:27:38 +00:00
|
|
|
console.log('Data loaded from frames')
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
counts(data)
|
2012-03-28 03:41:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function load(name)
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
registered = true
|
|
|
|
state = {}
|
2012-03-28 03:41:46 +00:00
|
|
|
if not states[name] then
|
|
|
|
frames()
|
|
|
|
save(name)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
return
|
|
|
|
end
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
data = deepcopy(states[name])
|
2014-02-14 01:27:38 +00:00
|
|
|
console.log('Data loaded from ' .. name)
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
--Show the data from before the state's frame.
|
|
|
|
local previous = states[name].previous
|
|
|
|
counts(previous)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
|
|
|
|
2012-03-27 21:11:34 +00:00
|
|
|
function record(buttons)
|
|
|
|
for button, value in pairs(buttons) do
|
-As much as I dislike the new joypad.set() setup, the least I could do is make it consistent with joypad.get().
--If there is no controller parameter, then all of the buttons are returned as they are stored in the system, just like joypad.set(input) takes button names as is.
--If there is a controller parameter, all of the buttons for that controller are returned without the "PX ", just like joypad.set(input, controller) takes button names without the "PX " and assigns them to the matching buttons for that controller.
--No one approved this change, but seriously, this is common sense. I expect some "change denied" April Fool's stuff tomorrow...
-Implemented a blacklist for ButtonCount. By default, Lag, Pause, and Reset are blacklisted. I don't think any of these buttons should be tracked.
2012-04-01 08:08:40 +00:00
|
|
|
local blacklisted = false
|
|
|
|
for index, name in pairs(blacklist) do
|
|
|
|
if name == button then
|
|
|
|
blacklisted = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if value and not blacklisted then
|
2012-04-25 04:56:48 +00:00
|
|
|
data.inputted = data.inputted + 1
|
|
|
|
if not data.buttons[button] then
|
|
|
|
data.pressed = data.pressed + 1
|
2012-03-27 21:11:34 +00:00
|
|
|
end
|
|
|
|
end
|
2012-04-25 04:56:48 +00:00
|
|
|
data.buttons[button] = value
|
2012-03-27 21:11:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function reset()
|
2012-04-25 04:56:48 +00:00
|
|
|
data.buttons = {}
|
|
|
|
data.pressed = 0
|
|
|
|
data.inputted = 0
|
2012-03-27 21:11:34 +00:00
|
|
|
end
|
|
|
|
|
2012-03-28 03:41:46 +00:00
|
|
|
function save(name)
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
registered = true
|
|
|
|
if next(state) == nil then
|
|
|
|
data.previous = deepcopy(data)
|
|
|
|
--Include the state's frame in the data.
|
|
|
|
record(joypad.get())
|
|
|
|
state = deepcopy(data)
|
|
|
|
end
|
|
|
|
states[name] = deepcopy(state)
|
2014-02-14 01:27:38 +00:00
|
|
|
console.log('Data saved to ' .. name)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
|
|
|
|
2012-03-27 21:11:34 +00:00
|
|
|
reset()
|
2012-03-28 03:41:46 +00:00
|
|
|
frames()
|
|
|
|
|
2013-11-01 15:19:35 +00:00
|
|
|
if event.onloadstate then
|
|
|
|
event.onloadstate(load)
|
|
|
|
event.onsavestate(save)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
while true do
|
|
|
|
--If this is the first frame, reset the data.
|
|
|
|
if emu.framecount() == 0 then
|
2012-03-28 03:41:46 +00:00
|
|
|
reset()
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
end
|
Came up with a solution for the joypad.get() issue.
-adelikat has informed me that in FCEUX, savestates contained the button state of the frame on which you saved on. He claims that this is redundant because you could retrieve the state from the frame you're loading on, so BizHawk will not do this.
-As such, I just retrieved the input for the frame you're saving on before associating the data with the state.
--This essentially includes the missing info without having to depend on a movie frame to get the data from.
--In order for this to make sense, I made it so that the main joypad.get() doesn't run on a frame you're saving / loading on.
--Finally, in order to show the data from before the save frame when loading the data, I cached that data as well.
---The two above steps require collecting the data for a state once and using that until the frame is advanced or a state is loaded. Otherwise, I'd be able to increase the count significantly by saving multiple times.
-All this said and done, I think this script is perfect now, and is way more convenient to use than the FCEUX counterpart.
Notes:
-As mentioned before, it seems that the scripts are disabled when the console is reset / a movie begins playing. I don't like this to begin with, but worse yet, I noticed that this somehow makes the button data carry over from before the reset. Why is this?
-It seems that using gui.text in savestate.registersave/load causes the text to be written over the previous text instead of clearing the screen and then writing. Is this expected? How can I avoid overlapping text?
2012-03-28 17:06:25 +00:00
|
|
|
if not registered then
|
|
|
|
record(joypad.get())
|
|
|
|
end
|
|
|
|
registered = false
|
|
|
|
state = {}
|
|
|
|
counts(data)
|
Added my converted ButtonCount.lua script (Original here: http://code.google.com/p/brandon-evans-tas/source/browse/Lua/ButtonCount.lua)
-As you'll recall, the script has 3 methods of keeping track of input:
--1. Tracking the button counts in real time. This took some minor adjustments, but seems to work fine.
--2. Parsing the button presses from a loaded, read-only TAS file when starting the script, if possible.
---This works well enough after a good amount of refactoring, but I only have it rigged to work for NES.
---As always, note that this method is very slow for big movies, which is why we only use it once.
--3. Caching the counts when saving a state and loading them when loading a state.
---savestate.registerload and savestate.registersave are not currently supported by BizHawk, so this is not functioning at all.
-I propose that a function called movie.getframe(frame) be added that gets status of all of the buttons, just like joypad.get(), for a given frame of a movie.
--This makes the would make method 2 trivial and fast.
--It would allow me to generalize the function for all platforms easily.
---Certainly there might be some discrepancies about which buttons should be disallowed, if any (Is Reset a button press?), but still.
--If this method could somehow work for non-readonly movies, then I'd be able to use the movie to get the counts when I load a state that doesn't have cached data.
---Trust me when I tell you that this would be immensely useful for minimum button TASing. The process would be seamless, and all of these methods combined would provide perfect accuracy while being fairly efficient and only using intensive routines when absolutely necessary.
Note: Earlier, I came up with the idea for a function that lets you set what frame of the movie you are on, which would be useful for endless TASes like we've already discussed, adelikat. Do you still think this is worth having?
2012-03-27 06:44:47 +00:00
|
|
|
emu.frameadvance()
|
|
|
|
end
|