浏览代码

Added url shorthands to addressing and message passing manuals

Closes #95
Björn Ritzl 5 年之前
父节点
当前提交
8e6568297e
共有 3 个文件被更改,包括 29 次插入21 次删除
  1. 3 18
      docs/en/manuals/addressing.md
  2. 9 3
      docs/en/manuals/message-passing.md
  3. 17 0
      docs/en/shared/url-shorthands.md

+ 3 - 18
docs/en/manuals/addressing.md

@@ -109,26 +109,11 @@ The address `"buddy#controller"` works for the game objects in both collections
 
 Relative addressing works by automatically prepending the current naming context when resolving a target address. This is again immensely useful and powerful because you can create groups of game objects with code and reuse those efficiently throughout the game.
 
-Shorthands
-: Defold provides two useful relative address shorthands:
+### Shorthands
 
-  `.`
-  : Shorthand resolving to the current game object.
+Defold provides two handy shorthands that you can use to send message without specifying a complete URL:
 
-  `#`
-  : Shorthand resolving to the current component.
-
-  For example:
-
-  ```lua
-   -- Let this game object acquire input focus
-   msg.post(".", "acquire_input_focus")
-  ```
-
-  ```lua
-   -- Post "reset" to the current script
-   msg.post("#", "reset")
-  ```
+:[Shorthands](../shared/url-shorthands.md)
 
 ## Game object paths
 

+ 9 - 3
docs/en/manuals/message-passing.md

@@ -38,7 +38,7 @@ The game contains a few simple mechanics that require communication between the
   There is only a single strength punch move in the game so the message does not need to contain any more information than its name, "punch".
 
   In the script component of the enemy, you create a function to receive the message:
-  
+
   ```lua
   function on_message(self, message_id, message, sender)
     if message_id == hash("punch") then
@@ -149,6 +149,13 @@ message_id
 There is a hard limit to the `message` parameter table size. This limit is set to 2 kilobytes. There is currently no trivial way to figure out the exact memory size a table consumes but you can use `collectgarbage("count")` at before and after inserting the table to monitor memory use.
 :::
 
+### Shorthands
+
+Defold provides two handy shorthands that you can use to send message without specifying a complete URL:
+
+:[Shorthands](../shared/url-shorthands.md)
+
+
 ## Receiving messages
 
 Reciving messages is a matter of making sure the target script component contains a function named `on_message()`. The function accepts four parameters:
@@ -175,7 +182,7 @@ function on_message(self, message_id, message, sender)
                     -->   score = 100,
                     -->   value = "some string"
                     --> }
-    
+
     print(sender) --> url: [main:/my_object#script]
 end
 ```
@@ -245,4 +252,3 @@ DEBUG:SCRIPT: 75 dispatch passes before this update.
 ```
 
 We see that this particular Defold engine version performs 10 dispatch passes on the message queue between `init()` and the first call to `update()`. It then performs 75 passes during each subsequent update loop.
-

+ 17 - 0
docs/en/shared/url-shorthands.md

@@ -0,0 +1,17 @@
+  `.`
+  : Shorthand resolving to the current game object.
+
+  `#`
+  : Shorthand resolving to the current component.
+
+  For example:
+
+  ```lua
+   -- Let this game object acquire input focus
+   msg.post(".", "acquire_input_focus")
+  ```
+
+  ```lua
+   -- Post "reset" to the current script
+   msg.post("#", "reset")
+  ```