Skip to content

Commit

Permalink
docs: Added info about tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-coster committed Mar 31, 2023
1 parent 2c6f3cf commit 6dd392e
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions packages/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This extension provides language features for GameMaker Language (GML), among ot

- `Stitch: New GameMaker Project` command available via the file explorer context menu for folders. This command clones a template GameMaker project into that folder. A very basic built-in template is used by default, but can be overridden with the `stitch.template.path` configuration option.
- `Stitch: Open in GameMaker` command available via the palette while editing `.yyp`, `.yy`, or `.gml` files, and via the file explorer context menu for the same file types. This command opens the project in the GameMaker IDE version last used by the same project, automatically installing that IDE version if necessary.
- Tasks for running your project right from VSCode
- GML syntax highlighting
- Workspace Symbol Search via the command palette.
- Autocomplete for built-in GameMaker functions and constants
Expand All @@ -23,6 +24,108 @@ This extension provides language features for GameMaker Language (GML), among ot
- Autocomplete for global types in JSDocs (built-in and project-specific)
- Format and validate `.yy`/`.yyp` project files. (To use it, set it as your default formatter for those filetypes.)

## Running Projects from VSCode

If you have task autodiscovery turned on, you may be able to find `stitch` listed in your tasks just by opening up your Palette and finding "Tasks: Run Task".

There's still a little jank in the task configuration, so mileage may vary!

<details>
<summary>
💡 Example GML script for getting clickable links from runtime errors.
</summary>

```js
function write_parseable_exception (err){
var as_string = "FATAL: " + string_trim(err.message);

var definition_files = ds_map_create();
var script_functions_string = environment_get_variable("VSCODE_STITCH_SCRIPT_FUNCTIONS");
if(is_string(script_functions_string) && string_length(script_functions_string) > 0){
try{
var pairs = string_split(script_functions_string, ",");
for(var i=0; i<array_length(pairs); i++){
if(string_length(pairs[i]) == 0){
continue;
}
var pair = string_split(pairs[i], ":");
if(array_length(pair) != 2){
continue;
}
definition_files[? pair[0]] = pair[1];
}
}
catch(__err){
echo(__err);
}
}

for(var i=0; i<array_length(err.stacktrace); i++){
var _trace = err.stacktrace[i];
// Example start "gml_Object_o_entry_Create_0 (line 2) - die();"
if(string_starts_with(_trace, "gml_")){
var _asset_type = "";
var _call = "";
var _line = "";
var _asset_and_event = "";

_trace = string_delete(_trace,1,4);
// => "Object_o_entry_Create_0 (line 2) - die();"
var __parts = string_split(_trace, "_", true, 1);
// => ["Object","o_entry_Create_0 (line 2) - die();"]
_asset_type = __parts[0];
// => "Object"
var __rest = string_split(__parts[1], " ", true, 1);
// => ["o_entry_Create_0","(line 2) - die();"]
_asset_and_event = __rest[0]; // Not all asset types have events, and not all events have numbers
// => "o_entry_Create_0"
var __line_and_call = string_split(__rest[1], " - ", true, 1);
// => ["(line 2)","die();"] // Not all traces have the call entry
_line = string_replace(string_split(__line_and_call[0], " ", true, 1)[1],")","");
_call = array_length(__line_and_call)>1 ? __line_and_call[1] : "";

_trace = string_lower(_asset_type) + "s/";

if( ! array_contains(["Object","Script"], _asset_type) ){
continue;
}

var folder = _asset_and_event;
var file = _asset_and_event;
if(_asset_type == "Object"){
// Need to separate the asset name from the event info
__parts = string_split(_asset_and_event, "_");
var __event_number = array_pop(__parts);
var __event_name = array_pop(__parts);
folder = array_join(__parts, "_");
file = __event_name + "_" + __event_number;
}
else if(is_string(definition_files[? _asset_and_event])){
folder = definition_files[? _asset_and_event];
file = folder;
}
_trace += folder + "/" + file + ".gml:" + _line;
if(_call != ""){
_trace += " " + _call;
}
}
as_string += "\n" + string_repeat(" ",i+1) + "" + string_trim(_trace);
}
var sep = "\n\n#####################\n\n";
show_debug_message(sep + as_string + sep);
ds_map_destroy(definition_files);
game_end(1);
}

var vscode_stitch_version = environment_get_variable("VSCODE_STITCH_VERSION");
if(is_string(vscode_stitch_version) && vscode_stitch_version != ""){
exception_unhandled_handler(write_parseable_exception);
}
```
</details>
## 🛣️ Roadmap
- Add dynamic syntax highlighting for the different resource types so they can be color-coded in the theme
Expand Down

0 comments on commit 6dd392e

Please sign in to comment.