Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posibility to change the template that the editor script is using. #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions monarch/editor-script/make_monarch.editor_script
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local M = {}

local collection_template
local gui_script_content
local gui_file_content
local gui_script_template
local gui_template

local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
Expand Down Expand Up @@ -36,6 +36,7 @@ local function create_files(file_path)
end
if not file_exists(target_gui_script_path) then
local gui_script = io.open(target_gui_script_path, "w")
local gui_script_content = gui_script_template()
gui_script:write(gui_script_content)
gui_script:close()

Expand Down Expand Up @@ -91,7 +92,8 @@ max_nodes: 512
]]
end

gui_script_content = [[local monarch = require "monarch.monarch"
gui_script_template = function()
return [[local monarch = require "monarch.monarch"

function init(self)
msg.post(".", "acquire_input_focus")
Expand All @@ -112,7 +114,7 @@ end
function on_reload(self)
end
]]

end

collection_template = function(gui_script, name)
return [[name: "]].. name .. [["
Expand Down Expand Up @@ -156,6 +158,12 @@ embedded_instances {

end

if file_exists("./editor_script_settings.lua") then
local settings = require "editor_script_settings"
gui_template = settings.gui_template or gui_template
collection_template = settings.collection_template or collection_template
gui_script_template = settings.gui_script_template or gui_script_template
end


return M