ソースを参照

Improved on extension docs and how to get help

Björn Ritzl 5 年 前
コミット
6b92c256ce

+ 3 - 3
docs/en/manuals/debugging-game-and-system-logs.md

@@ -33,10 +33,10 @@ $ > ./mygame.app/Contenst/MacOS/mygame
 
 
 Logs can be read using the developer tools provided by most browsers.
 Logs can be read using the developer tools provided by most browsers.
 
 
-* [Chrome](https://developers.google.com/web/tools/chrome-devtools/console)
-* [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console)
+* [Chrome](https://developers.google.com/web/tools/chrome-devtools/console) - Menu > More Tools > Developer Tools
+* [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console) - Tools > Web Developer > Web Console
 * [Edge](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide/console)
 * [Edge](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide/console)
-* [Safari](https://support.apple.com/guide/safari-developer/log-messages-with-the-console-dev4e7dedc90/mac)
+* [Safari](https://support.apple.com/guide/safari-developer/log-messages-with-the-console-dev4e7dedc90/mac) - Develop > Show JavaScript Console
 
 
 ### Android
 ### Android
 
 

+ 1 - 1
docs/en/manuals/extensions-details.md

@@ -20,7 +20,7 @@ When creating libraries (such as extensions), it's good to keep the lowest commo
 Clang - macOS, iOS, Win32, Android
 Clang - macOS, iOS, Win32, Android
 GCC - Linux
 GCC - Linux
 
 
-*We plan to use clang for Linux aswell at some point*
+*We plan to use clang for Linux as well at some point*
 
 
 ### SDK Versions
 ### SDK Versions
 
 

+ 23 - 31
docs/en/manuals/extensions.md

@@ -74,6 +74,7 @@ The optional *manifests* folder of an extension contains additional files used i
 
 
 Extensions are treated just like any other assets in your project and they can be shared in the same way. If a native extension folder is added as a Library folder it can be shared and used by others as a project dependency. Refer to the [Library project manual](/manuals/libraries/) for more information.
 Extensions are treated just like any other assets in your project and they can be shared in the same way. If a native extension folder is added as a Library folder it can be shared and used by others as a project dependency. Refer to the [Library project manual](/manuals/libraries/) for more information.
 
 
+
 ## A simple example extension
 ## A simple example extension
 
 
 Let's build a very simple extension. First, we create a new root folder *myextension* and add a file *ext.manifest* containing the name of the extension "MyExtension". Note that the name is a C++ symbol and must match the first argument to `DM_DECLARE_EXTENSION` (see below).
 Let's build a very simple extension. First, we create a new root folder *myextension* and add a file *ext.manifest* containing the name of the extension "MyExtension". Note that the name is a C++ symbol and must match the first argument to `DM_DECLARE_EXTENSION` (see below).
@@ -99,42 +100,27 @@ The extension source file contains the following code:
 
 
 // include the Defold SDK
 // include the Defold SDK
 #include <dmsdk/sdk.h>
 #include <dmsdk/sdk.h>
-#include <stdlib.h>
 
 
-static int Rot13(lua_State* L)
+static int Reverse(lua_State* L)
 {
 {
-    int top = lua_gettop(L);
+    // The number of expected items to be on the Lua stack
+    // once this struct goes out of scope
+    DM_LUA_STACK_CHECK(L, 1);
 
 
     // Check and get parameter string from stack
     // Check and get parameter string from stack
-    const char* str = luaL_checkstring(L, 1);
+    char* str = (char*)luaL_checkstring(L, 1);
 
 
-    // Allocate new string
+    // Reverse the string
     int len = strlen(str);
     int len = strlen(str);
-    char *rot = (char *) malloc(len + 1);
-
-    // Iterate over the parameter string and create rot13 string
-    for(int i = 0; i <= len; i++) {
-        const char c = str[i];
-        if((c >= 'A' && c <= 'M') || (c >= 'a' && c <= 'm')) {
-            // Between A-M just add 13 to the char.
-            rot[i] = c + 13;
-        } else if((c >= 'N' && c <= 'Z') || (c >= 'n' && c <= 'z')) {
-            // If rolling past 'Z' which happens below 'M', wrap back (subtract 13)
-            rot[i] = c - 13;
-        } else {
-            // Leave character intact
-            rot[i] = c;
-        }
+    for(int i = 0; i < len / 2; i++) {
+        const char a = str[i];
+        const char b = str[len - i - 1];
+        str[i] = b;
+        str[len - i - 1] = a;
     }
     }
 
 
-    // Put the rotated string on the stack
-    lua_pushstring(L, rot);
-
-    // Free string memory. Lua has a copy by now.
-    free(rot);
-
-    // Assert that there is one item on the stack.
-    assert(top + 1 == lua_gettop(L));
+    // Put the reverse string on the stack
+    lua_pushstring(L, str);
 
 
     // Return 1 item
     // Return 1 item
     return 1;
     return 1;
@@ -143,7 +129,7 @@ static int Rot13(lua_State* L)
 // Functions exposed to Lua
 // Functions exposed to Lua
 static const luaL_reg Module_methods[] =
 static const luaL_reg Module_methods[] =
 {
 {
-    {"rot13", Rot13},
+    {"reverse", Reverse},
     {0, 0}
     {0, 0}
 };
 };
 
 
@@ -199,12 +185,13 @@ To test the extension, create a game object and add a script component with some
 
 
 ```lua
 ```lua
 local s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 local s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-local rot_s = myextension.rot13(s)
-print(rot_s) --> nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM
+local reverse_s = myextension.reverse(s)
+print(reverse_s) --> ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba
 ```
 ```
 
 
 And that's it! We have created a fully working native extension.
 And that's it! We have created a fully working native extension.
 
 
+
 ## Extension Lifecycle
 ## Extension Lifecycle
 
 
 As we saw above the `DM_DECLARE_EXTENSION` macro is used to declare the various entry points into the extension code:
 As we saw above the `DM_DECLARE_EXTENSION` macro is used to declare the various entry points into the extension code:
@@ -240,6 +227,11 @@ The following identifiers are defined by the builder on each respective platform
 * DM_PLATFORM_LINUX
 * DM_PLATFORM_LINUX
 * DM_PLATFORM_HTML5
 * DM_PLATFORM_HTML5
 
 
+## Build server logs
+
+Build server logs are available when the project is using native extensions. The build server log (`log.txt`) is downloaded together with the custom engine when the project is built and stored inside the file `.internal/%platform%/build.zip`.
+
+
 ## The ext.manifest file
 ## The ext.manifest file
 
 
 Apart from the name of the extension, the manifest file can contain platform specific compile flags, link flags, libs and frameworks. If the *ext.manifest* file does not contain a "platforms" segment, or a platform is missing from the list, the platform you bundle for will still build, but without any extra flags set.
 Apart from the name of the extension, the manifest file can contain platform specific compile flags, link flags, libs and frameworks. If the *ext.manifest* file does not contain a "platforms" segment, or a platform is missing from the list, the platform you bundle for will still build, but without any extra flags set.

+ 11 - 21
docs/en/manuals/getting-help.md

@@ -11,7 +11,9 @@ If you run into a problem while using Defold we'd like to hear from you so that
 
 
 A good way to discuss and get help with a problem is to post a question on our [forum](https://forum.defold.com). Post either in the [Questions](https://forum.defold.com/c/questions) or [Bugs](https://forum.defold.com/c/bugs) category depending on the type of problem you have. Remember to [search](https://forum.defold.com/search) for your question/issue before asking as there may already be a solution to your problem.
 A good way to discuss and get help with a problem is to post a question on our [forum](https://forum.defold.com). Post either in the [Questions](https://forum.defold.com/c/questions) or [Bugs](https://forum.defold.com/c/bugs) category depending on the type of problem you have. Remember to [search](https://forum.defold.com/search) for your question/issue before asking as there may already be a solution to your problem.
 
 
-When you post a support question make sure to include as much information as possible. Also make sure to use a short and descriptive title. A good title would be "How do I move a game object in the direction it is rotated?" or "How do I fade out a sprite?". A bad title would be "I need some help using Defold!" or "My game is not working!".
+When you post a support question make sure to include as much information as possible. Provide [log files](#log-files), information about your operating system, steps to reproduce the problem, possible workarounds etc.
+
+Also make sure to use a short and descriptive title. A good title would be "How do I move a game object in the direction it is rotated?" or "How do I fade out a sprite?". A bad title would be "I need some help using Defold!" or "My game is not working!".
 
 
 If you have several questions, create multiple posts. Do not ask unrelated questions in the same post.
 If you have several questions, create multiple posts. Do not ask unrelated questions in the same post.
 
 
@@ -21,7 +23,7 @@ The editor provides a convenient way to report issues. Select the <kbd>Help->Rep
 
 
 ![](images/getting_help/report_issue.png)
 ![](images/getting_help/report_issue.png)
 
 
-Selecting this menu option will bring you to an issue tracker on GitHub. Please fill out the form and include as much information as possible. Refer to [the section below on how to extract log files](#log-files).
+Selecting this menu option will bring you to an issue tracker on GitHub. Provide [log files](#log-files), information about your operating system, steps to reproduce the problem, possible workarounds etc.
 
 
 ::: sidenote
 ::: sidenote
 You need a GitHub account to submit a bug report this way.
 You need a GitHub account to submit a bug report this way.
@@ -35,23 +37,11 @@ If you run into a problem while using Defold you can try to ask the question on
 
 
 # Log files
 # Log files
 
 
-The engine, editor and build server generates logging information that can be very valuable when asking for help and debugging an issue. Always provide log files when reporting a problem.
-
-## Engine logs
-- Android: Logs can be accessed using the `adb` command line tool (Android Debug Bridge). Read more about the `adb` command line tool in the [Android manual](/manuals/android/#android-debug-bridge).
-- iOS: Logs can be accessed using XCode and the Devices and Simulators menu option.
-- HTML5: Logs can be viewed in the browser developer console:
-  - Chrome: Menu > More Tools > Developer Tools
-  - Firefox: Tools > Web Developer > Web Console
-  - Safari: Develop > Show JavaScript Console
-- Desktop: Logs for desktop builds can be viewed by running the Defold application from a terminal/command prompt.
-
-You can also write engine logs to a file and access this once the application has been shut down. You can read more about how to enable and access the log in the [Debugging manual](/manuals/debugging/#extracting-the-logtxt-file).
-
-## Editor logs
-- Windows: `C:\Users\ **Your Username** \AppData\Local\Defold`
-- macOS: `/Users/ **Your Username** /Library/Application Support/` or `~/Library/Application Support/Defold`
-- Linux: `~/.Defold`
+The engine, editor and build server generates logging information that can be very valuable when asking for help and debugging an issue. Always provide log files when reporting a problem:
 
 
-## Build server logs
-Build server logs are available when the project is using native extensions. The build server log (`log.txt`) is downloaded together with the custom engine when the project is built and stored inside the file `.internal/%platform%/build.zip`.
+* [Engine logs](/manuals/debugging-game-and-system-logs)
+* Editor logs
+  * Windows: `C:\Users\ **Your Username** \AppData\Local\Defold`
+  * macOS: `/Users/ **Your Username** /Library/Application Support/` or `~/Library/Application Support/Defold`
+  * Linux: `~/.Defold`
+* [Build server logs](/manuals/extensions#build-server-logs)