-
-
Notifications
You must be signed in to change notification settings - Fork 112
Editor Script files ([filetype].lua or [filetype].py)
Editor-Script files are used to parse and edit save files and returning these values to EdiZon. These script files are required to be named after the type of files it targets (e.g a script file that processes JSON files has to be named json.lua) in lowercase and placed inside sdmc:/EdiZon/editor/scripts/
! This name will be used to target them inside the Editor-Config files. One script file can be used for multiple Editor-Config files, no need to write a new one for every game even though this is totally possible to add additional functionality, it's not recommended. If any external modules are required, they should get placed inside sdmc:/EdiZon/editor/scripts/libs/
for lua and sdmc:/EdiZon/editor/scripts/libs/python3.5/
for python.
The content of the file is written in Lua or Python. A typical example looks as follows:
-- bin --
saveFileBuffer = edizon.getSaveFileBuffer()
function getValueFromSaveFile()
strArgs = edizon.getStrArgs()
intArgs = edizon.getIntArgs()
indirectAddress = tonumber(strArgs[1], 16)
address = tonumber(strArgs[2], 16)
addressSize = intArgs[1]
valueSize = intArgs[2]
offset = 0
value = 0
if indirectAddress ~= 0 then
for i = 0, addressSize - 1 do
offset = offset | (saveFileBuffer[indirectAddress + i + 1] << i * 8)
end
end
for i = 0, valueSize - 1 do
value = value | (saveFileBuffer[offset + address + i + 1] << i * 8)
end
return value
end
function setValueInSaveFile(value)
strArgs = edizon.getStrArgs()
intArgs = edizon.getIntArgs()
indirectAddress = tonumber(strArgs[1], 16)
address = tonumber(strArgs[2], 16)
addressSize = intArgs[1]
valueSize = intArgs[2]
offset = 0
if indirectAddress ~= 0 then
for i = 0, addressSize - 1 do
offset = offset | (saveFileBuffer[indirectAddress + i + 1] << (i * 8))
end
end
for i = 0, valueSize - 1 do
saveFileBuffer[offset + address + i + 1] = (value & (0xFF << i * 8)) >> (i * 8)
end
end
function getModifiedSaveFile()
return saveFileBuffer
end
The same works for python as well. Just import the edizon
module and use the same functions as in Lua before.
All functions provided by EdiZon are inside the edizon
module, thus be accessed via edizon.function()
-
getSaveFileBuffer()
: Returns a table STARTING AT 1!!! filled with the byte values of this games save file. If the save file wasn't binary but a string based format, the values will be stored ASCII encoded inside the table. -
getSaveFileString()
: Returns a string representation of the save file. This only supports ASCII characters for now. UFT-8, UTF-16 and UTF-32 will be added in the next version. -
getIntArgs()
: Gets a table filled with the integer values specified inside theintArgs
tag of the current widget. This may be used to set the address and value size but the implementation is based on the current requirements and so can be used for every integer value possibly needed. -
getStrArgs()
: Gets a table filled with the string values specified inside thestrArgs
tag of the current widget. This may be used to set the address of the value in hexadecimal but the implementation is based on the current requirements and so can be used for every string value possibly needed.
-
getValueFromSaveFile()
: This function will be called from EdiZon when a value is requested from the editor. It takes in no parameters and returns an integer. This function might run multiple times per frame. -
getStringFromSaveFile()
: This function will be called from EdiZon when a string value is requested from the editor. It takes in no parameters and returns either a string. This function might run multiple times per frame. -
setValueInSaveFile(value)
: This function will be called from EdiZon when the user changed a value in one of the widgets. The value parameter will be set to the new value that was set in the editor. This function might run multiple times per second when the user is interacting with the editor. -
setStringInSaveFile(string)
: This function will be called from EdiZon when the user changed a string in one of the widgets. The value parameter will be set to the new string that was set in the editor. This function might run multiple times per second when the user is interacting with the editor. -
getModifiedSaveFile()
: This function will be called from EdiZon once the user issued the store operation. It has to return the entire modified save file buffer in the same format as it was received usinggetSaveFileBuffer()
. These values will be directly written to the save file after the user has confirmed their action.
Besides the above named functions, there also exist getDummyValue()
, setDummyValue(value)
, getDummyString()
and setDummyString(string)
which get called by EdiZon when the user changes the value in a widget that was marked as dummy
in the config file. intArgs and strArgs still get set accordingly to the config file and can be used to pass in parameters to differentiate between multiple dummy widgets.
Usage examples for this would be:
- A game that stores multiple save states in the same file (Darksouls)
- A game which's save file format changes depending on how far the game has progressed (Mario + Rabbids)