@defold-typescript/types 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
"go.property": [
|
|
351
351
|
{
|
|
352
352
|
"sourceHash": "96e6079cda36fa54",
|
|
353
|
-
"ts": "// This example defines a property \"health\" in a script. The health is decreased\n// whenever someone sends a \"take_damage\" message to the script.\
|
|
353
|
+
"ts": "// This example defines a property \"health\" in a script. The health is decreased\n// whenever someone sends a \"take_damage\" message to the script.\n\n// The payload of your own message id, declared once for the whole program\n// (usually in a .d.ts of its own).\ndeclare global {\n interface CustomMessages {\n take_damage: { damage: number };\n }\n}\n\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // `go.property(\"health\", 100)` registration from this field, and only this\n // field types the property onto `self`.\n properties: { health: 100 },\n\n init(self) {\n // prints 100 to the output\n print(self.health);\n },\n\n on_message(self, message_id, message) {\n if (isMessage(message_id, message, \"take_damage\")) {\n self.health = self.health - message.damage;\n print(`Ouch! My health is now: ${self.health}`);\n }\n },\n});"
|
|
354
354
|
}
|
|
355
355
|
],
|
|
356
356
|
"go.set": [
|
package/package.json
CHANGED
package/src/go-overloads.d.ts
CHANGED
|
@@ -89,7 +89,9 @@ declare global {
|
|
|
89
89
|
* @deprecated Don't call `go.property` yourself. Declare the property in
|
|
90
90
|
* `defineScript({ properties })` — that is the only form that types it onto
|
|
91
91
|
* `self`; the transpiler emits the `go.property(...)` registration for you.
|
|
92
|
-
* A direct call still registers, but
|
|
92
|
+
* A direct call still registers the property at runtime, but it reaches
|
|
93
|
+
* neither `properties` nor `init`'s return, so reading `self.<name>` in a
|
|
94
|
+
* hook is a compile error.
|
|
93
95
|
*
|
|
94
96
|
* @param name - editor property id to register.
|
|
95
97
|
* @param value - default value for the registered property.
|