ERROR:RESOURCE: /imports/json/build_time.json could not be reloaded since it was never loaded before.
When I hotreload a particle for example I get an error like this for file generated with editor script.
I am creating a file in a folder that might not have been created yet. So before creating the file file:write(shell); file:close()
I would normally do os.execute("mkdir -p " .. folder_path)
. But in editor_script os.execute
doesnāt exists so I need to do the mkdir
command in the run
part of a editor_script. But creating that file is done within a normal lua function.
I want to create a folder at build/editor_script/
I will then copy a shell script with file.write
into that folder. I will then run my python scripts through that shell script.
The only solution I see is to ignore lua all together and do everything with shell scripts, which is annoying because I might multiple versions depending on OS.
So, I just updated my editor a minute ago, but I still donāt have the new outline properties stuff. editor.can_get
and editor.can_set
do not exist and the āoutlineā selection type is not recognized. Is there some other channel Iām supposed to be on?
You use alpha
channel, it should be editor-alpha
instead (you can edit your channel in file named config
in Defold installation directory)
Aha, thanks!
I played around with the Outline Properties a bit and they enable a lot of stuff!
The first thing I tried to make was an extensino that aligns your gui nodes. It works fine (assuming you only rotate around Z) until they have parents, so here is me asking for more features - I would love to see something like editor.get(id, "parent")
#2816.
Here is a preview of the extension.
We need a viewport right click context menu we can populate.
I tried to get the Box Node pivot but got
ERROR:EXT: /editor-script-align/editor-script-align.editor_script:106 BoxNode has no "pivot" property
This got me to try all fo them and these are not available:
size_mode, texture, slice_9, color, alpha, layer, blend_mode, pivot, x_anchor, y_anchor, adjust_mode, clipping_mode
These are the ones you can get on a Box Node:
position, rotation, scale, size, inherit_alpha, clipping_visible, clipping_inverted
I am trying to do everything with shell script because mixing shell and functions are impossible.
I have a shell script I want to copy to "./build/editor-scripts/"
the first time I run the script the folder isnāt there. Therefore I have to create it I donāt hae access to os.execute
so I need to do
command = {"mkdir" ,"-p", "./build/editor-scripts/"}
After the folder is created I want move the file into it. The normal way to do this is with file:write
but becuase I am now in the return statement of the "run"
function I canāt use any lua. Therefore I need to rediret the output of the shell file into the new file.
command = {"echo", editor.get("/editor-script-cleanup/scripts/extend_path.sh", "text"), ">", "./build/editor-scripts/extend_path.sh"}
But it seem that the echo is only redirected to Defoldās console regardless that I tell it to redirect it to the file, so no file is created.
Any other ideas how to do this?
Currently I donāt think there is a way to do this. Presumably you want to somehow extract shell scripts from a lib dependency zip file so that these shell scripts can be executed in response to menu commands in the editor?
Perhaps there needs to be a mechanism in place to extract and resolve paths to packaged shell scripts somehow?
Yeah, what I want to do is call a python script through a shell script because I need to source .bash_profile first. Some way to use files inside of a dendency would be very useful.
I can work around the problem in this particular case because it is a python script that will be called. I can assume that python is installed and maybe do something like [[f=open(]] .. create_this_file.. [[);f.write(]] .. with_this_content ..[[);f.close()]]
Since it looks like people are posting their editor scripts here, I figured Iād chip in and post my lifecycle script that auto-implements this fix for slow HTML5 bundles on certain browsers. The only caveat is that you have to output the bundle into the project directory so Lua can access it. Iām also not very experienced with IO and string manipulation, so feel free to suggest improvements! Anyways, here it is:
Code
local M = {}
local function read(file)
local data = ""
for l in file:lines() do
data = data .. l .. "\n"
end
return data
end
function M.on_bundle_finished(opts)
if opts.platform == "js-web" and opts.success then
local title = sys.get_config("project.title", "Desktop Game")
local file = io.open(opts.output_directory .. "/" .. title .. "/index.html", "r")
local fixed = string.gsub(read(file), "engine_arguments: %[%]", "engine_arguments: [\"--verify-graphics-calls=false\"]")
file:close()
file = io.open(opts.output_directory .. "/" .. title .."/index.html", "wb")
file:write(fixed)
file:flush()
file:close()
end
end
return M
editor-script-lua-format - Format your Lua code!
Adds a right click context menu item āFormat Documentā for .lua, .script, .editor_script, .render_script, .gui_script files to format them with lua-format.
Installation
Download repo as .zip, simply copy āeditor-script-lua-formatā folder to your project and reload editor scripts. Done!
Known Issues
- Not tested yet on
Linuxand macOS. Binary executable files are from vscode-lua-format repo.- Canāt be used as dependency library . Simply copy paste the script folder into your project.
Changelog
2020-01-11: I added Git pre-commit hook sample to the repo. It formats staged Lua files to keep your code fabulous!
2020-01-13: Binary executable files are built using Travis CI and AppVeyor.
Why? Ah, because of the binary file you need to run to format the code?
Thatās great!
Shame that we donāt support binaries in dependencies, seems like a very demanded featureā¦
Maybe disallow it for lib ones but do allow it for ones actually in the project folder? Or is that how it already is?
Yes, because of that.
Yes, itās already that.
I added Git pre-commit hook sample to the repo. It formats staged Lua files to keep your code fabulous