From 3fe49ca2a35edf211ada6a7ba16eb85c09efdbd4 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 24 Apr 2020 13:23:39 +0100 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: MichaƂ Janiszewski Co-Authored-By: Aaron van Geffen Co-Authored-By: Tulio Leao --- distribution/scripting.md | 4 ++-- src/openrct2-ui/interface/InGameConsole.h | 2 -- src/openrct2-ui/scripting/ScUi.hpp | 2 +- src/openrct2/scripting/Plugin.h | 4 ++-- src/openrct2/scripting/ScObject.hpp | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/distribution/scripting.md b/distribution/scripting.md index e31701b518..4be8ba207e 100644 --- a/distribution/scripting.md +++ b/distribution/scripting.md @@ -2,7 +2,7 @@ OpenRCT2 allows custom scripts (also known as plug-ins) to be written and executed in the game providing additional behaviour on top of the vanilla experience. This can range from extra windows providing information about the park to entire new multiplayer game modes. -Each script is a single physical javascript file within the `plugin` directory in your OpenRCT2 user directory. This is usually `C:\Users\YourName\Documents\OpenRCT2` on Windows, or `/home/YourName/.config/openrct2` on Linux. OpenRCT2 will load every single file with the extension `.js` in this directory recursively. So if you want to prevent a plug-in from being used, you must move it outside this directory, or rename it so the filename does not end with `.js`. +Each script is a single physical javascript file within the `plugin` directory in your OpenRCT2 user directory. This is usually `C:\Users\YourName\Documents\OpenRCT2` on Windows, or `$XDG_CONFIG_HOME/OpenRCT2` or in its absence `$HOME/.config/OpenRCT2` on Linux. OpenRCT2 will load every single file with the extension `.js` in this directory recursively. So if you want to prevent a plug-in from being used, you must move it outside this directory, or rename it so the filename does not end with `.js`. There are two types of scripts: * Local @@ -44,7 +44,7 @@ The hot reload feature can be enabled by editing your `config.ini` file and sett > Why was JavaScript chosen instead of LUA or Python. -JavaScript is a very mature and flexible language with a large, if not largest, resource base available. There are arguably more transpilers, tools, and libraries for JavaScript than any other language. That and also it using a familiar C-like syntax and 0-indexed arrays make it more suitable than LUA and Python. Of course if you would still like to use LUA or another language, there will likely be a JavaScript transpiler for it. +JavaScript is a very mature and flexible language with a large, if not the largest, resource base available. There are arguably more transpilers, tools, and libraries for JavaScript than any other language. That and also it using a familiar C-like syntax and 0-indexed arrays make it more suitable than LUA and Python. Of course if you would still like to use LUA or another language, there will likely be a JavaScript transpiler for it. Another benefit of using JavaScript is that you get rich editor features such as completion and API documentation by using a TypeScript definition file which works for both TypeScript and JavaScript. [Visual Studio Code](https://code.visualstudio.com) is recommended, as that supports the workflow very well. See the [OpenRCT2 plugin hot-reload demo](https://www.youtube.com/watch?v=jmjWzEhmDjk) video for a demonstration of the editor functionality. diff --git a/src/openrct2-ui/interface/InGameConsole.h b/src/openrct2-ui/interface/InGameConsole.h index 42af4c3ea6..601b4b9743 100644 --- a/src/openrct2-ui/interface/InGameConsole.h +++ b/src/openrct2-ui/interface/InGameConsole.h @@ -9,10 +9,8 @@ #pragma once -#include #include #include -#include namespace OpenRCT2::Ui { diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 820ec0f3f5..9a812ff0c0 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -46,7 +46,7 @@ namespace OpenRCT2::Scripting } private: - int32_t width_get() + int32_t width_get() const { return context_get_width(); } diff --git a/src/openrct2/scripting/Plugin.h b/src/openrct2/scripting/Plugin.h index d7e25c61ba..3c70d911d1 100644 --- a/src/openrct2/scripting/Plugin.h +++ b/src/openrct2/scripting/Plugin.h @@ -40,7 +40,7 @@ namespace OpenRCT2::Scripting std::string Name; std::string Version; std::vector Authors; - PluginType Type; + PluginType Type{}; int32_t MinApiVersion{}; DukValue Main; }; @@ -50,7 +50,7 @@ namespace OpenRCT2::Scripting private: duk_context* _context{}; std::string _path; - PluginMetadata _metadata; + PluginMetadata _metadata{}; std::string _code; bool _hasStarted{}; diff --git a/src/openrct2/scripting/ScObject.hpp b/src/openrct2/scripting/ScObject.hpp index bd049e767e..b3124edfed 100644 --- a/src/openrct2/scripting/ScObject.hpp +++ b/src/openrct2/scripting/ScObject.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2020 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2