-
Notifications
You must be signed in to change notification settings - Fork 178
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
Script editor #3074
Script editor #3074
Conversation
I just tested this, and one crash that I found is that if you try and load a script from a terrain folder the game crashes |
I just realized I'm not nearly done here, so I've converted this to draft. @AnotherFoxGuy Probably an uncaught exception. I just added an exception-reporting event type, but I need to manually wrap all troublesome funcs. The I just added an API giving script info - I need it to make nice exception window, and also to tell which exceptions belong to who - the editor needs to catch all so it can diagnose it's guest script. The |
@AnotherFoxGuy I can't seem to reproduce the crash you mentioned. |
Latest development: 👼script bindings of OGRE overlay system and a prototype editor script allowing you to add/edit/delete elements and export OGRE's .overlay files.. Also the editor now has tabs and autosave. |
CODECCHANGES: * scriptEngine.h: framestep() now returns void (retval was meaningless since multiple scripts got supported); aded `executeContextAndHandleErrors()` and `exceptionCallback()` * scriptEngine.cpp: framestep() now uses `executeContextAndHandleErrors()` * gameScript: added functions `get/setRegisteredEventsMask()` so that script editor can listen for the guest script's exceptions. * scriptEvents.h: added SE_ANGELSCRIPT_EXCEPTIONCALLBACK * doc/script2game/globals.h: added events SE_ANGELSCRIPT_EXCEPTIONCALLBACK (new) and SE_ANGELSCRIPT_LINECALLBACK (omitted by mistake). script_editor.as updated - angelscript exceptions are displayed alongside forwarded C++ exceptions
Folding is not implemented yet, only a visual highlight is present for testing. overlay_editor.as was marked up as example. Note the markers must be in // comments not to disrupt AngelScript.
`triggerEvent()` and `envokeCallback()` now use `[prepare/execute]ContextAndHandleErrors()` helpers. Coded while investigating Xploder98's as_CONTEXT_NOT_PREPARED problem which turned out to be a callback with incorrect signature.
….as' New conventions: * scripts with name 'example_*.as' are examples and have Examples menu in the script editor (aready estabilished) * scripts with name '*_utils.as' are includes and have Includes menu in the script editor (new) Documenting style (example): /// \title SCRIPT NAME /// \brief One-line short description /// Blah blah details... /// Usage: /// `#include "scriptname.as"` ~~ adds the utils to your script
cb24ddf
to
85bb231
Compare
- loading new file also focuses the new tab - fixed Save menu "Select" button writing to Load menu's inputbox - fixed script title & brief strings not appearing in menus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work fine, though my knowledge with scripting is quite limited. A search feature and the ability to duplicate a line (CTRL+D in Notepad++) would be nice, but those could come later.
apparently `getAsString()` has some Linux-x64 issues (`eof()` triggers SIGINT): see https://discord.com/channels/136544456244461568/189904947649708032/1155952230130778262 Observed with OGRE 1.11.6
* changed "select+load" to just "load" in menubar. * workaround: clamp error line num.s to actual line count * Renamed "Welcome" tab to "Tutorial.as". * fixed bogus filesize of Recent scripts.
e1ca279
to
a1952a7
Compare
Script writing is powerful but clumsy:
loadscript ...
to console or use ScriptMonitor menu to Load/Reload the scriptTo make scripting fun, the dev/test cycle needs to be quick and comfy. So we needed an ingame editor with a "(RE)START" button and error reporting.
Behold the 'script_editor.as' AngelScript editor written in AngelScript:
At the moment it's somewhat glitchy but the START/STOP button works perfectly. It relies entirely on
ImGui::InputTextMultiline()
, errors and syntax highlight is done by overdrawing. The numbers are: line number, line length, comment offset, num errors - most are not useful but look cool, you can disable them in the View menu.Update: yes, the hyperlink opens the default browser (only tested on Win10).
Update2: added
game.findResourceFileInfo()
which lists files in pre-defined resource groups. This allowed me to list up files in user's 'scripts' dir: