@defold-typescript/types 0.40.0 → 0.41.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.
- package/api-availability.json +3963 -772
- package/api-migrations.json +27 -0
- package/api-signatures.json +18069 -10240
- package/api-targets.json +448 -11
- package/examples/translations.json +560 -89
- package/fixtures/messages_doc.json +96 -0
- package/generated/b2d.d.ts +680 -4
- package/generated/b2d_body.d.ts +29 -103
- package/generated/b2d_chain.d.ts +5 -6
- package/generated/b2d_fixture.d.ts +34 -38
- package/generated/b2d_joint.d.ts +503 -25
- package/generated/b2d_shape.d.ts +183 -20
- package/generated/b2d_world.d.ts +57 -63
- package/generated/buffer.d.ts +16 -15
- package/generated/builtin-messages.d.ts +7 -1
- package/generated/bullet3d.d.ts +91 -0
- package/generated/bullet3d_collision_object.d.ts +433 -0
- package/generated/bullet3d_constraint.d.ts +818 -0
- package/generated/bullet3d_rigid_body.d.ts +429 -0
- package/generated/bullet3d_shape.d.ts +123 -0
- package/generated/bullet3d_world.d.ts +492 -0
- package/generated/camera.d.ts +29 -32
- package/generated/collectionfactory.d.ts +15 -18
- package/generated/collectionproxy.d.ts +22 -6
- package/generated/compute.d.ts +12 -238
- package/generated/crash.d.ts +24 -10
- package/generated/editor-vm/http.d.ts +90 -7
- package/generated/editor-vm/image.d.ts +7 -7
- package/generated/editor-vm/json.d.ts +11 -0
- package/generated/editor-vm/localization.d.ts +7 -7
- package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
- package/generated/editor-vm/zip.d.ts +28 -0
- package/generated/editor.d.ts +1496 -430
- package/generated/factory.d.ts +21 -25
- package/generated/font.d.ts +64 -22
- package/generated/go.d.ts +235 -182
- package/generated/graphics.d.ts +335 -97
- package/generated/gui.d.ts +240 -471
- package/generated/html5.d.ts +2 -2
- package/generated/http.d.ts +28 -35
- package/generated/image.d.ts +105 -72
- package/generated/json.d.ts +34 -16
- package/generated/kinds/gui-script.d.ts +7 -0
- package/generated/kinds/render-script.d.ts +7 -0
- package/generated/kinds/script.d.ts +7 -0
- package/generated/label.d.ts +77 -7
- package/generated/liveupdate.d.ts +13 -10
- package/generated/material.d.ts +312 -360
- package/generated/model.d.ts +40 -39
- package/generated/particlefx.d.ts +19 -28
- package/generated/physics.d.ts +365 -133
- package/generated/profiler.d.ts +13 -23
- package/generated/render.d.ts +237 -297
- package/generated/resource.d.ts +664 -583
- package/generated/socket.d.ts +120 -133
- package/generated/sound.d.ts +62 -31
- package/generated/sprite.d.ts +31 -17
- package/generated/sys.d.ts +234 -190
- package/generated/tilemap.d.ts +21 -16
- package/generated/timer.d.ts +34 -21
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
- package/generated/versions/defold-1.12.4/buffer.d.ts +1 -3
- package/generated/versions/defold-1.12.4/camera.d.ts +21 -21
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +9 -9
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
- package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
- package/generated/versions/defold-1.12.4/go.d.ts +6 -12
- package/generated/versions/defold-1.12.4/gui.d.ts +77 -175
- package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
- package/generated/versions/defold-1.12.4/http.d.ts +0 -13
- package/generated/versions/defold-1.12.4/image.d.ts +16 -33
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/json.d.ts +10 -6
- package/generated/versions/defold-1.12.4/label.d.ts +2 -3
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
- package/generated/versions/defold-1.12.4/model.d.ts +2 -10
- package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.12.4/physics.d.ts +69 -67
- package/generated/versions/defold-1.12.4/profiler.d.ts +2 -5
- package/generated/versions/defold-1.12.4/render.d.ts +99 -128
- package/generated/versions/defold-1.12.4/resource.d.ts +120 -148
- package/generated/versions/defold-1.12.4/socket.d.ts +34 -60
- package/generated/versions/defold-1.12.4/sound.d.ts +8 -8
- package/generated/versions/defold-1.12.4/sprite.d.ts +15 -5
- package/generated/versions/defold-1.12.4/sys.d.ts +37 -71
- package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -21
- package/generated/versions/defold-1.12.4/window.d.ts +1 -16
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +169 -8
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
- package/generated/versions/defold-1.13.0/buffer.d.ts +1 -3
- package/generated/versions/defold-1.13.0/camera.d.ts +25 -25
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +9 -9
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.0/compute.d.ts +0 -69
- package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
- package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
- package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
- package/generated/versions/defold-1.13.0/go.d.ts +6 -12
- package/generated/versions/defold-1.13.0/graphics.d.ts +73 -37
- package/generated/versions/defold-1.13.0/gui.d.ts +77 -175
- package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
- package/generated/versions/defold-1.13.0/http.d.ts +0 -13
- package/generated/versions/defold-1.13.0/image.d.ts +16 -33
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/json.d.ts +10 -6
- package/generated/versions/defold-1.13.0/label.d.ts +2 -3
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
- package/generated/versions/defold-1.13.0/material.d.ts +68 -106
- package/generated/versions/defold-1.13.0/model.d.ts +2 -10
- package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.13.0/physics.d.ts +69 -67
- package/generated/versions/defold-1.13.0/profiler.d.ts +2 -5
- package/generated/versions/defold-1.13.0/render.d.ts +99 -128
- package/generated/versions/defold-1.13.0/resource.d.ts +126 -150
- package/generated/versions/defold-1.13.0/socket.d.ts +34 -60
- package/generated/versions/defold-1.13.0/sound.d.ts +8 -8
- package/generated/versions/defold-1.13.0/sprite.d.ts +15 -5
- package/generated/versions/defold-1.13.0/sys.d.ts +37 -71
- package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -21
- package/generated/versions/defold-1.13.0/window.d.ts +1 -16
- package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
- package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
- package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
- package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
- package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
- package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
- package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
- package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
- package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
- package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
- package/generated/versions/defold-1.13.1/font.d.ts +81 -0
- package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
- package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
- package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.1/http.d.ts +77 -0
- package/generated/versions/defold-1.13.1/image.d.ts +131 -0
- package/generated/versions/defold-1.13.1/index.d.ts +57 -0
- package/generated/versions/defold-1.13.1/json.d.ts +80 -0
- package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.1/label.d.ts +93 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
- package/generated/versions/defold-1.13.1/material.d.ts +408 -0
- package/generated/versions/defold-1.13.1/model.d.ts +272 -0
- package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
- package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
- package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
- package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
- package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
- package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
- package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
- package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
- package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
- package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
- package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
- package/generated/versions/defold-1.13.1/types.d.ts +61 -0
- package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
- package/generated/versions/defold-1.13.1/window.d.ts +183 -0
- package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
- package/generated/vmath.d.ts +1 -21
- package/generated/window.d.ts +71 -71
- package/identity-vocabulary.json +561 -0
- package/index.d.ts +7 -0
- package/package.json +13 -2
- package/scripts/example-store-io.ts +12 -1
- package/scripts/extension-goldens.ts +1 -0
- package/scripts/fidelity-baseline.json +146 -46
- package/scripts/generate-api-availability.ts +90 -12
- package/scripts/generate-api-signatures.ts +12 -2
- package/scripts/import-defold-release.ts +85 -24
- package/scripts/prose-constants.ts +77 -16
- package/scripts/regen.ts +391 -77
- package/scripts/shared-handle-methods.ts +53 -0
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/sync-api-docs.ts +16 -5
- package/src/api-availability.ts +0 -0
- package/src/api-doc.ts +201 -3
- package/src/api-identity.ts +252 -0
- package/src/core-types.ts +26 -3
- package/src/correction-pins.ts +49 -0
- package/src/doc-comment.ts +104 -11
- package/src/doc-corrections.ts +108 -0
- package/src/editor-vm-globals.d.ts +5 -2
- package/src/emit-dts.ts +2064 -281
- package/src/emit-messages.ts +52 -0
- package/src/example-store.ts +125 -14
- package/src/field-correction-coverage.ts +204 -0
- package/src/fnv1a.ts +16 -0
- package/src/go-overloads.d.ts +25 -6
- package/src/index-base-table.ts +145 -0
- package/src/index-slot-classifications.ts +588 -0
- package/src/index.ts +38 -5
- package/src/library-index-slot-classifications.ts +332 -0
- package/src/lifecycle.ts +61 -199
- package/src/luals-type-expr.ts +354 -0
- package/src/msg-overloads.d.ts +0 -1
- package/src/param-correction-provenance.ts +8 -11
- package/src/render-overloads.d.ts +0 -15
- package/src/return-correction-provenance.ts +58 -16
- package/src/sys-overloads.d.ts +48 -0
- package/src/vmath-overloads.d.ts +27 -1
- package/src/window-event-guard.d.ts +6 -9
- package/url-parameters.json +1 -2
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"b2d.fixture.set_shape": [
|
|
15
15
|
{
|
|
16
16
|
"sourceHash": "ff836b80569f5d30",
|
|
17
|
-
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.fixture.get_shape(body, 1);\n
|
|
17
|
+
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.fixture.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.fixture.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"b2d.shape.set_shape": [
|
|
21
21
|
{
|
|
22
22
|
"sourceHash": "f31970e9ebb8d446",
|
|
23
|
-
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.shape.get_shape(body, 1);\n
|
|
23
|
+
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.shape.get_shape(body, 1);\n const radius = \"radius\" in circle ? circle.radius : undefined;\n b2d.shape.set_shape(body, 1, { type: b2d.shape.SHAPE_TYPE_CIRCLE, radius: radius ?? 16, center: vmath.vector3(24, 0, 0) }, true);\n b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"buffer.copy_buffer": [
|
|
@@ -53,6 +53,102 @@
|
|
|
53
53
|
"ts": "// How to set a metadata entry on a buffer\nconst buf = resource.get_buffer(\"/my.bufferc\");\n\n// create a new metadata entry with three floats\nbuffer.set_metadata(buf, hash(\"somefloats\"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);\n// ...\n// update to a new set of values\nbuffer.set_metadata(buf, hash(\"somefloats\"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);"
|
|
54
54
|
}
|
|
55
55
|
],
|
|
56
|
+
"bullet3d.collision_object.get_shapes": [
|
|
57
|
+
{
|
|
58
|
+
"sourceHash": "253c074f6a45c615",
|
|
59
|
+
"ts": "// Enumerate the logical shapes attached to a collision object:\nexport default defineScript({\n init() {\n const object = bullet3d.get_collision_object(\"#collisionobject\");\n if (object === undefined) return;\n for (const shape of bullet3d.collision_object.get_shapes(object)) {\n const index = bullet3d.shape.get_index(shape);\n const data = bullet3d.shape.get_shape(shape);\n print(\"shape\", index, \"type\", data.type);\n }\n },\n});"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"bullet3d.collision_object.set_ccd_motion_threshold": [
|
|
63
|
+
{
|
|
64
|
+
"sourceHash": "0969c6cba121a215",
|
|
65
|
+
"ts": "// Enable continuous collision detection for a small, fast-moving body:\nexport default defineScript({\n init() {\n const body = bullet3d.get_rigid_body(\"#collisionobject\");\n if (body === undefined) return;\n bullet3d.collision_object.set_ccd_swept_sphere_radius(body, 0.25);\n bullet3d.collision_object.set_ccd_motion_threshold(body, 0.5);\n },\n});"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"bullet3d.collision_object.set_world_transform": [
|
|
69
|
+
{
|
|
70
|
+
"sourceHash": "23d7b59707855f9f",
|
|
71
|
+
"ts": "// Move a collision object while preserving its rotation:\nexport default defineScript({\n init() {\n const object = bullet3d.get_collision_object(\"#collisionobject\");\n if (object === undefined) return;\n const [position, rotation] = bullet3d.collision_object.get_world_transform(object);\n bullet3d.collision_object.set_world_transform(object, position.add(vmath.vector3(0, 5, 0)), rotation);\n bullet3d.collision_object.activate(object, true);\n },\n});"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"bullet3d.constraint.create_generic_6dof_spring": [
|
|
75
|
+
{
|
|
76
|
+
"sourceHash": "208db6534df9ca4a",
|
|
77
|
+
"ts": "// Create a spring that moves along its first linear axis:\nexport default defineScript({\n init() {\n const body_a = bullet3d.get_rigid_body(\"/body_a#collisionobject\");\n const body_b = bullet3d.get_rigid_body(\"/body_b#collisionobject\");\n let spring: bullet3d.constraint.btTypedConstraint | undefined;\n if (body_a !== undefined && body_b !== undefined) {\n spring = bullet3d.constraint.create_generic_6dof_spring(body_a, body_b, {\n frame_a_position: vmath.vector3(),\n frame_a_rotation: vmath.quat(),\n frame_b_position: vmath.vector3(),\n frame_b_rotation: vmath.quat(),\n });\n bullet3d.constraint.set_limit(spring, 1, -1, 1);\n bullet3d.constraint.enable_spring(spring, 1, true);\n bullet3d.constraint.set_spring_stiffness(spring, 1, 20);\n bullet3d.constraint.set_spring_damping(spring, 1, 0.5);\n bullet3d.constraint.set_spring_equilibrium_point(spring, 1, 0);\n }\n return { spring };\n },\n\n final(self) {\n if (self.spring !== undefined && bullet3d.constraint.is_valid(self.spring)) {\n bullet3d.constraint.destroy(self.spring);\n }\n },\n});"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"bullet3d.constraint.create_hinge": [
|
|
81
|
+
{
|
|
82
|
+
"sourceHash": "76ffd570e08f0b18",
|
|
83
|
+
"ts": "// Create a motorized hinge with a 90-degree range:\nexport default defineScript({\n init() {\n const body_a = bullet3d.get_rigid_body(\"/door#collisionobject\");\n const body_b = bullet3d.get_rigid_body(\"/frame#collisionobject\");\n let hinge: bullet3d.constraint.btTypedConstraint | undefined;\n if (body_a !== undefined) {\n hinge = bullet3d.constraint.create_hinge(body_a, body_b, {\n frame_a_position: vmath.vector3(-0.5, 0, 0),\n frame_a_rotation: vmath.quat(),\n frame_b_position: vmath.vector3(0.5, 0, 0),\n frame_b_rotation: vmath.quat(),\n });\n bullet3d.constraint.set_hinge_limits(hinge, -math.pi / 4, math.pi / 4);\n bullet3d.constraint.set_hinge_motor(hinge, true, 1.5, 2.5);\n }\n return { hinge };\n },\n\n final(self) {\n if (self.hinge !== undefined && bullet3d.constraint.is_valid(self.hinge)) {\n bullet3d.constraint.destroy(self.hinge);\n }\n },\n});"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"bullet3d.constraint.create_point_to_point": [
|
|
87
|
+
{
|
|
88
|
+
"sourceHash": "91bc34d28899d0c1",
|
|
89
|
+
"ts": "// Join two bodies at matching local pivots and explicitly destroy the\n// constraint when the script is finalized:\nexport default defineScript({\n init() {\n const body_a = bullet3d.get_rigid_body(\"/body_a#collisionobject\");\n const body_b = bullet3d.get_rigid_body(\"/body_b#collisionobject\");\n let constraint: bullet3d.constraint.btTypedConstraint | undefined;\n if (body_a !== undefined) {\n constraint = bullet3d.constraint.create_point_to_point(body_a, body_b, {\n pivot_a: vmath.vector3(0.5, 0, 0),\n pivot_b: vmath.vector3(-0.5, 0, 0),\n });\n }\n return { constraint };\n },\n\n final(self) {\n if (self.constraint !== undefined && bullet3d.constraint.is_valid(self.constraint)) {\n bullet3d.constraint.destroy(self.constraint);\n }\n },\n});"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"bullet3d.get_rigid_body": [
|
|
93
|
+
{
|
|
94
|
+
"sourceHash": "e09c75e81d50dd6c",
|
|
95
|
+
"ts": "const world = bullet3d.get_world();\nconst body = bullet3d.get_rigid_body(\"#collisionobject\");\nif (world !== undefined && body !== undefined && bullet3d.rigid_body.is_valid(body)) {\n bullet3d.rigid_body.apply_central_impulse(body, vmath.vector3(0, 10, 0));\n}\n\n// A trigger is a collision object, not a rigid body.\nconst trigger = bullet3d.get_collision_object(\"#trigger\");\nassert(trigger !== undefined && bullet3d.get_rigid_body(\"#trigger\") === undefined);"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"bullet3d.rigid_body.apply_force": [
|
|
99
|
+
{
|
|
100
|
+
"sourceHash": "9f7182e8b1f12712",
|
|
101
|
+
"ts": "// Apply an upward force at the game object's current world position:\nexport default defineScript({\n init() {\n const body = bullet3d.get_rigid_body(\"#collisionobject\");\n if (body === undefined) return;\n const force = vmath.vector3(0, 100, 0);\n bullet3d.rigid_body.apply_force(body, force, go.get_world_position());\n },\n});"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"bullet3d.rigid_body.set_gravity": [
|
|
105
|
+
{
|
|
106
|
+
"sourceHash": "c790938f15458c40",
|
|
107
|
+
"ts": "// Give one body persistent custom gravity without discarding its other flags:\nexport default defineScript({\n init() {\n const body = bullet3d.get_rigid_body(\"#collisionobject\");\n if (body === undefined) return;\n let flags = bullet3d.rigid_body.get_flags(body);\n flags = bit.bor(flags, bullet3d.rigid_body.BT_DISABLE_WORLD_GRAVITY);\n bullet3d.rigid_body.set_flags(body, flags);\n bullet3d.rigid_body.set_gravity(body, vmath.vector3(0, 4, 0));\n },\n});"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"bullet3d.rigid_body.set_mass": [
|
|
111
|
+
{
|
|
112
|
+
"sourceHash": "6f1ffcb5da18e9db",
|
|
113
|
+
"ts": "// Change the mass of a dynamic collision object and inspect its recalculated inertia:\nexport default defineScript({\n init() {\n const body = bullet3d.get_rigid_body(\"#collisionobject\");\n if (body === undefined) return;\n bullet3d.rigid_body.set_mass(body, 5);\n print(\"local inertia\", bullet3d.rigid_body.get_local_inertia(body));\n },\n});"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"bullet3d.shape.set_shape": [
|
|
117
|
+
{
|
|
118
|
+
"sourceHash": "822278c5e2152e23",
|
|
119
|
+
"ts": "// Increase the dimensions of the first box shape by 50 percent for this instance:\nexport default defineScript({\n init() {\n const object = bullet3d.get_collision_object(\"#collisionobject\");\n if (object === undefined) return;\n const shape = bullet3d.collision_object.get_shape(object, 1);\n const data = bullet3d.shape.get_shape(shape);\n\n if (data.type === bullet3d.shape.SHAPE_TYPE_BOX && \"dimensions\" in data) {\n data.dimensions = data.dimensions.mul(1.5);\n bullet3d.shape.set_shape(shape, data);\n }\n },\n});"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"bullet3d.world.cast_ray_async": [
|
|
123
|
+
{
|
|
124
|
+
"sourceHash": "bcd124b063567325",
|
|
125
|
+
"ts": "// Queue a downward cast and inspect only the closest non-trigger hit:\nconst world = bullet3d.get_world();\nif (world !== undefined) {\n bullet3d.world.cast_ray_async(\n world,\n go.get_world_position(),\n vmath.vector3(0, -100, 0),\n (self, hits) => {\n const hit = hits[0];\n if (hit !== undefined) {\n print(\"hit\", hit.object);\n }\n },\n { include_triggers: false },\n 1,\n );\n}"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"bullet3d.world.cast_ray_closest": [
|
|
129
|
+
{
|
|
130
|
+
"sourceHash": "e0695680d5f69806",
|
|
131
|
+
"ts": "// Cast downward and report the closest non-trigger hit:\nexport default defineScript({\n init() {\n const world = bullet3d.get_world();\n if (world === undefined) return;\n const origin = go.get_world_position();\n const translation = vmath.vector3(0, -100, 0);\n const filter = { include_triggers: false };\n\n const hit = bullet3d.world.cast_ray_closest(world, origin, translation, filter);\n if (hit !== undefined) {\n const distance = vmath.length(translation) * hit.fraction;\n print(\"hit\", hit.object, \"after\", distance, \"units\");\n }\n },\n});"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"bullet3d.world.contact_test": [
|
|
135
|
+
{
|
|
136
|
+
"sourceHash": "24e4e290d62e54f3",
|
|
137
|
+
"ts": "// Inspect current contacts for this collision object:\nexport default defineScript({\n update(self, dt) {\n const world = bullet3d.get_world();\n const object = bullet3d.get_collision_object(\"#collisionobject\");\n if (world === undefined || object === undefined) return;\n const filter = { include_triggers: false };\n const contacts = bullet3d.world.contact_test(world, object, filter);\n\n for (const contact of contacts) {\n if (contact.distance < 0) {\n print(\"penetration\", -contact.distance, \"against\", contact.object_b);\n }\n }\n },\n});"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"bullet3d.world.overlap_shape": [
|
|
141
|
+
{
|
|
142
|
+
"sourceHash": "2b15e4c9166eeb30",
|
|
143
|
+
"ts": "// Find non-trigger objects overlapping a two-unit sphere around this game object:\nexport default defineScript({\n init() {\n const world = bullet3d.get_world();\n if (world === undefined) return;\n const shape = {\n type: bullet3d.shape.SHAPE_TYPE_SPHERE,\n diameter: 2,\n position: go.get_world_position(),\n };\n const filter = { include_triggers: false };\n const overlaps = bullet3d.world.overlap_shape(world, shape, filter);\n\n for (const object of overlaps) {\n print(\"overlap\", object);\n }\n },\n});"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"bullet3d.world.set_gravity": [
|
|
147
|
+
{
|
|
148
|
+
"sourceHash": "d97b405b0c249b8c",
|
|
149
|
+
"ts": "// Set gravity for the current collection's physics world:\nexport default defineScript({\n init() {\n const world = bullet3d.get_world();\n if (world !== undefined) {\n bullet3d.world.set_gravity(world, vmath.vector3(0, -9.81, 0));\n }\n },\n});"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
56
152
|
"camera.get_cameras": [
|
|
57
153
|
{
|
|
58
154
|
"sourceHash": "d332d9320898b958",
|
|
@@ -79,8 +175,12 @@
|
|
|
79
175
|
],
|
|
80
176
|
"collectionfactory.create": [
|
|
81
177
|
{
|
|
82
|
-
"sourceHash": "
|
|
83
|
-
"ts": "
|
|
178
|
+
"sourceHash": "1ba3a94b5d04c5a0",
|
|
179
|
+
"ts": "export default defineScript({\n init() {\n // Spawn a small group of enemies.\n const pos = vmath.vector3(100, 12.5, 0);\n const rot = vmath.quat_rotation_z(Math.PI / 2);\n const scale = 0.5;\n const props = new LuaMap<Hash, Record<string, unknown>>();\n props.set(hash(\"/enemy_leader\"), { health: 1000.0 });\n props.set(hash(\"/enemy_1\"), { health: 200.0 });\n props.set(hash(\"/enemy_2\"), { health: 400.0, color: hash(\"green\") });\n\n const enemy_ids = collectionfactory.create(\"#enemyfactory\", pos, rot, props, scale);\n // enemy_ids now map to the spawned instance ids:\n //\n // pprint(self.enemy_ids)\n //\n // DEBUG:SCRIPT:\n // {\n // hash: [/enemy_leader] = hash: [/collection0/enemy_leader],\n // hash: [/enemy_1] = hash: [/collection0/enemy_1],\n // hash: [/enemy_2] = hash: [/collection0/enemy_2]\n // }\n\n // Send \"attack\" message to the leader. First look up its instance id.\n const leader_id = enemy_ids.get(hash(\"/enemy_leader\"));\n if (leader_id !== undefined) {\n msg.post(leader_id, \"attack\");\n }\n return { enemy_ids };\n },\n});"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"sourceHash": "4a14456855350b8c",
|
|
183
|
+
"ts": "function delete_enemies(self: { enemy_ids: Hash[] }) {\n go.delete(self.enemy_ids);\n}"
|
|
84
184
|
}
|
|
85
185
|
],
|
|
86
186
|
"collectionfactory.load": [
|
|
@@ -157,8 +257,16 @@
|
|
|
157
257
|
],
|
|
158
258
|
"editor.bob": [
|
|
159
259
|
{
|
|
160
|
-
"sourceHash": "
|
|
161
|
-
"ts": "
|
|
260
|
+
"sourceHash": "2d2af2a8d67e6042",
|
|
261
|
+
"ts": "editor.bob({ help: true });"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"sourceHash": "daf12f556b1915ae",
|
|
265
|
+
"ts": "const opts = { archive: true, platform: editor.platform };\neditor.bob(opts, \"distclean\", \"resolve\", \"build\", \"bundle\");"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"sourceHash": "9e755fcbee26e790",
|
|
269
|
+
"ts": "const opts = {\n archive: true,\n platform: editor.platform,\n build_server: \"https://build.my-company.com\",\n settings: [\"test.ini\", \"headless.ini\"],\n};\neditor.bob(opts, \"distclean\", \"resolve\", \"build\");"
|
|
162
270
|
}
|
|
163
271
|
],
|
|
164
272
|
"editor.command": [
|
|
@@ -175,8 +283,16 @@
|
|
|
175
283
|
],
|
|
176
284
|
"editor.create_resources": [
|
|
177
285
|
{
|
|
178
|
-
"sourceHash": "
|
|
179
|
-
"ts": "
|
|
286
|
+
"sourceHash": "dd9b866b84f9de49",
|
|
287
|
+
"ts": "editor.create_resources([\"/npc.go\"]);"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"sourceHash": "86faf70ca56cf8a6",
|
|
291
|
+
"ts": "editor.create_resources([\"/npc.go\", \"/levels/1.collection\", \"/levels/2.collection\"]);"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"sourceHash": "f29c4cbd5eb7bb65",
|
|
295
|
+
"ts": "editor.create_resources([{ 1: \"/npc.script\", 2: \"go.property('hp', 100)\" }]);"
|
|
180
296
|
}
|
|
181
297
|
],
|
|
182
298
|
"editor.delete_directory": [
|
|
@@ -187,14 +303,18 @@
|
|
|
187
303
|
],
|
|
188
304
|
"editor.execute": [
|
|
189
305
|
{
|
|
190
|
-
"sourceHash": "
|
|
191
|
-
"ts": "
|
|
306
|
+
"sourceHash": "d5e0db47ebda0546",
|
|
307
|
+
"ts": "editor.execute(\"mkdir\", \"new dir\");"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"sourceHash": "5044e4584bab1ea9",
|
|
311
|
+
"ts": "const status = editor.execute(\"git\", \"status\", \"--porcelain\", {\n reload_resources: false,\n out: \"capture\",\n});"
|
|
192
312
|
}
|
|
193
313
|
],
|
|
194
314
|
"editor.ui.use_memo": [
|
|
195
315
|
{
|
|
196
316
|
"sourceHash": "dac97ede337c4f69",
|
|
197
|
-
"ts": "function increment(n: unknown): number {\n return (n as number) + 1;\n}\n\nfunction makeListener(setCount: unknown) {\n return () => {\n (setCount as (update: unknown) => unknown)(increment);\n };\n}\n\nconst counterButton = editor.ui.component((props) => {\n const [count, setCount] = editor.ui.use_state((props as { count: unknown }).count);\n const onPressed = editor.ui.use_memo(makeListener, setCount);\n return editor.ui.button({\n text: tostring(count),\n on_pressed: onPressed,\n });\n});"
|
|
317
|
+
"ts": "function increment(n: unknown): number {\n return (n as number) + 1;\n}\n\nfunction makeListener(setCount: unknown) {\n return () => {\n (setCount as (update: unknown) => unknown)(increment);\n };\n}\n\nconst counterButton = editor.ui.component((props) => {\n const [count, setCount] = editor.ui.use_state((props as { count: unknown }).count);\n const onPressed = editor.ui.use_memo(makeListener, setCount) as () => void;\n return editor.ui.button({\n text: tostring(count),\n on_pressed: onPressed,\n });\n});"
|
|
198
318
|
}
|
|
199
319
|
],
|
|
200
320
|
"editor.ui.use_state": [
|
|
@@ -205,8 +325,12 @@
|
|
|
205
325
|
],
|
|
206
326
|
"factory.create": [
|
|
207
327
|
{
|
|
208
|
-
"sourceHash": "
|
|
209
|
-
"ts": "
|
|
328
|
+
"sourceHash": "df32ef57d1e2366e",
|
|
329
|
+
"ts": "export default defineScript({\n init(self) {\n // create a new game object and provide property values\n const created = factory.create(\"#factory\", undefined, undefined, { my_value: 1 });\n // communicate with the object\n msg.post(created, \"hello\");\n },\n});"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"sourceHash": "981a4891837250a9",
|
|
333
|
+
"ts": "go.property(\"my_value\", 0);\n\nexport default defineScript({\n init(self) {\n // do something with self.my_value which is now one\n },\n});"
|
|
210
334
|
}
|
|
211
335
|
],
|
|
212
336
|
"factory.load": [
|
|
@@ -251,6 +375,12 @@
|
|
|
251
375
|
"ts": "const font_hash = hash(\"/assets/fonts/roboto.fontc\");\nconst ttf_hash = hash(\"/assets/fonts/Roboto/Roboto-Bold.ttf\");\nfont.remove_font(font_hash, ttf_hash);"
|
|
252
376
|
}
|
|
253
377
|
],
|
|
378
|
+
"font.set_style": [
|
|
379
|
+
{
|
|
380
|
+
"sourceHash": "ec2d9af51ad582c9",
|
|
381
|
+
"ts": "font.set_style(\"/fonts/ui.fontc\", \"link:hover\", \"<color=#66b3ff><outline color=#000000 size=1><shake amplitude=0.2>\");"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
254
384
|
"go.animate": [
|
|
255
385
|
{
|
|
256
386
|
"sourceHash": "c4fc72e0b8812778",
|
|
@@ -297,8 +427,36 @@
|
|
|
297
427
|
],
|
|
298
428
|
"go.get": [
|
|
299
429
|
{
|
|
300
|
-
"sourceHash": "
|
|
301
|
-
"ts": "
|
|
430
|
+
"sourceHash": "bf6bc560db059a69",
|
|
431
|
+
"ts": "go.property(\"speed\", 50);"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"sourceHash": "6c13a2e33f4f0c98",
|
|
435
|
+
"ts": "const speed = go.get(\"#player\", \"speed\");"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"sourceHash": "decf402c4b246359",
|
|
439
|
+
"ts": "// the glsl indices are 0-based\nconst url = msg.url(\"#mesh\");\ngo.get(url, \"example\", { index: 1 }); // the first vector4 in the array: example[0]\ngo.get(url, \"example\", { index: 16 }); // the last vector4 in the array: example[15]\ngo.get(url, \"example.x\", { index: 1 }); // an element of a vector4: example[0].x"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"sourceHash": "cd59aaeb4278cdfc",
|
|
443
|
+
"ts": "const url = msg.url(\"#mesh\");\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\ngo.get(url, \"example.x\"); // => [number1, number2, ...]"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"sourceHash": "4b5cae0c647b3381",
|
|
447
|
+
"ts": "// get the resource of a certain gui font\nconst font_hash = go.get(\"#gui\", \"fonts\", { key: \"system_font_BIG\" });"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"sourceHash": "ecf8c97d1bcaf7d3",
|
|
451
|
+
"ts": "// Addressing the first level of a component:\ngo.get(\"#particlefx\", \"material\", { keys: [\"cone_emitter\"] });"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"sourceHash": "df724fc6773a584b",
|
|
455
|
+
"ts": "// Note: no built-in component supports this yet, but a custom one could.\ngo.get(\"#my_component\", \"some_property\", { keys: [\"root\", \"child_node\"] });"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"sourceHash": "3ba93bc03f7948cc",
|
|
459
|
+
"ts": "const url = msg.url(\"#mesh\");\n// get all vector4's in the constant array\ngo.get(url, \"example\"); // => [vector4, vector4, ...]\n// get all elements of the vector4's from an array\ngo.get(url, \"example.x\"); // => [number1, number2, ...]"
|
|
302
460
|
}
|
|
303
461
|
],
|
|
304
462
|
"go.get_id": [
|
|
@@ -411,12 +569,48 @@
|
|
|
411
569
|
{
|
|
412
570
|
"sourceHash": "96e6079cda36fa54",
|
|
413
571
|
"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});"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"sourceHash": "94d9f68e3db7056c",
|
|
575
|
+
"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});"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"sourceHash": "a56e7919856fdf57",
|
|
579
|
+
"ts": "// Text properties can contain UTF-8 and newline characters:\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registrations from this field, and only this field types them onto `self`.\n properties: { player_name: \"Player One\", dialogue: \"First line\\nSecond line\" },\n});"
|
|
414
580
|
}
|
|
415
581
|
],
|
|
416
582
|
"go.set": [
|
|
417
583
|
{
|
|
418
|
-
"sourceHash": "
|
|
419
|
-
"ts": "
|
|
584
|
+
"sourceHash": "bf6bc560db059a69",
|
|
585
|
+
"ts": "go.property(\"speed\", 50);"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"sourceHash": "dcb0970a052d80a0",
|
|
589
|
+
"ts": "go.set(\"#player\", \"speed\", 100);"
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
"sourceHash": "150af4281adacf42",
|
|
593
|
+
"ts": "// the glsl indices are 0-based\nconst url = msg.url(\"#mesh\");\ngo.set(url, \"example\", vmath.vector4(1, 1, 1, 1), { index: 1 }); // example[0] = v\ngo.set(url, \"example\", vmath.vector4(2, 2, 2, 2), { index: 16 }); // example[15] = v\ngo.set(url, \"example.x\", 7, { index: 1 }); // example[0].x = 7"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"sourceHash": "fb7b5aefbb9fad4b",
|
|
597
|
+
"ts": "// set the first two vector4's in the array\n// if the array has more than two elements in the array they will not be set\nconst url = msg.url(\"#mesh\");\ngo.set(url, \"example\", [vmath.vector4(1, 1, 1, 1), vmath.vector4(2, 2, 2, 2)]);"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
"sourceHash": "ea5b1b6430458d24",
|
|
601
|
+
"ts": "go.property(\"big_font\", resource.font());\n\nfunction set_named_font(self: { big_font: Hash }) {\n go.set(\"#gui\", \"fonts\", self.big_font, { key: \"system_font_BIG\" });\n}"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"sourceHash": "bb73335ad4c5f1fe",
|
|
605
|
+
"ts": "go.property(\"my_material\", resource.material());\n\nfunction set_sub_component_material(self: { my_material: Hash }) {\n go.set(\"#particlefx\", \"material\", self.my_material, { keys: [\"cone_emitter\"] });\n}"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"sourceHash": "2a68fe57bedcd5c1",
|
|
609
|
+
"ts": "// Note: no built-in component supports this yet, but a custom one could.\nconst some_value = 1;\ngo.set(\"#my_component\", \"some_property\", some_value, { keys: [\"root\", \"child_node\"] });"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"sourceHash": "54eab9a4ddd280ac",
|
|
613
|
+
"ts": "go.property(\"big_font\", resource.font());\n\nfunction set_named_font(self: { big_font: Hash }) {\n go.set(\"#gui\", \"fonts\", self.big_font, { key: \"system_font_BIG\" });\n}"
|
|
420
614
|
}
|
|
421
615
|
],
|
|
422
616
|
"go.set_parent": [
|
|
@@ -511,8 +705,12 @@
|
|
|
511
705
|
],
|
|
512
706
|
"gui.cancel_animations": [
|
|
513
707
|
{
|
|
514
|
-
"sourceHash": "
|
|
515
|
-
"ts": "
|
|
708
|
+
"sourceHash": "4887f66e427b7c8e",
|
|
709
|
+
"ts": "const node = gui.get_node(\"my_node\");\n// animate to new position\nconst pos = vmath.vector3(100, 100, 0);\ngui.animate(node, \"position\", pos, gui.EASING_LINEAR, 2);\n// ...\n// cancel animation of the x component.\ngui.cancel_animations(node, \"position.x\");"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"sourceHash": "62239db9b4ffcfec",
|
|
713
|
+
"ts": "const node = gui.get_node(\"my_node\");\n// animate to new position and scale\ngui.animate(node, \"position\", vmath.vector3(100, 100, 0), gui.EASING_LINEAR, 5);\ngui.animate(node, \"scale\", vmath.vector3(0.5), gui.EASING_LINEAR, 5);\n// ...\n// cancel positioning and scaling at once\ngui.cancel_animations(node);"
|
|
516
714
|
}
|
|
517
715
|
],
|
|
518
716
|
"gui.cancel_flipbook": [
|
|
@@ -571,14 +769,22 @@
|
|
|
571
769
|
],
|
|
572
770
|
"gui.new_texture": [
|
|
573
771
|
{
|
|
574
|
-
"sourceHash": "
|
|
575
|
-
"ts": "
|
|
772
|
+
"sourceHash": "b649d09aecc014e4",
|
|
773
|
+
"ts": "export default defineGuiScript({\n init(self) {\n const w = 200;\n const h = 300;\n\n // A nice orange. String with the RGB values.\n const orange = String.fromCharCode(0xff, 0x80, 0x10);\n\n // Create the texture. Repeat the color string for each pixel.\n const [ok, reason] = gui.new_texture(\"orange_tx\", w, h, \"rgb\", orange.repeat(w * h));\n if (ok) {\n // Create a box node and apply the texture to it.\n const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));\n gui.set_texture(n, \"orange_tx\");\n } else {\n // Could not create texture for some reason...\n if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {\n // ...\n } else {\n // ...\n }\n }\n },\n});"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
"sourceHash": "3279c780ce37ad44",
|
|
777
|
+
"ts": "const size = 4;\nconst pos = vmath.vector3(200, 200, 0);\nconst path = \"/assets/images/logo_4x4.astc\";\nconst [data] = sys.load_resource(path);\nif (data !== undefined) {\n const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));\n // size is read from the .astc buffer\n // flip is not supported\n gui.new_texture(path, 0, 0, \"astc\", data, false);\n gui.set_texture(n, path);\n}"
|
|
576
778
|
}
|
|
577
779
|
],
|
|
578
780
|
"gui.play_flipbook": [
|
|
579
781
|
{
|
|
580
|
-
"sourceHash": "
|
|
581
|
-
"ts": "
|
|
782
|
+
"sourceHash": "766767de34e4e6a2",
|
|
783
|
+
"ts": "function anim_callback(self: unknown, node: unknown) {\n // Take action after animation has played.\n}\n\nexport default defineGuiScript({\n init(self) {\n // Create a new node and set the texture to a flipbook animation\n const node = gui.get_node(\"button_node\");\n gui.set_texture(node, \"gui_sprites\");\n gui.play_flipbook(node, \"animated_button\");\n },\n});"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"sourceHash": "90aa26229f63af7e",
|
|
787
|
+
"ts": "// Create a new node and set the texture to a \"button.png\" from atlas\nconst node = gui.get_node(\"button_node\");\ngui.set_texture(node, \"gui_sprites\");\ngui.play_flipbook(node, \"button\");"
|
|
582
788
|
}
|
|
583
789
|
],
|
|
584
790
|
"gui.play_particlefx": [
|
|
@@ -601,12 +807,24 @@
|
|
|
601
807
|
],
|
|
602
808
|
"gui.set": [
|
|
603
809
|
{
|
|
604
|
-
"sourceHash": "
|
|
605
|
-
"ts": "
|
|
810
|
+
"sourceHash": "0b505e5f92fd4aff",
|
|
811
|
+
"ts": "const node = gui.get_node(\"my_box_node\");\nconst node_position = gui.get(node, \"position\") as Vector3;\ngui.set(node, \"position.x\", node_position.x + 128);"
|
|
606
812
|
},
|
|
607
813
|
{
|
|
608
|
-
"sourceHash": "
|
|
609
|
-
"ts": "
|
|
814
|
+
"sourceHash": "8ed6f5c059ba2496",
|
|
815
|
+
"ts": "const node = gui.get_node(\"my_box_node\");\ngui.set(node, \"rotation\", vmath.quat_rotation_z(math.rad(45)));\n// this is equivalent to:\ngui.set(node, \"euler.z\", 45);\n// or using the entire vector:\ngui.set(node, \"euler\", vmath.vector3(0, 0, 45));\n// or using the set_rotation\ngui.set_rotation(node, vmath.vector3(0, 0, 45));"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"sourceHash": "2a8317babd507565",
|
|
819
|
+
"ts": "const node = gui.get_node(\"my_box_node\");\ngui.set(node, \"tint\", vmath.vector4(1, 0, 0, 1));\n// matrix4 is also supported\ngui.set(node, \"light_matrix\", vmath.matrix4());\n// update a constant in an array at position 4. the array is specified in the shader as:\n// uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based\ngui.set(node, \"tint_array\", vmath.vector4(1, 0, 0, 1), { index: 4 });\n// update a matrix constant in an array at position 4. the array is specified in the shader as:\n// uniform mat4 light_matrix_array[4];\ngui.set(node, \"light_matrix_array\", vmath.matrix4(), { index: 4 });\n// update a sub-element in a constant\ngui.set(node, \"tint.x\", 1);\n// update a sub-element in an array constant at position 4\ngui.set(node, \"tint_array.x\", 1, { index: 4 });"
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
"sourceHash": "b52d73e25b02e93f",
|
|
823
|
+
"ts": "export default defineGuiScript({\n on_message(self, message_id, message) {\n if (message_id === hash(\"set_font\") && types.is_hash(message.font)) {\n gui.set(msg.url(), \"fonts\", message.font, { key: \"my_font_name\" });\n gui.set_font(gui.get_node(\"text\"), \"my_font_name\");\n } else if (message_id === hash(\"set_texture\") && types.is_hash(message.texture)) {\n gui.set(msg.url(), \"textures\", message.texture, { key: \"my_texture\" });\n gui.set_texture(gui.get_node(\"box\"), \"my_texture\");\n gui.play_flipbook(gui.get_node(\"box\"), \"logo_256\");\n }\n },\n});"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"sourceHash": "8e2e40668493072c",
|
|
827
|
+
"ts": "const atlas_params = {\n texture: \"/runtime.texturec\",\n animations: [{ id: \"runtime\", width: 1, height: 1, frames: [1] }],\n geometries: [{ vertices: [0, 0, 0, 1, 1, 1, 1, 0], uvs: [0, 0, 0, 1, 1, 1, 1, 0], indices: [0, 1, 2, 0, 2, 3] }],\n} satisfies Parameters<typeof resource.create_atlas>[1];\nconst atlas_id = resource.create_atlas(\"/runtime.texturesetc\", atlas_params);\ngui.set(msg.url(), \"textures\", atlas_id, { key: \"runtime_texture\" });\ngui.set_texture(gui.get_node(\"box\"), \"runtime_texture\");\n\n// Later, remove the GUI mapping before releasing the atlas resource.\ngui.set(msg.url(), \"textures\", undefined, { key: \"runtime_texture\" });\nresource.release(atlas_id);"
|
|
610
828
|
}
|
|
611
829
|
],
|
|
612
830
|
"gui.set_id": [
|
|
@@ -623,8 +841,12 @@
|
|
|
623
841
|
],
|
|
624
842
|
"gui.set_texture": [
|
|
625
843
|
{
|
|
626
|
-
"sourceHash": "
|
|
627
|
-
"ts": "
|
|
844
|
+
"sourceHash": "27917506578ef40c",
|
|
845
|
+
"ts": "const node = gui.get_node(\"box_node\");\ngui.set_texture(node, \"my_atlas\");\ngui.play_flipbook(node, \"image\");"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"sourceHash": "63abf329a2522305",
|
|
849
|
+
"ts": "const w = 200;\nconst h = 300;\n// A nice orange. String with the RGB values.\nconst orange = String.fromCharCode(0xff, 0x80, 0x10);\n// Create the texture. Repeat the color string for each pixel.\nconst [ok] = gui.new_texture(\"orange_tx\", w, h, \"rgb\", orange.repeat(w * h));\nif (ok) {\n const node = gui.get_node(\"box_node\");\n gui.set_texture(node, \"orange_tx\");\n}"
|
|
628
850
|
}
|
|
629
851
|
],
|
|
630
852
|
"gui.set_texture_data": [
|
|
@@ -666,7 +888,7 @@
|
|
|
666
888
|
"image.load_buffer": [
|
|
667
889
|
{
|
|
668
890
|
"sourceHash": "55649cadc660e25e",
|
|
669
|
-
"ts": "// Load an image from an URL as a buffer and create a texture resource from it:\nconst imgurl = \"http://www.site.com/image.png\";\nhttp.request(imgurl, \"GET\", (self, id, response) => {\n const img =\n response.response !== undefined\n ? image.load_buffer(response.response, { flip_vertically: true })\n : undefined;\n if (img !== undefined) {\n const tparams = {\n width: img.width,\n height: img.height,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
891
|
+
"ts": "// Load an image from an URL as a buffer and create a texture resource from it:\nconst imgurl = \"http://www.site.com/image.png\";\nhttp.request(imgurl, \"GET\", (self, id, response) => {\n const img =\n response.response !== undefined\n ? image.load_buffer(response.response, { flip_vertically: true })\n : undefined;\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (img !== undefined && format !== undefined) {\n const tparams = {\n width: img.width,\n height: img.height,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, img.buffer);\n // Apply the texture to a model\n go.set(\"/go1#model\", \"texture0\", my_texture_id);\n }\n});"
|
|
670
892
|
}
|
|
671
893
|
],
|
|
672
894
|
"init": [
|
|
@@ -677,26 +899,48 @@
|
|
|
677
899
|
],
|
|
678
900
|
"json.decode": [
|
|
679
901
|
{
|
|
680
|
-
"sourceHash": "
|
|
681
|
-
"ts": "
|
|
902
|
+
"sourceHash": "8dcdd6f81ef65528",
|
|
903
|
+
"ts": "export default defineScript({\n init() {\n const jsonstring = '{\"persons\":[{\"name\":\"John Doe\"},{\"name\":\"Darth Vader\"}]}';\n const data = json.decode(jsonstring);\n pprint(data);\n },\n});"
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"sourceHash": "4cd6b13a31344b55",
|
|
907
|
+
"ts": "// {\n// persons = {\n// 1 = {\n// name = John Doe,\n// }\n// 2 = {\n// name = Darth Vader,\n// }\n// }\n// }"
|
|
682
908
|
}
|
|
683
909
|
],
|
|
684
910
|
"json.encode": [
|
|
685
911
|
{
|
|
686
|
-
"sourceHash": "
|
|
687
|
-
"ts": "
|
|
912
|
+
"sourceHash": "cd58784a46da5fcb",
|
|
913
|
+
"ts": "export default defineScript({\n init() {\n const tbl = {\n persons: [{ name: \"John Doe\" }, { name: \"Darth Vader\" }],\n };\n const jsonstring = json.encode(tbl);\n pprint(jsonstring);\n },\n});"
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
"sourceHash": "2bb4b4f7cdbb2f0f",
|
|
917
|
+
"ts": "// {\"persons\":[{\"name\":\"John Doe\"},{\"name\":\"Darth Vader\"}]}"
|
|
918
|
+
}
|
|
919
|
+
],
|
|
920
|
+
"label.get_layout_objects": [
|
|
921
|
+
{
|
|
922
|
+
"sourceHash": "cb0d030f627da4ea",
|
|
923
|
+
"ts": "const objects = label.get_layout_objects(\"#label\");\nfor (const object of objects) {\n if (object.type === \"link\") {\n print(object.attributes.get(\"src\"), object.text_offset, object.text_length);\n } else if (object.type === \"sprite\") {\n print(object.attributes.get(\"src\"), object.x, object.y, object.width, object.height);\n }\n}"
|
|
688
924
|
}
|
|
689
925
|
],
|
|
690
926
|
"label.get_text": [
|
|
691
927
|
{
|
|
692
928
|
"sourceHash": "f1c34d0aca8a07d9",
|
|
693
929
|
"ts": "export default defineScript({\n init(self) {\n const text = label.get_text(\"#label\");\n print(text);\n },\n});"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"sourceHash": "877de2c1daa19e58",
|
|
933
|
+
"ts": "export default defineScript({\n init() {\n const text = go.get<label.properties>()(\"#label\", \"text\");\n print(text);\n },\n});"
|
|
694
934
|
}
|
|
695
935
|
],
|
|
696
936
|
"label.set_text": [
|
|
697
937
|
{
|
|
698
938
|
"sourceHash": "0d47c9a209b0d646",
|
|
699
939
|
"ts": "export default defineScript({\n init(self) {\n label.set_text(\"#label\", \"Hello World!\");\n },\n});"
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
"sourceHash": "2ac0aeb70ccdc6bf",
|
|
943
|
+
"ts": "export default defineScript({\n init() {\n go.set<label.properties>()(\"#label\", \"text\", \"Hello World!\");\n },\n});"
|
|
700
944
|
}
|
|
701
945
|
],
|
|
702
946
|
"liveupdate.add_mount": [
|
|
@@ -711,12 +955,16 @@
|
|
|
711
955
|
],
|
|
712
956
|
"liveupdate.get_mounts": [
|
|
713
957
|
{
|
|
714
|
-
"sourceHash": "
|
|
715
|
-
"ts": "
|
|
958
|
+
"sourceHash": "5c7eede2122552e2",
|
|
959
|
+
"ts": "pprint(\"MOUNTS\", liveupdate.get_mounts());"
|
|
716
960
|
},
|
|
717
961
|
{
|
|
718
|
-
"sourceHash": "
|
|
719
|
-
"ts": "//
|
|
962
|
+
"sourceHash": "8f1c19f5a5d6e4b1",
|
|
963
|
+
"ts": "// DEBUG:SCRIPT: MOUNTS,\n// {\n// 1 = {\n// name = hash: [liveupdate],\n// uri = \"zip:/device/path/to/acchives/liveupdate.zip\",\n// priority = 5\n// },\n// 2 = {\n// name = hash: [_base],\n// uri = \"archive:build/default/game.dmanifest\",\n// priority = -10\n// }\n// }"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
"sourceHash": "a93aeb64f6460957",
|
|
967
|
+
"ts": "// DEBUG:SCRIPT: MOUNTS,\n// {\n// 1 = {\n// name = \"liveupdate\",\n// uri = \"zip:/device/path/to/acchives/liveupdate.zip\",\n// priority = 5\n// },\n// 2 = {\n// name = \"_base\",\n// uri = \"archive:build/default/game.dmanifest\",\n// priority = -10\n// }\n// }"
|
|
720
968
|
}
|
|
721
969
|
],
|
|
722
970
|
"liveupdate.is_built_with_excluded_files": [
|
|
@@ -835,8 +1083,12 @@
|
|
|
835
1083
|
],
|
|
836
1084
|
"msg.post": [
|
|
837
1085
|
{
|
|
838
|
-
"sourceHash": "
|
|
839
|
-
"ts": "
|
|
1086
|
+
"sourceHash": "3bb511425986efad",
|
|
1087
|
+
"ts": "msg.post(\"my_gameobject#my_sprite\", \"enable\");"
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
"sourceHash": "bb0ad09dd9648670",
|
|
1091
|
+
"ts": "const my_url = msg.url(\"my_gameobject#my_script\");\nconst params = { my_parameter: \"my_value\" };\nmsg.post(my_url, \"my_message\", params);"
|
|
840
1092
|
}
|
|
841
1093
|
],
|
|
842
1094
|
"msg.url": [
|
|
@@ -913,10 +1165,28 @@
|
|
|
913
1165
|
"ts": "export default defineScript({\n init(self) {\n let gravity = physics.get_gravity();\n // Inverse gravity!\n gravity = vmath.vector3(-gravity.x, -gravity.y, -gravity.z);\n physics.set_gravity(gravity);\n },\n});"
|
|
914
1166
|
}
|
|
915
1167
|
],
|
|
1168
|
+
"physics.get_group": [
|
|
1169
|
+
{
|
|
1170
|
+
"sourceHash": "c8144370669b125f",
|
|
1171
|
+
"ts": "function check_is_enemy(): boolean {\n const group = physics.get_group(\"#collisionobject\");\n return group === hash(\"enemy\");\n}"
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
"physics.get_maskbit": [
|
|
1175
|
+
{
|
|
1176
|
+
"sourceHash": "8679181844a752a4",
|
|
1177
|
+
"ts": "function is_invincible(): boolean {\n // check if the collisionobject would collide with the \"bullet\" group\n const invincible = physics.get_maskbit(\"#collisionobject\", \"bullet\");\n return invincible;\n}"
|
|
1178
|
+
}
|
|
1179
|
+
],
|
|
1180
|
+
"physics.get_shape": [
|
|
1181
|
+
{
|
|
1182
|
+
"sourceHash": "82791cbb5f80661a",
|
|
1183
|
+
"ts": "function get_shape_meta() {\n const sphere = physics.get_shape(\"#collisionobject\", \"my_sphere_shape\");\n // returns a table with sphere.diameter\n return sphere;\n}"
|
|
1184
|
+
}
|
|
1185
|
+
],
|
|
916
1186
|
"physics.raycast": [
|
|
917
1187
|
{
|
|
918
1188
|
"sourceHash": "3e0c534d741f0120",
|
|
919
|
-
"ts": "function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash; request_id: number }) {\n // act on the hit (see 'ray_cast_response')\n}\n\n// How to perform a ray cast synchronously:\nexport default defineScript({\n init() {\n return { groups: [hash(\"world\"), hash(\"enemy\")] };\n },\n\n update(self, dt) {\n // request ray cast\n const from = go.get_world_position();\n const to = vmath.vector3(from.x, from.y - 100, from.z);\n const results = physics.raycast(from, to, self.groups, { all: true });\n if (results !== undefined) {\n for (const result of results) {\n handle_result(result);\n }\n }\n },\n});"
|
|
1189
|
+
"ts": "function handle_result(hit: { fraction: number; position: Vector3; normal: Vector3; id: Hash; group: Hash; request_id: number }) {\n // act on the hit (see 'ray_cast_response')\n}\n\n// How to perform a ray cast synchronously:\nexport default defineScript({\n init() {\n return { groups: [hash(\"world\"), hash(\"enemy\")] };\n },\n\n update(self, dt) {\n // request ray cast\n const from = go.get_world_position();\n const to = vmath.vector3(from.x, from.y - 100, from.z);\n const results = physics.raycast(from, to, self.groups, { all: true });\n if (results !== undefined) {\n // with `all` set, the ray cast returns every hit as a list\n for (const result of Array.isArray(results) ? results : [results]) {\n handle_result(result);\n }\n }\n },\n});"
|
|
920
1190
|
}
|
|
921
1191
|
],
|
|
922
1192
|
"physics.raycast_async": [
|
|
@@ -941,12 +1211,30 @@
|
|
|
941
1211
|
"ts": "export default defineScript({\n init(self) {\n // Set \"upside down\" gravity for this collection.\n physics.set_gravity(vmath.vector3(0, 10.0, 0));\n },\n});"
|
|
942
1212
|
}
|
|
943
1213
|
],
|
|
1214
|
+
"physics.set_group": [
|
|
1215
|
+
{
|
|
1216
|
+
"sourceHash": "c4125b51c18c0a63",
|
|
1217
|
+
"ts": "function change_collision_group() {\n physics.set_group(\"#collisionobject\", \"enemy\");\n}"
|
|
1218
|
+
}
|
|
1219
|
+
],
|
|
944
1220
|
"physics.set_hflip": [
|
|
945
1221
|
{
|
|
946
1222
|
"sourceHash": "71a627e46d2e651e",
|
|
947
1223
|
"ts": "export default defineScript({\n init() {\n const fliph = true; // set on some condition\n physics.set_hflip(\"#collisionobject\", fliph);\n return { fliph };\n },\n});"
|
|
948
1224
|
}
|
|
949
1225
|
],
|
|
1226
|
+
"physics.set_maskbit": [
|
|
1227
|
+
{
|
|
1228
|
+
"sourceHash": "a4b238ed0887509f",
|
|
1229
|
+
"ts": "function make_invincible() {\n // no longer collide with the \"bullet\" group\n physics.set_maskbit(\"#collisionobject\", \"bullet\", false);\n}"
|
|
1230
|
+
}
|
|
1231
|
+
],
|
|
1232
|
+
"physics.set_shape": [
|
|
1233
|
+
{
|
|
1234
|
+
"sourceHash": "12a0293fcc2f7687",
|
|
1235
|
+
"ts": "function set_shape_data() {\n // set capsule shape data\n physics.set_shape(\"#collisionobject\", \"my_capsule_shape\", {\n type: physics.SHAPE_TYPE_CAPSULE,\n diameter: 10,\n height: 20,\n });\n\n // set sphere shape data\n physics.set_shape(\"#collisionobject\", \"my_sphere_shape\", {\n type: physics.SHAPE_TYPE_SPHERE,\n diameter: 10,\n });\n\n // set box shape data\n physics.set_shape(\"#collisionobject\", \"my_box_shape\", {\n type: physics.SHAPE_TYPE_BOX,\n dimensions: vmath.vector3(10, 10, 5),\n });\n}"
|
|
1236
|
+
}
|
|
1237
|
+
],
|
|
950
1238
|
"physics.set_vflip": [
|
|
951
1239
|
{
|
|
952
1240
|
"sourceHash": "7b5832955ec6635c",
|
|
@@ -959,6 +1247,12 @@
|
|
|
959
1247
|
"ts": "physics.update_mass(\"#collisionobject\", 14);"
|
|
960
1248
|
}
|
|
961
1249
|
],
|
|
1250
|
+
"physics.wakeup": [
|
|
1251
|
+
{
|
|
1252
|
+
"sourceHash": "8bda507f7a5248c1",
|
|
1253
|
+
"ts": "export default defineScript({\n on_input(self, action_id, action) {\n if (action_id === hash(\"test\") && action.pressed) {\n physics.wakeup(\"#collisionobject\");\n }\n },\n});"
|
|
1254
|
+
}
|
|
1255
|
+
],
|
|
962
1256
|
"profiler.dump_frame": [
|
|
963
1257
|
{
|
|
964
1258
|
"sourceHash": "54342e4fc710032d",
|
|
@@ -1033,8 +1327,20 @@
|
|
|
1033
1327
|
],
|
|
1034
1328
|
"render.constant_buffer": [
|
|
1035
1329
|
{
|
|
1036
|
-
"sourceHash": "
|
|
1037
|
-
"ts": "
|
|
1330
|
+
"sourceHash": "16ded57baadade85",
|
|
1331
|
+
"ts": "const constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
"sourceHash": "d89056c8f1a576bb",
|
|
1335
|
+
"ts": "function draw_tinted(self: { my_pred: Opaque<\"render_predicate\"> }) {\n const constants = render.constant_buffer();\n constants.tint = vmath.vector4(1, 1, 1, 1);\n render.draw(self.my_pred, { constants });\n}"
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
"sourceHash": "2c9cd28e1eb6e610",
|
|
1339
|
+
"ts": "const constants = render.constant_buffer();\nconstants.light_colors = [];\nconstants.light_colors[0] = vmath.vector4(1, 0, 0, 1);\nconstants.light_colors[1] = vmath.vector4(0, 1, 0, 1);\nconstants.light_colors[2] = vmath.vector4(0, 0, 1, 1);"
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
"sourceHash": "d1c04a81200daf67",
|
|
1343
|
+
"ts": "const constants = render.constant_buffer();\nconstants.light_colors = [\n vmath.vector4(1, 0, 0, 1),\n vmath.vector4(0, 1, 0, 1),\n vmath.vector4(0, 0, 1, 1),\n];\n\n// Add more constants to the array\nconstants.light_colors[3] = vmath.vector4(1, 1, 1, 1);"
|
|
1038
1344
|
}
|
|
1039
1345
|
],
|
|
1040
1346
|
"render.delete_render_target": [
|
|
@@ -1063,14 +1369,30 @@
|
|
|
1063
1369
|
],
|
|
1064
1370
|
"render.dispatch_compute": [
|
|
1065
1371
|
{
|
|
1066
|
-
"sourceHash": "
|
|
1067
|
-
"ts": "export default defineRenderScript({\n init() {\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n };\n return {\n backing_texture: resource.get_texture_info(\"/main/backing.texturec\").handle,\n scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),\n };\n },\n\n update(self, dt) {\n render.set_compute(\"bloom\");\n render.enable_texture(0, self.backing_texture);\n render.enable_texture(1, self.scene_rt);\n render.dispatch_compute(128, 128, 1);\n render.set_compute();\n },\n})
|
|
1372
|
+
"sourceHash": "75d02543f0e1f325",
|
|
1373
|
+
"ts": "export default defineRenderScript({\n init() {\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n };\n return {\n backing_texture: resource.get_texture_info(\"/main/backing.texturec\").handle,\n scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),\n };\n },\n\n update(self, dt) {\n render.set_compute(\"bloom\");\n render.enable_texture(0, self.backing_texture);\n render.enable_texture(1, self.scene_rt);\n render.dispatch_compute(128, 128, 1);\n render.set_compute();\n },\n});"
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
"sourceHash": "839cd1accd7a318c",
|
|
1377
|
+
"ts": "const constants = render.constant_buffer();\nconstants.tint = vmath.vector4(1, 1, 1, 1);\nrender.dispatch_compute(32, 32, 32, { constants });"
|
|
1068
1378
|
}
|
|
1069
1379
|
],
|
|
1070
1380
|
"render.draw": [
|
|
1071
1381
|
{
|
|
1072
|
-
"sourceHash": "
|
|
1073
|
-
"ts": "export default defineRenderScript({\n init() {\n
|
|
1382
|
+
"sourceHash": "5f241f4874a8bc1a",
|
|
1383
|
+
"ts": "export default defineRenderScript({\n init() {\n // define a predicate matching anything with material tag \"my_tag\"\n return { my_pred: render.predicate([hash(\"my_tag\")]) };\n },\n\n update(self, dt) {\n // draw everything in the my_pred predicate\n render.draw(self.my_pred);\n },\n});"
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
"sourceHash": "50e774f222fef263",
|
|
1387
|
+
"ts": "function draw_tinted(self: { my_pred: Opaque<\"render_predicate\"> }) {\n const constants = render.constant_buffer();\n constants.tint = vmath.vector4(1, 1, 1, 1);\n render.draw(self.my_pred, { constants });\n}"
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
"sourceHash": "19aaab03c8a4c8e7",
|
|
1391
|
+
"ts": "function draw_culled(self: { my_pred: Opaque<\"render_predicate\">; proj: Matrix4; view: Matrix4 }) {\n const frustum = self.proj.mul(self.view);\n render.draw(self.my_pred, { frustum });\n}"
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
"sourceHash": "d1cbea5554766082",
|
|
1395
|
+
"ts": "function draw_culled(self: { my_pred: Opaque<\"render_predicate\">; proj: Matrix4; view: Matrix4 }) {\n const frustum = self.proj.mul(self.view);\n render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });\n}"
|
|
1074
1396
|
}
|
|
1075
1397
|
],
|
|
1076
1398
|
"render.draw_debug3d": [
|
|
@@ -1154,11 +1476,19 @@
|
|
|
1154
1476
|
},
|
|
1155
1477
|
{
|
|
1156
1478
|
"sourceHash": "271ca31f05e103b5",
|
|
1157
|
-
"ts": "// How to create a render target with multiple outputs:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params_rgba = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const color_params_float = {\n format: graphics.TEXTURE_FORMAT_RG32F,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n\n // Create a render target with three color attachments\n // Note: No depth buffer is attached here\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,\n [
|
|
1479
|
+
"ts": "// How to create a render target with multiple outputs:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params_rgba = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const color_params_float = {\n format: graphics.TEXTURE_FORMAT_RG32F,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n\n // the engine registers the extra color attachments only when the driver supports them\n const color1 = graphics.BUFFER_TYPE_COLOR1_BIT;\n const color2 = graphics.BUFFER_TYPE_COLOR2_BIT;\n if (color1 === undefined || color2 === undefined) return undefined;\n\n // Create a render target with three color attachments\n // Note: No depth buffer is attached here\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,\n [color1]: color_params_rgba,\n [color2]: color_params_float,\n }),\n my_pred: render.predicate([hash(\"my_tag\")]),\n };\n },\n\n update(self, dt) {\n if (self === undefined) return;\n // enable target so all drawing is done to it\n render.set_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
|
|
1158
1480
|
},
|
|
1159
1481
|
{
|
|
1160
1482
|
"sourceHash": "e39f13af5d65d01d",
|
|
1161
1483
|
"ts": "// How to create a render target with multiple outputs:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params_rgba = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const color_params_float = {\n format: graphics.TEXTURE_FORMAT_RG32F,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n\n // Create a render target with three color attachments\n // Note: No depth buffer is attached here\n return {\n my_render_target: render.render_target({\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,\n [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,\n }),\n my_pred: render.predicate([hash(\"my_tag\")]),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.set_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
|
|
1484
|
+
},
|
|
1485
|
+
{
|
|
1486
|
+
"sourceHash": "582c319c90bcf7ad",
|
|
1487
|
+
"ts": "export default defineRenderScript({\n init() {\n if (graphics.BUFFER_TYPE_COLOR1_BIT === undefined) {\n // this devices does not support multiple color attachments\n }\n },\n});"
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
"sourceHash": "eec69c97bf2815ed",
|
|
1491
|
+
"ts": "// How to create a new render target and draw to it:\nexport default defineRenderScript({\n init() {\n // render target buffer parameters\n const color_params = {\n format: graphics.TEXTURE_FORMAT_RGBA,\n width: render.get_window_width(),\n height: render.get_window_height(),\n min_filter: graphics.TEXTURE_FILTER_LINEAR,\n mag_filter: graphics.TEXTURE_FILTER_LINEAR,\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n const depth_params = {\n format: graphics.TEXTURE_FORMAT_DEPTH,\n width: render.get_window_width(),\n height: render.get_window_height(),\n u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,\n };\n return {\n my_render_target: render.render_target({\n sample_count: 4,\n [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,\n [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,\n }),\n my_pred: render.predicate([hash(\"my_tag\")]),\n };\n },\n\n update(self, dt) {\n // enable target so all drawing is done to it\n render.set_render_target(self.my_render_target);\n\n // draw a predicate to the render target\n render.draw(self.my_pred);\n },\n});"
|
|
1162
1492
|
}
|
|
1163
1493
|
],
|
|
1164
1494
|
"render.set_blend_equation_separate": [
|
|
@@ -1181,8 +1511,12 @@
|
|
|
1181
1511
|
],
|
|
1182
1512
|
"render.set_camera": [
|
|
1183
1513
|
{
|
|
1184
|
-
"sourceHash": "
|
|
1185
|
-
"ts": "
|
|
1514
|
+
"sourceHash": "b107acc1597639c2",
|
|
1515
|
+
"ts": "function draw_through_camera(self: { my_pred: Opaque<\"render_predicate\"> }) {\n render.set_camera(\"main:/my_go#camera\");\n render.draw(self.my_pred);\n render.set_camera(undefined);\n}"
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
"sourceHash": "4fc6efe0ea0a194d",
|
|
1519
|
+
"ts": "function draw_through_camera(self: { my_pred: Opaque<\"render_predicate\"> }) {\n // The camera frustum will take precedence over the frustum plane option in render.draw\n render.set_camera(\"main:/my_go#camera\", { use_frustum: true });\n // However, we can still customize the frustum planes regardless of the camera option!\n render.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });\n render.set_camera();\n}"
|
|
1186
1520
|
}
|
|
1187
1521
|
],
|
|
1188
1522
|
"render.set_color_mask": [
|
|
@@ -1298,7 +1632,7 @@
|
|
|
1298
1632
|
"resource.create_atlas": [
|
|
1299
1633
|
{
|
|
1300
1634
|
"sourceHash": "987cf3d09a4ce250",
|
|
1301
|
-
"ts": "// Create a backing texture and an atlas\nexport default defineScript({\n init() {\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
1635
|
+
"ts": "// Create a backing texture and an atlas\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (format === undefined) return;\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n const my_texture_id = resource.create_texture(\"/my_texture.texturec\", tparams);\n\n // optionally use resource.set_texture to upload data to texture\n\n // create an atlas with one animation and one square geometry\n // note that the function doesn't support hashes for the texture,\n // you need to use a string for the texture path here aswell\n const aparams = {\n texture: \"/my_texture.texturec\",\n animations: [\n {\n id: \"my_animation\",\n width: 128,\n height: 128,\n frames: [1],\n },\n ],\n geometries: [\n {\n id: \"idle0\",\n width: 128,\n height: 128,\n pivot_x: 0.5,\n pivot_y: 0.5,\n vertices: [0, 0, 0, 128, 128, 128, 128, 0],\n uvs: [0, 0, 0, 128, 128, 128, 128, 0],\n indices: [0, 1, 2, 0, 2, 3],\n },\n ],\n } satisfies Parameters<typeof resource.create_atlas>[1];\n const my_atlas_id = resource.create_atlas(\"/my_atlas.texturesetc\", aparams);\n\n // assign the atlas to the 'sprite' component on the same go\n go.set(\"#sprite\", \"image\", my_atlas_id);\n },\n});"
|
|
1302
1636
|
}
|
|
1303
1637
|
],
|
|
1304
1638
|
"resource.create_buffer": [
|
|
@@ -1320,23 +1654,39 @@
|
|
|
1320
1654
|
"resource.create_texture": [
|
|
1321
1655
|
{
|
|
1322
1656
|
"sourceHash": "717b1b10958e5fa2",
|
|
1323
|
-
"ts": "// How to create an 128x128 RGBA texture resource and assign it to a model\nexport default defineScript({\n init() {\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
1657
|
+
"ts": "// How to create an 128x128 RGBA texture resource and assign it to a model\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (format === undefined) return;\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams);\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});"
|
|
1324
1658
|
},
|
|
1325
1659
|
{
|
|
1326
1660
|
"sourceHash": "71bd6ae180eb83d6",
|
|
1327
|
-
"ts": "// How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object\nexport default defineScript({\n init() {\n // Create a new buffer with 4 components and FLOAT32 type\n const tbuffer = buffer.create(128 * 128, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < 128; y++) {\n for (let x = 0; x < 128; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 999.0;\n tstream[index + 1] = -1.0;\n tstream[index + 2] = 0.5;\n tstream[index + 3] = 1.0;\n }\n }\n\n // Create a 2D Texture with a RGBA23F format\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
1661
|
+
"ts": "// How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA32F;\n if (format === undefined) return;\n // Create a new buffer with 4 components and FLOAT32 type\n const tbuffer = buffer.create(128 * 128, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < 128; y++) {\n for (let x = 0; x < 128; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 999.0;\n tstream[index + 1] = -1.0;\n tstream[index + 2] = 0.5;\n tstream[index + 3] = 1.0;\n }\n }\n\n // Create a 2D Texture with a RGBA23F format\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n // Note that we pass the buffer as the last argument here!\n const my_texture_id = resource.create_texture(\"/my_custom_texture.texturec\", tparams, tbuffer);\n\n // assign the texture to a model\n go.set(\"#model\", \"texture0\", my_texture_id);\n },\n});"
|
|
1328
1662
|
},
|
|
1329
1663
|
{
|
|
1330
1664
|
"sourceHash": "be4f6e903c862a52",
|
|
1331
|
-
"ts": "// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type
|
|
1665
|
+
"ts": "// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n // the engine registers a texture type or format only when the driver supports it\n const type = graphics.TEXTURE_TYPE_IMAGE_3D;\n const format = graphics.TEXTURE_FORMAT_RGBA32F;\n if (type === undefined || format === undefined) return;\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type,\n width: 32,\n height: 32,\n depth: 32,\n format,\n flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});"
|
|
1332
1666
|
},
|
|
1333
1667
|
{
|
|
1334
1668
|
"sourceHash": "b1535ccf9e09d259",
|
|
1335
|
-
"ts": "// How to create 512x512 texture array with 5 pages.\nconst new_tex = resource.create_texture(\"/runtime/example_array.texturec\", {\n
|
|
1669
|
+
"ts": "// How to create 512x512 texture array with 5 pages.\n// the engine registers a texture format only when the driver supports it\nconst format = graphics.TEXTURE_FORMAT_RGB;\nif (format !== undefined) {\n const new_tex = resource.create_texture(\"/runtime/example_array.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: 512,\n height: 512,\n page_count: 5,\n format,\n });\n}"
|
|
1336
1670
|
},
|
|
1337
1671
|
{
|
|
1338
1672
|
"sourceHash": "54a85cf9f38f2521",
|
|
1339
1673
|
"ts": "// How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader\nexport default defineScript({\n init() {\n const t_volume = resource.create_texture(\"/my_backing_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 32,\n height: 32,\n depth: 32,\n format: graphics.TEXTURE_FORMAT_RGBA32F,\n flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,\n });\n\n // pass the backing texture to the render script\n msg.post(\"@render:\", \"add_textures\", [t_volume]);\n },\n});"
|
|
1674
|
+
},
|
|
1675
|
+
{
|
|
1676
|
+
"sourceHash": "805bde1e64372a97",
|
|
1677
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // it is safe to use this format\n}"
|
|
1678
|
+
},
|
|
1679
|
+
{
|
|
1680
|
+
"sourceHash": "51b59b3d6e594c38",
|
|
1681
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // Device and graphics adapter support 3D textures\n}"
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
"sourceHash": "99a0f19709b55611",
|
|
1685
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // It is safe to use this format.\n}"
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
"sourceHash": "a2e9eeb06d748575",
|
|
1689
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // The device and graphics adapter support 3D textures.\n}"
|
|
1340
1690
|
}
|
|
1341
1691
|
],
|
|
1342
1692
|
"resource.create_texture_async": [
|
|
@@ -1346,7 +1696,28 @@
|
|
|
1346
1696
|
},
|
|
1347
1697
|
{
|
|
1348
1698
|
"sourceHash": "921632059c7abb58",
|
|
1349
|
-
"ts": "// Create a texture resource asyncronously without
|
|
1699
|
+
"ts": "// Create a texture resource asyncronously without handling its completion\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (format === undefined) return;\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n // the binding requires a callback function, so pass one that does nothing\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer, () => {});\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});",
|
|
1700
|
+
"prose": "Create a texture resource asynchronously with a callback that does nothing"
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
"sourceHash": "805bde1e64372a97",
|
|
1704
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // it is safe to use this format\n}"
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
"sourceHash": "51b59b3d6e594c38",
|
|
1708
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // Device and graphics adapter support 3D textures\n}"
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
"sourceHash": "99a0f19709b55611",
|
|
1712
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // It is safe to use this format.\n}"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
"sourceHash": "a2e9eeb06d748575",
|
|
1716
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // The device and graphics adapter support 3D textures.\n}"
|
|
1717
|
+
},
|
|
1718
|
+
{
|
|
1719
|
+
"sourceHash": "66e3c1c627270938",
|
|
1720
|
+
"ts": "// Create a texture resource asyncronously with a buffer and a callback\nfunction callback(self: unknown, request_id: number, result: resource.texture_creation_result) {\n // The resource has been updated with a new texture,\n // so we can update other systems with the new handle,\n // or update components to use the resource if we want\n const tinfo = resource.get_texture_info(result.path);\n msg.post(\"@render:\", \"set_backing_texture\", { handle: tinfo.handle });\n}\n\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (format === undefined) return;\n // Create a texture resource async\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n // Create a new buffer with 4 components\n const tbuffer = buffer.create(tparams.width * tparams.height, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_UINT8, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // Fill the buffer stream with some float values\n for (let y = 0; y < tparams.width; y++) {\n for (let x = 0; x < tparams.height; x++) {\n const index = y * 128 * 4 + x * 4;\n tstream[index + 0] = 255;\n tstream[index + 1] = 0;\n tstream[index + 2] = 255;\n tstream[index + 3] = 255;\n }\n }\n // create the texture\n const [tpath, request_id] = resource.create_texture_async(\"/my_texture.texturec\", tparams, tbuffer, callback);\n // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture\n // that will be removed once the new texture has been updated\n go.set(\"#model\", \"texture0\", tpath);\n },\n});"
|
|
1350
1721
|
}
|
|
1351
1722
|
],
|
|
1352
1723
|
"resource.font": [
|
|
@@ -1384,7 +1755,7 @@
|
|
|
1384
1755
|
"resource.get_texture_info": [
|
|
1385
1756
|
{
|
|
1386
1757
|
"sourceHash": "2d4a0b27a192425a",
|
|
1387
|
-
"ts": "// Create a new texture and get the metadata from it\nexport default defineScript({\n init() {\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
1758
|
+
"ts": "// Create a new texture and get the metadata from it\nexport default defineScript({\n init() {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (format === undefined) return;\n // create an empty texture\n const tparams = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n\n const my_texture_path = resource.create_texture(\"/my_texture.texturec\", tparams);\n const my_texture_info = resource.get_texture_info(my_texture_path);\n\n // my_texture_info now contains\n // {\n // handle = <the-numeric-handle>,\n // width = 128,\n // height = 128,\n // depth = 1\n // mipmaps = 1,\n // page_count = 1,\n // type = graphics.TEXTURE_TYPE_2D,\n // flags = graphics.TEXTURE_USAGE_FLAG_SAMPLE\n // }\n },\n});"
|
|
1388
1759
|
},
|
|
1389
1760
|
{
|
|
1390
1761
|
"sourceHash": "4fed93d6cd7f9380",
|
|
@@ -1393,8 +1764,12 @@
|
|
|
1393
1764
|
],
|
|
1394
1765
|
"resource.load": [
|
|
1395
1766
|
{
|
|
1396
|
-
"sourceHash": "
|
|
1397
|
-
"ts": "// read custom resource data into buffer\nconst buffer = resource.load(\"/resources/datafile\")
|
|
1767
|
+
"sourceHash": "dfc400954f81d242",
|
|
1768
|
+
"ts": "// read custom resource data into buffer\nconst buffer = resource.load(\"/resources/datafile\");"
|
|
1769
|
+
},
|
|
1770
|
+
{
|
|
1771
|
+
"sourceHash": "f02ab4b1fbd6e499",
|
|
1772
|
+
"ts": "// [project]\n// title = My project\n// version = 0.1\n// custom_resources = resources/,assets/level_data.json"
|
|
1398
1773
|
}
|
|
1399
1774
|
],
|
|
1400
1775
|
"resource.material": [
|
|
@@ -1422,11 +1797,11 @@
|
|
|
1422
1797
|
"resource.set_atlas": [
|
|
1423
1798
|
{
|
|
1424
1799
|
"sourceHash": "58ec7c40c31875a4",
|
|
1425
|
-
"ts": "// Add a new animation to an existing atlas\nexport default defineScript({\n init() {\n const data = resource.get_atlas(\"/main/my_atlas.a.texturesetc\");\n const my_animation = {\n id: \"my_new_animation\",\n width: 128,\n height: 128,\n frame_start: 1,\n frame_end: 6,\n playback: go.PLAYBACK_LOOP_PINGPONG,\n fps: 8,\n flip_vertical: false,\n flip_horizontal: false,\n };\n data.animations.
|
|
1800
|
+
"ts": "// Add a new animation to an existing atlas\nexport default defineScript({\n init() {\n const data = resource.get_atlas(\"/main/my_atlas.a.texturesetc\");\n const my_animation = {\n id: \"my_new_animation\",\n width: 128,\n height: 128,\n frame_start: 1,\n frame_end: 6,\n playback: go.PLAYBACK_LOOP_PINGPONG,\n fps: 8,\n flip_vertical: false,\n flip_horizontal: false,\n };\n // set_atlas takes each animation's frames as a non-empty list\n const animations = data.animations.flatMap((animation) => {\n // an animation described by frame_start/frame_end passes through as-is\n if (!(\"frames\" in animation)) return [animation];\n const [first, ...rest] = (animation.frames as number[] | undefined) ?? [];\n return first === undefined ? [] : [{ ...animation, frames: [first, ...rest] as [number, ...number[]] }];\n });\n // set_atlas needs at least one animation and one geometry\n const [first_geometry, ...geometries] = data.geometries;\n if (first_geometry !== undefined) {\n resource.set_atlas(\"/main/my_atlas.a.texturesetc\", {\n ...data,\n animations: [my_animation, ...animations],\n geometries: [first_geometry, ...geometries],\n });\n }\n },\n});"
|
|
1426
1801
|
},
|
|
1427
1802
|
{
|
|
1428
1803
|
"sourceHash": "c672fd8c9d921f68",
|
|
1429
|
-
"ts": "// Sets atlas data for a 256x256 texture with a single animation being rendered as a quad\nexport default defineScript({\n init() {\n const params = {\n texture: \"/main/my_256x256_texture.texturec\",\n animations: [\n {\n id: \"my_animation\",\n width: 256,\n height: 256,\n frames: [1],\n },\n ],\n geometries: [\n {\n vertices: [0, 0, 0, 256, 256, 256, 256, 0],\n uvs: [0, 0, 0, 256, 256, 256, 256, 0],\n indices: [0, 1, 2, 0, 2, 3],\n },\n ],\n };\n resource.set_atlas(\"/main/test.a.texturesetc\", params);\n },\n});"
|
|
1804
|
+
"ts": "// Sets atlas data for a 256x256 texture with a single animation being rendered as a quad\nexport default defineScript({\n init() {\n const params = {\n texture: \"/main/my_256x256_texture.texturec\",\n animations: [\n {\n id: \"my_animation\",\n width: 256,\n height: 256,\n frames: [1],\n },\n ],\n geometries: [\n {\n vertices: [0, 0, 0, 256, 256, 256, 256, 0],\n uvs: [0, 0, 0, 256, 256, 256, 256, 0],\n indices: [0, 1, 2, 0, 2, 3],\n },\n ],\n } satisfies Parameters<typeof resource.set_atlas>[1];\n resource.set_atlas(\"/main/test.a.texturesetc\", params);\n },\n});"
|
|
1430
1805
|
}
|
|
1431
1806
|
],
|
|
1432
1807
|
"resource.set_buffer": [
|
|
@@ -1438,15 +1813,15 @@
|
|
|
1438
1813
|
"resource.set_texture": [
|
|
1439
1814
|
{
|
|
1440
1815
|
"sourceHash": "fe312c35ef2ab0f4",
|
|
1441
|
-
"ts": "// How to set all pixels of an atlas\nexport default defineScript({\n init() {\n const height = 128;\n const width = 128;\n const buf = buffer.create(width * height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n const stream = buffer.get_stream(buf, hash(\"rgb\"));\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const index = y * width * 3 + x * 3;\n stream[index + 0] = 0xff;\n stream[index + 1] = 0x80;\n stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n
|
|
1816
|
+
"ts": "// How to set all pixels of an atlas\nexport default defineScript({\n init() {\n const height = 128;\n const width = 128;\n const buf = buffer.create(width * height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n const stream = buffer.get_stream(buf, hash(\"rgb\"));\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const index = y * width * 3 + x * 3;\n stream[index + 0] = 0xff;\n stream[index + 1] = 0x80;\n stream[index + 2] = 0x10;\n }\n }\n\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGB;\n if (format !== undefined) {\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, buf);\n }\n return { buffer: buf, stream };\n },\n});"
|
|
1442
1817
|
},
|
|
1443
1818
|
{
|
|
1444
1819
|
"sourceHash": "b4098f0f37b9c1d0",
|
|
1445
|
-
"ts": "// How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.\nexport default defineScript({\n init() {\n const x = 16;\n const y = 16;\n const height = 128 - x * 2;\n const width = 128 - y * 2;\n const buf = buffer.create(width * height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n const stream = buffer.get_stream(buf, hash(\"rgb\"));\n\n for (let row = 0; row < height; row++) {\n for (let col = 0; col < width; col++) {\n const index = row * width * 3 + col * 3;\n stream[index + 0] = 0xff;\n stream[index + 1] = 0x80;\n stream[index + 2] = 0x10;\n }\n }\n\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n
|
|
1820
|
+
"ts": "// How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.\nexport default defineScript({\n init() {\n const x = 16;\n const y = 16;\n const height = 128 - x * 2;\n const width = 128 - y * 2;\n const buf = buffer.create(width * height, [{ name: hash(\"rgb\"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);\n const stream = buffer.get_stream(buf, hash(\"rgb\"));\n\n for (let row = 0; row < height; row++) {\n for (let col = 0; col < width; col++) {\n const index = row * width * 3 + col * 3;\n stream[index + 0] = 0xff;\n stream[index + 1] = 0x80;\n stream[index + 2] = 0x10;\n }\n }\n\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGB;\n if (format !== undefined) {\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };\n resource.set_texture(resource_path, args, buf);\n }\n return { buffer: buf, stream };\n },\n});"
|
|
1446
1821
|
},
|
|
1447
1822
|
{
|
|
1448
1823
|
"sourceHash": "02d7f2ec29971bf1",
|
|
1449
|
-
"ts": "// Update a texture from a buffer resource\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_buffer: resource.buffer(\"/my_default_buffer.buffer\") },\n\n init(self) {\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n // the \"my_buffer\" resource is expected to hold 128 * 128 * 3 bytes!\n const args = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format
|
|
1824
|
+
"ts": "// Update a texture from a buffer resource\nexport default defineScript({\n // Never call `go.property` yourself: the transpiler emits the chunk-scope\n // registration from this field, and only this field types the property onto `self`.\n properties: { my_buffer: resource.buffer(\"/my_default_buffer.buffer\") },\n\n init(self) {\n // the engine registers a texture format only when the driver supports it\n const format = graphics.TEXTURE_FORMAT_RGB;\n if (format === undefined) return;\n const resource_path = go.get<model.properties>()(\"#model\", \"texture0\");\n // the \"my_buffer\" resource is expected to hold 128 * 128 * 3 bytes!\n const args = {\n width: 128,\n height: 128,\n type: graphics.TEXTURE_TYPE_2D,\n format,\n };\n // Note that the extra resource.get_buffer call is a requirement here\n // since the \"self.my_buffer\" is just pointing to a buffer resource path\n // and not an actual buffer object or buffer resource.\n resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));\n },\n});"
|
|
1450
1825
|
},
|
|
1451
1826
|
{
|
|
1452
1827
|
"sourceHash": "15829bfe1b186bc3",
|
|
@@ -1454,11 +1829,31 @@
|
|
|
1454
1829
|
},
|
|
1455
1830
|
{
|
|
1456
1831
|
"sourceHash": "f9b616092f8c1b6a",
|
|
1457
|
-
"ts": "// Update texture 2nd array page with loaded texture from png\nconst tex_path = \"/bundle_resources/page_02.png\";\nconst [data] = sys.load_resource(tex_path);\nif (data !== undefined) {\n const buf = image.load_buffer(data);\n if (buf !== undefined) {\n // new_tex is the resource handle of a texture created via resource.create_texture\n const new_tex = resource.create_texture(\"/my_array_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page_count: 2,\n format
|
|
1832
|
+
"ts": "// Update texture 2nd array page with loaded texture from png\nconst tex_path = \"/bundle_resources/page_02.png\";\nconst [data] = sys.load_resource(tex_path);\n// the engine registers a texture format only when the driver supports it\nconst format = graphics.TEXTURE_FORMAT_RGB;\nif (data !== undefined && format !== undefined) {\n const buf = image.load_buffer(data);\n if (buf !== undefined) {\n // new_tex is the resource handle of a texture created via resource.create_texture\n const new_tex = resource.create_texture(\"/my_array_texture.texturec\", {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page_count: 2,\n format,\n });\n resource.set_texture(\n new_tex,\n {\n type: graphics.TEXTURE_TYPE_2D_ARRAY,\n width: buf.width,\n height: buf.height,\n page: 1,\n format,\n },\n buf.buffer,\n );\n go.set(\"#mesh\", \"texture0\", new_tex);\n }\n}"
|
|
1458
1833
|
},
|
|
1459
1834
|
{
|
|
1460
1835
|
"sourceHash": "34dce6f8362c0e92",
|
|
1461
1836
|
"ts": "// Update an existing 3D texture from a buffer\nexport default defineScript({\n init() {\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 0; z < 8; z++) {\n for (let y = 0; y < 8; y++) {\n for (let x = 0; x < 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type: graphics.TEXTURE_TYPE_IMAGE_3D,\n width: 8,\n height: 8,\n depth: 8,\n format: graphics.TEXTURE_FORMAT_RGBA32F,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});"
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
"sourceHash": "805bde1e64372a97",
|
|
1840
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // it is safe to use this format\n}"
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
"sourceHash": "51b59b3d6e594c38",
|
|
1844
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // Device and graphics adapter support 3D textures\n}"
|
|
1845
|
+
},
|
|
1846
|
+
{
|
|
1847
|
+
"sourceHash": "99a0f19709b55611",
|
|
1848
|
+
"ts": "if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {\n // It is safe to use this format.\n}"
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
"sourceHash": "a2e9eeb06d748575",
|
|
1852
|
+
"ts": "if (graphics.TEXTURE_TYPE_3D !== undefined) {\n // The device and graphics adapter support 3D textures.\n}"
|
|
1853
|
+
},
|
|
1854
|
+
{
|
|
1855
|
+
"sourceHash": "e051bd09ecb32c90",
|
|
1856
|
+
"ts": "// Update an existing 3D texture from a lua buffer\nexport default defineScript({\n init() {\n // the engine registers a texture type or format only when the driver supports it\n const type = graphics.TEXTURE_TYPE_IMAGE_3D;\n const format = graphics.TEXTURE_FORMAT_RGBA32F;\n if (type === undefined || format === undefined) return;\n // create a buffer that can hold the data of a 8x8x8 texture\n const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash(\"rgba\"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);\n const tstream = buffer.get_stream(tbuffer, hash(\"rgba\"));\n\n // populate the buffer with some data\n let index = 0;\n for (let z = 1; z <= 8; z++) {\n for (let y = 1; y <= 8; y++) {\n for (let x = 1; x <= 8; x++) {\n tstream[index + 0] = x;\n tstream[index + 1] = y;\n tstream[index + 2] = z;\n tstream[index + 3] = 1.0;\n index = index + 4;\n }\n }\n }\n\n const t_args = {\n type,\n width: 8,\n height: 8,\n depth: 8,\n format,\n };\n\n // This expects that the texture resource \"/my_3d_texture.texturec\" already exists\n // and is a 3D texture resource. To create a dynamic 3D texture resource\n // use the \"resource.create_texture\" function.\n resource.set_texture(\"/my_3d_texture.texturec\", t_args, tbuffer);\n },\n});"
|
|
1462
1857
|
}
|
|
1463
1858
|
],
|
|
1464
1859
|
"resource.texture": [
|
|
@@ -1493,8 +1888,12 @@
|
|
|
1493
1888
|
],
|
|
1494
1889
|
"socket.skip": [
|
|
1495
1890
|
{
|
|
1496
|
-
"sourceHash": "
|
|
1497
|
-
"ts": "const line = \"250 OK\";\n
|
|
1891
|
+
"sourceHash": "4a23a75fe4aaaca9",
|
|
1892
|
+
"ts": "const line = \"250 OK\";\n// get the status code and separator from SMTP server reply\nconst [dummy1, dummy2, code, sep] = string.find(line, \"^(%d%d%d)(.?)\");"
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
"sourceHash": "76686918042071bd",
|
|
1896
|
+
"ts": "const line = \"250 OK\";\n// get the status code and separator from SMTP server reply\nconst [code, sep] = socket.skip(2, string.find(line, \"^(%d%d%d)(.?)\"));"
|
|
1498
1897
|
}
|
|
1499
1898
|
],
|
|
1500
1899
|
"sound.get_group_gain": [
|
|
@@ -1547,8 +1946,12 @@
|
|
|
1547
1946
|
],
|
|
1548
1947
|
"sound.play": [
|
|
1549
1948
|
{
|
|
1550
|
-
"sourceHash": "
|
|
1551
|
-
"ts": "
|
|
1949
|
+
"sourceHash": "657f9fcfa39cf3af",
|
|
1950
|
+
"ts": "sound.play(\"#sound\", { delay: 1, gain: 0.9, pan: -1.0 });"
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
"sourceHash": "181c1feca6bf14c8",
|
|
1954
|
+
"ts": "function sound_done(self: unknown, message_id: unknown, message: unknown, sender: unknown) {\n // play 'boom' sound fx when the countdown has completed\n const { play_id } = message as { play_id: number };\n if (message_id === hash(\"sound_done\") && play_id === (self as { countdown_id: number }).countdown_id) {\n sound.play(\"#boom\", undefined, sound_done);\n }\n}\n\nexport default defineScript({\n init() {\n return { countdown_id: sound.play(\"#countdown\", undefined, sound_done) };\n },\n});"
|
|
1552
1955
|
}
|
|
1553
1956
|
],
|
|
1554
1957
|
"sound.set_gain": [
|
|
@@ -1577,8 +1980,12 @@
|
|
|
1577
1980
|
],
|
|
1578
1981
|
"sprite.play_flipbook": [
|
|
1579
1982
|
{
|
|
1580
|
-
"sourceHash": "
|
|
1581
|
-
"ts": "
|
|
1983
|
+
"sourceHash": "69a3c26fd553ffa4",
|
|
1984
|
+
"ts": "const url = msg.url(\"#sprite\");\n\nfunction anim_done(self: unknown, message_id: Hash, message: { id: Hash }) {\n if (message_id === hash(\"animation_done\") && message.id === hash(\"jump\")) {\n // jump animation done, chain with \"run\"\n sprite.play_flipbook(url, \"run\");\n }\n}"
|
|
1985
|
+
},
|
|
1986
|
+
{
|
|
1987
|
+
"sourceHash": "286542aa4db17a87",
|
|
1988
|
+
"ts": "export default defineScript({\n init() {\n const url = msg.url(\"#sprite\");\n sprite.play_flipbook(url, \"jump\", (self, message_id, message) => {\n if (message_id === hash(\"animation_done\") && message.id === hash(\"jump\")) {\n // jump animation done, chain with \"run\"\n sprite.play_flipbook(url, \"run\");\n }\n });\n },\n});"
|
|
1582
1989
|
}
|
|
1583
1990
|
],
|
|
1584
1991
|
"sprite.reset_constant": [
|
|
@@ -1619,8 +2026,12 @@
|
|
|
1619
2026
|
],
|
|
1620
2027
|
"sys.get_application_info": [
|
|
1621
2028
|
{
|
|
1622
|
-
"sourceHash": "
|
|
1623
|
-
"ts": "
|
|
2029
|
+
"sourceHash": "326e42d5ff9baf96",
|
|
2030
|
+
"ts": "const sysinfo = sys.get_sys_info();\nlet twitter: { installed?: boolean } = {};\n\nif (sysinfo.system_name === \"Android\") {\n twitter = sys.get_application_info(\"com.twitter.android\");\n} else if (sysinfo.system_name === \"iPhone OS\") {\n twitter = sys.get_application_info(\"twitter:\");\n}\n\nif (twitter.installed) {\n // twitter is installed!\n}"
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
"sourceHash": "1dd1eced66cc1e10",
|
|
2034
|
+
"ts": "// ...\n// <key>LSApplicationQueriesSchemes</key>\n// <array>\n// <string>twitter</string>\n// </array>\n// ..."
|
|
1624
2035
|
}
|
|
1625
2036
|
],
|
|
1626
2037
|
"sys.get_application_path": [
|
|
@@ -1637,8 +2048,12 @@
|
|
|
1637
2048
|
],
|
|
1638
2049
|
"sys.get_config_int": [
|
|
1639
2050
|
{
|
|
1640
|
-
"sourceHash": "
|
|
1641
|
-
"ts": "
|
|
2051
|
+
"sourceHash": "cadf71c740165693",
|
|
2052
|
+
"ts": "const speed = sys.get_config_int(\"my_game.speed\", 20); // with default value"
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
"sourceHash": "9365fae7e38c060c",
|
|
2056
|
+
"ts": "const testmode = sys.get_config_int(\"my_game.testmode\"); // without default value\nif (testmode !== undefined) {\n // do stuff\n}"
|
|
1642
2057
|
}
|
|
1643
2058
|
],
|
|
1644
2059
|
"sys.get_config_number": [
|
|
@@ -1649,8 +2064,20 @@
|
|
|
1649
2064
|
],
|
|
1650
2065
|
"sys.get_config_string": [
|
|
1651
2066
|
{
|
|
1652
|
-
"sourceHash": "
|
|
1653
|
-
"ts": "
|
|
2067
|
+
"sourceHash": "0bf7e3158e38a94a",
|
|
2068
|
+
"ts": "const text = sys.get_config_string(\"my_game.text\", \"default text\");"
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
"sourceHash": "a4703f05ae2e55b8",
|
|
2072
|
+
"ts": "// $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1"
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
"sourceHash": "4bf891e310fb931a",
|
|
2076
|
+
"ts": "const testmode = sys.get_config_int(\"mygame.testmode\");"
|
|
2077
|
+
},
|
|
2078
|
+
{
|
|
2079
|
+
"sourceHash": "c1b9b57492dd68a7",
|
|
2080
|
+
"ts": "const text = sys.get_config_string(\"my_game.text\", \"default text\");"
|
|
1654
2081
|
}
|
|
1655
2082
|
],
|
|
1656
2083
|
"sys.get_connectivity": [
|
|
@@ -1667,8 +2094,12 @@
|
|
|
1667
2094
|
],
|
|
1668
2095
|
"sys.get_host_path": [
|
|
1669
2096
|
{
|
|
1670
|
-
"sourceHash": "
|
|
1671
|
-
"ts": "
|
|
2097
|
+
"sourceHash": "cea90df8f93a0217",
|
|
2098
|
+
"ts": "const mytable = { score: 100, level: 3 };\nconst host_path = sys.get_host_path(\"logs/test.txt\");\nsys.save(host_path, mytable);"
|
|
2099
|
+
},
|
|
2100
|
+
{
|
|
2101
|
+
"sourceHash": "8b9a6ad30303b25e",
|
|
2102
|
+
"ts": "const host_path = sys.get_host_path(\"logs/test.txt\");\nconst table = sys.load(host_path);"
|
|
1672
2103
|
}
|
|
1673
2104
|
],
|
|
1674
2105
|
"sys.get_ifaddrs": [
|
|
@@ -1697,14 +2128,30 @@
|
|
|
1697
2128
|
],
|
|
1698
2129
|
"sys.load_buffer": [
|
|
1699
2130
|
{
|
|
1700
|
-
"sourceHash": "
|
|
1701
|
-
"ts": "
|
|
2131
|
+
"sourceHash": "485ff25191819692",
|
|
2132
|
+
"ts": "const my_buffer = sys.load_buffer(\"/assets/my_level_data.bin\");\nconst data_str = buffer.get_bytes(my_buffer, \"data\");\nconst has_my_header = data_str.slice(0, 6) === \"D3F0LD\";"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
"sourceHash": "ff532f8e663a09ba",
|
|
2136
|
+
"ts": "const asset_1 = sys.load_buffer(\"folder_next_to_binary/my_level_asset.txt\");\nconst asset_2 = sys.load_buffer(\"/my/absolute/path\");"
|
|
1702
2137
|
}
|
|
1703
2138
|
],
|
|
1704
2139
|
"sys.load_buffer_async": [
|
|
1705
2140
|
{
|
|
1706
|
-
"sourceHash": "
|
|
1707
|
-
"ts": "
|
|
2141
|
+
"sourceHash": "91d84e7dc569ae20",
|
|
2142
|
+
"ts": "function my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { status, buf } = result as { status: number; buf: Opaque<\"buffer\"> };\n if (status === sys.REQUEST_STATUS_FINISHED) {\n resource.set_texture(\"/my_texture\", { type: graphics.TEXTURE_TYPE_2D, width: 128, height: 128, format: graphics.TEXTURE_FORMAT_RGBA }, buf);\n }\n}\n\nconst my_request = sys.load_buffer_async(\"/assets/my_level_data.bin\", my_callback);"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
"sourceHash": "5545b8901e6ec4c5",
|
|
2146
|
+
"ts": "function my_callback(self: unknown, request_id: unknown, result: unknown) {\n const { first_asset, second_asset } = self as { first_asset: Hash; second_asset: Hash };\n if ((result as { status: number }).status !== sys.REQUEST_STATUS_FINISHED) {\n // uh oh! File could not be found, do something graceful\n } else if (request_id === first_asset) {\n // result.buffer contains data from my_level_asset.bin\n } else if (request_id === second_asset) {\n // result.buffer contains data from 'my_level.bin'\n }\n}\n\nexport default defineScript({\n init() {\n const first_path = \"folder_next_to_binary/my_level_asset.bin\";\n const second_path = \"/some_absolute_path/my_level.bin\";\n return {\n first_asset: hash(first_path),\n second_asset: hash(second_path),\n first_request: sys.load_buffer_async(first_path, my_callback),\n second_request: sys.load_buffer_async(second_path, my_callback),\n };\n },\n});"
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
"sourceHash": "7f66d3285b20ff78",
|
|
2150
|
+
"ts": "// Load binary data from a custom project resource and update a texture resource:\nfunction my_callback(self: unknown, request_id: number, result: sys.load_buffer_result) {\n const format = graphics.TEXTURE_FORMAT_RGBA;\n if (result.status === sys.REQUEST_STATUS_FINISHED && result.buffer !== undefined && format !== undefined) {\n resource.set_texture(\"/my_texture\", { type: graphics.TEXTURE_TYPE_2D, width: 128, height: 128, format }, result.buffer);\n }\n}\n\nconst my_request = sys.load_buffer_async(\"/assets/my_level_data.bin\", my_callback);"
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
"sourceHash": "9be4f92f718990af",
|
|
2154
|
+
"ts": "// Load binary data from non-custom resource files on disk:\nfunction my_callback(self: unknown, request_id: number, result: sys.load_buffer_result) {\n const { first_request, second_request } = self as { first_request: number; second_request: number };\n if (result.status !== sys.REQUEST_STATUS_FINISHED) {\n // uh oh! File could not be found, do something graceful\n } else if (request_id === first_request) {\n // result.buffer contains data from my_level_asset.bin\n } else if (request_id === second_request) {\n // result.buffer contains data from 'my_level.bin'\n }\n}\n\nexport default defineScript({\n init() {\n return {\n first_request: sys.load_buffer_async(\"folder_next_to_binary/my_level_asset.bin\", my_callback),\n second_request: sys.load_buffer_async(\"/some_absolute_path/my_level.bin\", my_callback),\n };\n },\n});"
|
|
1708
2155
|
}
|
|
1709
2156
|
],
|
|
1710
2157
|
"sys.load_resource": [
|
|
@@ -1745,8 +2192,12 @@
|
|
|
1745
2192
|
],
|
|
1746
2193
|
"sys.set_engine_throttle": [
|
|
1747
2194
|
{
|
|
1748
|
-
"sourceHash": "
|
|
1749
|
-
"ts": "
|
|
2195
|
+
"sourceHash": "3e3d6cc6b4f7ebb6",
|
|
2196
|
+
"ts": "sys.set_engine_throttle(false);"
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
"sourceHash": "8bf9b8da4d26c449",
|
|
2200
|
+
"ts": "sys.set_engine_throttle(true, 1.5);"
|
|
1750
2201
|
}
|
|
1751
2202
|
],
|
|
1752
2203
|
"sys.set_error_handler": [
|
|
@@ -1755,10 +2206,10 @@
|
|
|
1755
2206
|
"ts": "// Install error handler that just prints the errors\nfunction my_error_handler(source: unknown, message: unknown, traceback: unknown) {\n print(source); //> lua\n print(message); //> main/my.script:10: attempt to perform arithmetic on a string value\n print(traceback); //> stack traceback:\n //> main/test.script:10: in function 'boom'\n //> main/test.script:15: in function <main/my.script:13>\n}\n\nfunction boom() {\n return 10 + \"string\";\n}\n\nexport default defineScript({\n init() {\n sys.set_error_handler(my_error_handler);\n boom();\n },\n});"
|
|
1756
2207
|
}
|
|
1757
2208
|
],
|
|
1758
|
-
"sys.
|
|
2209
|
+
"sys.set_render_enabled": [
|
|
1759
2210
|
{
|
|
1760
2211
|
"sourceHash": "aa4a8e62d5eddb0b",
|
|
1761
|
-
"ts": "// Disable rendering\nsys.
|
|
2212
|
+
"ts": "// Disable rendering\nsys.set_render_enabled(false);"
|
|
1762
2213
|
}
|
|
1763
2214
|
],
|
|
1764
2215
|
"sys.set_update_frequency": [
|
|
@@ -1771,6 +2222,10 @@
|
|
|
1771
2222
|
{
|
|
1772
2223
|
"sourceHash": "95117be25e11bf9f",
|
|
1773
2224
|
"ts": "// Setting the swap intervall to swap every v-blank\nsys.set_vsync_swap_interval(1);"
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
"sourceHash": "3b6e97f1ef4ca783",
|
|
2228
|
+
"ts": "// Setting the swap interval to swap every v-blank\nsys.set_vsync_swap_interval(1);"
|
|
1774
2229
|
}
|
|
1775
2230
|
],
|
|
1776
2231
|
"tilemap.get_bounds": [
|
|
@@ -1819,12 +2274,20 @@
|
|
|
1819
2274
|
{
|
|
1820
2275
|
"sourceHash": "00f46bbbb35028b3",
|
|
1821
2276
|
"ts": "function cancel_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second\"));\n // ...\n const result = timer.cancel(self.handle);\n if (!result) {\n print(\"the timer is already cancelled\");\n }\n}"
|
|
2277
|
+
},
|
|
2278
|
+
{
|
|
2279
|
+
"sourceHash": "ad9e37f1a30347b3",
|
|
2280
|
+
"ts": "function cancel_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second\"));\n // ...\n const cancelled = timer.cancel(self.handle);\n if (!cancelled) {\n print(\"the timer is already cancelled\");\n }\n}"
|
|
1822
2281
|
}
|
|
1823
2282
|
],
|
|
1824
2283
|
"timer.delay": [
|
|
1825
2284
|
{
|
|
1826
|
-
"sourceHash": "
|
|
1827
|
-
"ts": "
|
|
2285
|
+
"sourceHash": "afdbd5fc199b8290",
|
|
2286
|
+
"ts": "timer.delay(1, false, () => print(\"print in one second\"));"
|
|
2287
|
+
},
|
|
2288
|
+
{
|
|
2289
|
+
"sourceHash": "777732bd4b7c14a2",
|
|
2290
|
+
"ts": "function call_every_second(self: unknown, handle: unknown, time_elapsed: unknown) {\n const state = self as { counter: number };\n state.counter = state.counter + 1;\n print(\"Call #\", state.counter);\n if (state.counter === 10) {\n timer.cancel(handle as number); // cancel timer after 10 calls\n }\n}\n\nfunction start_counting(self: { counter: number }) {\n self.counter = 0;\n timer.delay(1, true, call_every_second);\n}"
|
|
1828
2291
|
}
|
|
1829
2292
|
],
|
|
1830
2293
|
"timer.get_info": [
|
|
@@ -1837,6 +2300,10 @@
|
|
|
1837
2300
|
{
|
|
1838
2301
|
"sourceHash": "3d4814c0a3380acf",
|
|
1839
2302
|
"ts": "function trigger_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second or manually by timer.trigger\"));\n // ...\n const result = timer.trigger(self.handle);\n if (!result) {\n print(\"the timer is already cancelled or complete\");\n }\n}"
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
"sourceHash": "96cf34367a47da0b",
|
|
2306
|
+
"ts": "function trigger_ticking(self: { handle: number }) {\n self.handle = timer.delay(1, true, () => print(\"print every second or manually by timer.trigger\"));\n // ...\n const triggered = timer.trigger(self.handle);\n if (!triggered) {\n print(\"the timer is already cancelled or complete\");\n }\n}"
|
|
1840
2307
|
}
|
|
1841
2308
|
],
|
|
1842
2309
|
"update": [
|
|
@@ -2143,6 +2610,10 @@
|
|
|
2143
2610
|
{
|
|
2144
2611
|
"sourceHash": "5075cb14faa9510b",
|
|
2145
2612
|
"ts": "function window_callback(self: unknown, event: unknown, data: Record<string | number, unknown>) {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONFIED) {\n print(\"window.WINDOW_EVENT_ICONFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n}\n\nexport default defineScript({\n init() {\n window.set_listener(window_callback);\n },\n});"
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
"sourceHash": "c4168599cd777bb9",
|
|
2616
|
+
"ts": "function window_callback(self: unknown, event: unknown, data: Record<string | number, unknown>) {\n if (event === window.WINDOW_EVENT_FOCUS_LOST) {\n print(\"window.WINDOW_EVENT_FOCUS_LOST\");\n } else if (event === window.WINDOW_EVENT_FOCUS_GAINED) {\n print(\"window.WINDOW_EVENT_FOCUS_GAINED\");\n } else if (event === window.WINDOW_EVENT_ICONIFIED) {\n print(\"window.WINDOW_EVENT_ICONIFIED\");\n } else if (event === window.WINDOW_EVENT_DEICONIFIED) {\n print(\"window.WINDOW_EVENT_DEICONIFIED\");\n } else if (event === window.WINDOW_EVENT_RESIZED) {\n print(\"Window resized: \", data.width, data.height);\n }\n}\n\nexport default defineScript({\n init() {\n window.set_listener(window_callback);\n },\n});"
|
|
2146
2617
|
}
|
|
2147
2618
|
],
|
|
2148
2619
|
"zlib.deflate": [
|