theRAPTLab / gsgo

GEM-STEP Foundation repo migrated from GitLab June 2023
1 stars 1 forks source link

Feature: Edit Instance Init Scripts using Wizard #777

Closed benloh closed 8 months ago

benloh commented 8 months ago

Addresses #754

Instance init scripts in the Map Editor were originally edited directly with a code editor. This adds the ability to edit instance init scripts in a Script Editor window, supporting both a wizard view and a code editor view.

To Test

  1. Open Main
  2. Click on "SETUP" to edit the Map
  3. Click on an instance in "CHARACTERS" (or if you haven't created an instance already, select blueprint from "ADD CHARACTERS")
  4. Click on the instance to expand the Edit view.
  5. Click on the "Edit" button to open the init script in a new wizard.
  6. Edit the script using a wizard as you normally would.
  7. Click "Save Line" to save changes to the line.
  8. Click "Save to Server" to update the init script.
  9. The instance will be updated.

Other things to test:

Technical Background

Editing init script is a bit tricky because the wizard needs to pre-compile the blueprint in order to know how to scaffold the wizard editor. The blueprint script needs to be compiled and bundled so that the wizard knows which props and features have been defined and are therefore available to be called in the initScript. We do this by adding initScripts to the blueprint bundle, and then re-purposing the ScriptEditor components to handle either regular blueprint scripts or just init scripts.

To Do

jdanish commented 8 months ago

If ScriptEditor is open and the user drags, the code should update? Or do we lock out the drag? Ideally update, but if it is a hassle that's fine since we almost always close first (I can't fit both on my window!!)

"Character Type Editor" vs "Character Instance Editor"? I think that works

Also, this reveals the issue that the code to generate the instance properties is not using the character type and that is a problem for the wizard. In other words, it says prop x setTo 5 the editor expects prop Beaver.x setTo 5

Is it possible to set the writing code to add the character name in so that the wizard won't complain? It's probably good form anyhow?

jdanish commented 8 months ago

Also, since it is so crowded, I am OK removing the model name from the script editor since we currently can only run one model anyhow?

jdanish commented 8 months ago

I tried adding a new line of script to change the alpha. When I hit save line, no problem. When I hit save script, no response. I closed the window and the change had taken. Then I tried opening and editing that line, and again no change. I checked the console and this error is there. The changes are saving, but it is choking on the button push.

Screenshot 2023-10-10 at 7 39 57 AM
jdanish commented 8 months ago

I also noticed that when I changed alpha, it did not update the character on-screen until I had saved setup. That's fine, but if it is easy to do an update cycle on save, that'd be even better :)

benloh commented 8 months ago

@jdanish Thanks for testing. We are still far away from finishing. I had thought we were close but there are all these edge conditions that have to be chased down one by one.

jdanish commented 8 months ago

That's why we are here! If you want us to pause or test specific areas let me know

benloh commented 8 months ago

since it is so crowded, I am OK removing the model name from the script editor since we currently can only run one model anyhow?

@jdanish Are you saying you want to remove the character name from panel title bar (e.g. "SCRIPT EDITOR beaver")? Or were you referring to the character name in the wizard/code view?

jdanish commented 8 months ago
Screenshot 2023-10-10 at 7 36 48 AM

wetlands_beavers_energy is the model name, and I think we could cut it? The script / character we should keep

benloh commented 8 months ago

@jdanish I can't reproduce this error:

I tried adding a new line of script to change the alpha. When I hit save line, no problem. When I hit save script, no response. I closed the window and the change had taken. Then I tried opening and editing that line, and again no change. I checked the console and this error is there. The changes are saving, but it is choking on the button push.

Screenshot 2023-10-10 at 7 39 57 AM

Please try again after the most recent pushes, which should address some of the update errors.

jdanish commented 8 months ago

@jdanish I can't reproduce this error:

I tried adding a new line of script to change the alpha. When I hit save line, no problem. When I hit save script, no response. I closed the window and the change had taken. Then I tried opening and editing that line, and again no change. I checked the console and this error is there. The changes are saving, but it is choking on the button push.

Screenshot 2023-10-10 at 7 39 57 AM

Please try again after the most recent pushes, which should address some of the update errors.

Confirmed this is no-longer an issue.

jdanish commented 8 months ago

Can you either remove the "delete script" button from the instance editor, or change it to be "delete instance" and change the function accordingly? I think just removing it might make the most sense?

benloh commented 8 months ago

Can you either remove the "delete script" button from the instance editor, or change it to be "delete instance" and change the function accordingly? I think just removing it might make the most sense?

Removed. Also removed the "Select Script" button for init script.

jdanish commented 8 months ago

Odd one, but ... in the current build, if you do the following:

  1. Change a property other than x or y in instance (directly, using external code editor). E.g., adding: prop character.row setTo 2
  2. Load script and run - the property is set.
  3. Look at instance via setup - the property is set.
  4. Load script editor for character type (e.g., NOT the instance)
  5. Make some change - doesn't matter what. Save script
  6. All instances now only include prop x and prop y - the additional prop character.row setTo 2 has been deleted
benloh commented 8 months ago

Sorry, I thought I had fixed that, but obviously I didn't. Oh this is is a deeper problem. After you edit a character type script, the instances are reset. So that's why the lines are gone.

benloh commented 8 months ago

This should be fixed now. It was some ancient code that did not account for the fact that we now support using <bpname>.x references.

benloh commented 8 months ago

@jdanish Ready for more careful review. Most things should be fixed now.

jdanish commented 8 months ago

Looks goos to me. AOK to merge.