Jump to content

Editor Scripting suggestions


klepto2
 Share

Recommended Posts

I don't know exactly if this is the right place for this, but feel free to move it where ever you like,

After the debugging fix in the latest release, I have started to experiment with the Lua extension integration.

Some things I noticed:

  • Currently, there is no way to dynamically down cast an entity to its derived class, e.g.: Entity → Model
    • This is not supported by sol out of the box, but might be needed later as well for type checking.
    • Currently, you can access all entities in the world, but not determine if it is something other than an entity.
  • Some things are not yet accessible for extensions:
    • The objects in the scene (I found out how to add items, not very hard) but I can't find a way to access the already added items in the scene. (using the world property of the program is not very useful because of the first problem (cast/type check) I have mentioned)
  • Currently, there are no advanced extensions available, and as I understand that the focus lies on the release on bug fixing I would appreciate some documentation on how to properly script extensions (usage of the Undo/Redo, scene access) 

It would be nice to see some more advanced scripting options soon.

I especially like some of the syntaxes which are available through sol3:

local ent = world:GetEntitiesInArea(min,max)
for i = 1, #ent do
        local e = ent[i]
        local name = getmetatable(e).__type.name -- unfortunatly only returns "UltraEngine::Entity" and nothing else. No way to cast
        Print(name)
end

 

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

  • 2 weeks later...

@Josh I have found some additional things (I know the api is still in development) 

  • program:OpenAsset is the only method to open the AssetEditor
  • no Asset(model) / Asset(entity) is available --> currently it is not possible (at least no way i know about) to open a model file in the AssetEditor via lua.
  • consider to make the Options in optionswindow a treeview to reflect the actual json layout of the settings. 
    • Maybe an addition to the AddSettings where you can specify the node where this is stored in the settings.json.
      • eg: I have this: program.settings.extensions.polyhaven.material.downloadSize = "1k"
      • now i want a method like opt:AddSettings("Polyhaven", "Material DownloadSize", PROPERTY_STRING, { "1k,"2k",4k",8k" }, "program.settings.extensions.polyhaven.material.downloadSize")
    • a settings property with multiple combo values would be nice as well. eg: PROPERTY_STRING and a array of Strings as possible values 
      • In my case i have a setting where you can choose between (1k,2,4k and 8k) resolutions
      • I can add my own settings dialog, but it would be nice to have the ability to let plugins have its configuration at the same place as the other options.

In general it would by nice if you could expose more Editor-Scripting possibilities for lua in the near future. This would increase the power of the editor by magnitudes (IMHO) 

 

  • Like 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

11 hours ago, klepto2 said:

program:OpenAsset is the only method to open the AssetEditor

How else would it work? Multiple asset windows can be opened, and they are never empty.

The Model.base member is a class that is an asset, though I am not sure if it is exposed to Lua. I don't see it in the documentation...

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

11 hours ago, Josh said:

How else would it work? Multiple asset windows can be opened, and they are never empty.

The Model.base member is a class that is an asset, though I am not sure if it is exposed to Lua. I don't see it in the documentation...

This is exactly what i meant. I guessed it should be only this one. 

Is the model.base already exposed in the editor? I can't access it after the latest update. 

This is what i have tried so far:

model.base (not available)

model:GetBase() (not available)

Asset(model) or Asset(model.base) (not working)

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Sorry about that. This will work now in build 246:

mdl = LoadModel(nil, "models/developer/crate/crate.gltf") program:OpenAsset(mdl.base)

Alternatively, you can just do this:

program:OpenAsset("models/developer/crate/crate.gltf")

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

that works.

I noticed, that sometimes when using CreateDir in the script, the assetbrowser is not updating the folder structure. Could you add a method which refreshes the nodes, or something like assetbrowser:RefreshFolder(folder) ? 

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

8 hours ago, klepto2 said:

that works.

I noticed, that sometimes when using CreateDir in the script, the assetbrowser is not updating the folder structure. Could you add a method which refreshes the nodes, or something like assetbrowser:RefreshFolder(folder) ? 

It should detect a file system event. If not it is a bug...

A simple test works correctly:

CreateDir("Models/test")
CreateDir("Models/test/a/b/c", true)

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...