Files
aego/tests/docs/testdata/keywords.golden.json

65 lines
9.0 KiB
JSON

{
"@export": "@export saves the field in the scene and shows it in the Inspector.\nArguments: min, max, step (numbers only), unit, display, tip, category.\n\n@export(min=0, max=600, unit=\"px/s\")\nvar Speed float = 220",
"@former": "@former lists old names so scenes saved before a rename still load; the scene is rewritten with the new name on save.\n\n@former(\"Velocity\")\n@export var Speed float",
"@hide": "@hide keeps the script out of the Add Script menu. Existing attachments keep working.",
"AssetRef": "AssetRef<Texture | Scene | Prefab | Mesh> references an asset and may be nil. Assign it in the Inspector.\n\n@export var Bullet AssetRef<Prefab>",
"Color": "Color has lanes R, G, B and A in linear space, from 0 to 1.\n\nred := Color{1, 0, 0, 1}",
"ComponentRef": "ComponentRef<T> references a component on a node and is re-validated on every access.\n\nsr := node.Get<SpriteRenderer>()\nif sr != nil {\n\tsr.FlipX = true\n}",
"Connect": "Connect registers a method with the same parameters as the signal and returns a Connection. The handler must be a plain method: not a coroutine and not a lifecycle method.\n\nconn = enemy.Died.Connect(OnEnemyDied)",
"Connected": "Connected reports whether the connection is still active. It becomes false after Disconnect or when the source or the handler owner stops.",
"Connection": "Connection is a handle returned by Connect. Keep it in a field to Disconnect later.",
"Coroutine": "Coroutine is a handle returned by start. The zero value is nil and is never running.",
"Disconnect": "Disconnect removes the handler; calling it twice is harmless.\n\nconn.Disconnect()",
"Emit": "Emit calls every connected handler synchronously, in connection order. Connections added or removed by a handler apply after this Emit returns.\n\nDied.Emit(\"fall\")",
"FixedUpdate": "FixedUpdate runs every fixed step, before physics. dt is the fixed step, 1/60 by default.\n\nfunc FixedUpdate(dt float) {\n}",
"GetScript": "GetScript<T>() returns the instance of script T on the node, or nil when the node has none. Use pkg.Name when the short name is ambiguous.\n\ne := Target.GetScript<EnemyAI>()\nif e != nil {\n\te.Died.Connect(OnEnemyDied)\n}",
"NodeRef": "NodeRef references a scene node and may be nil. Exported NodeRef fields are set by dragging a node onto the field in the Inspector.\n\n@export var Target NodeRef",
"Quat": "Quat is a 3D rotation with lanes X, Y, Z and W. Build it with math.QuatEuler or math.QuatAxisAngle. Quats cannot be compared with ==.",
"Ready": "Ready runs once after every instance in the scene exists and references are resolved, in scene pre-order.\n\nfunc Ready() {\n}",
"Rect": "Rect has lanes X, Y, W and H.",
"Reloaded": "Reloaded runs after a hot reload for every instance whose script or a dependency changed. Ready does not run again.\n\nfunc Reloaded() {\n}",
"Running": "Running reports whether the coroutine is still alive (not finished, cancelled or faulted).\n\nif !blink.Running() {\n\tblink = start Blink()\n}",
"ScriptRef": "ScriptRef<T> references a script instance on a node. Through it you read and write fields, call plain methods and connect to signals of T. Lifecycle methods and coroutines are not reachable (AES2059). It becomes invalid when the instance stops; access then faults with AES6004.\n\nvar enemy ScriptRef<EnemyAI>",
"Stop": "Stop cancels the coroutine; it does not run again. Stopping a finished coroutine is harmless.\n\nblink.Stop()",
"Transform2D": "Transform2D holds Position Vec2, Rotation float in radians (clockwise) and Scale Vec2. It is a value: read it, change it, write it back.\n\nt := node.Transform2D()\nt.Position.X += 1\nnode.SetTransform2D(t)",
"Transform3D": "Transform3D holds Position Vec3, Rotation Quat and Scale Vec3.\n\nt := node.Transform3D()\nt.Position.Y += 1\nnode.SetTransform3D(t)",
"Update": "Update runs every frame. dt is the frame time in seconds.\n\nfunc Update(dt float) {\n}",
"Vec2": "Vec2 is a 2D vector with lanes X and Y. Build it with a composite literal; it supports +, -, and * or / by a float.\n\nv := Vec2{1, 0} * Speed",
"Vec3": "Vec3 is a 3D vector with lanes X, Y and Z.\n\nup := Vec3{0, 1, 0}",
"append": "append returns the slice with v added at the end. Assign the result back.\n\nhits = append(hits, 5)",
"bool": "bool is true or false. Conditions of if and for must be bool.",
"break": "break leaves the innermost for loop or switch.",
"case": "case lists one or more values for a switch branch.",
"const": "const declares a compile-time constant of type bool, int, float, string or enum. Packages hold constants only, never mutable variables.\n\nconst MaxSpeed float = 600",
"continue": "continue jumps to the next iteration of the innermost for loop.",
"coroutine": "coroutine after a method signature makes the method a coroutine: it can pause with yield and continue on a later frame. Only script methods without a result can be coroutines, and lifecycle methods cannot. Run one with start Name(args).\n\nfunc Blink() coroutine {\n\tyield wait(0.1)\n}",
"default": "default runs when no case of the switch matches.",
"else": "else runs when the preceding if condition is false. It must stay on the line of the closing brace: } else {",
"enum": "enum declares named int constants used as Name.Member. A switch on an enum must cover every member or have a default.\n\nenum State {\n\tIdle\n\tRun\n}",
"false": "false is the bool constant for no.",
"float": "float is a 32-bit IEEE number. float → int conversion saturates and maps NaN to 0.",
"for": "for is the only loop: for cond {}, for init; cond; post {} or for {} for an endless loop.\n\nfor i := 0; i < len(items); i++ {\n}",
"func": "func declares a function. Package functions see no script state; functions inside a script are methods and can use node and the fields.\n\nfunc clamp01(x float) float {\n\treturn math.Clamp(x, 0, 1)\n}",
"if": "if runs a block when the bool condition is true. No parentheses around the condition.\n\nif hp <= 0 {\n\tdie()\n} else if hp < 10 {\n\tflee()\n}",
"import": "import makes a script package or an engine module available by the last element of its path.\n\nimport (\n\t\"aego/input\"\n\t\"mygame/combat\"\n)",
"int": "int is a signed 64-bit integer that wraps on overflow. Convert with float(i) and int(f); there is no implicit conversion.",
"len": "len returns the number of elements of a slice or the number of bytes of a string.\n\nn := len(items)",
"nil": "nil is the empty reference. Only NodeRef, AssetRef and ComponentRef can be nil; reading through nil faults with AES6004.\n\nif Target != nil {\n}",
"node": "node is the NodeRef of the node this instance is attached to. It exists in every script method.\n\nt := node.Transform2D()",
"package": "package names the package of this file. It must equal the directory name under scripts/; all files in one directory share it.",
"return": "return ends the function, with a value when the function declares a result. Such a function must return on every path.",
"script": "script declares a stateful type that attaches to scene nodes. A node holds at most one instance of each script type.\nvar fields are runtime state; @export fields are saved in the scene and shown in the Inspector.\n\nscript Mover {\n\t@export var Speed float = 200\n\tfunc Update(dt float) {\n\t}\n}",
"signal": "signal declares an event of the script. Only the script itself can Emit it; other scripts Connect to it through a ScriptRef.\n\nsignal Died(reason string)",
"start": "start runs a coroutine method of this script up to its first yield and returns its Coroutine handle. The coroutine belongs to the instance and is cancelled when the instance stops.\n\nblink = start Blink()",
"string": "string is immutable UTF-8 text. + concatenates, len counts bytes, string(x) converts bool, int and float.",
"struct": "struct lists the fields of a type declaration. Fields may be scalars, vectors, references, enums, slices or other structs.",
"switch": "switch compares a value with each case and runs the first match. There is no fallthrough.\n\nswitch state {\ncase State.Idle:\ncase State.Run, State.Walk:\ndefault:\n}",
"true": "true is the bool constant for yes.",
"type": "type declares a struct. Structs are values: assignment and passing copy them.\n\ntype Stats struct {\n\tHp int\n\tArmor float\n}",
"var": "var declares a variable with an explicit type and an optional value. Inside a script it declares a field.\n\nvar hits []int\nvar speed float = 1.5",
"yield": "yield pauses the current coroutine:\n yield next frame\n yield wait(s) after s seconds of game time\n yield frames(n) after n frames\n yield fixed(n) after n fixed steps\n yield c when coroutine c ends\nyield is allowed only inside a coroutine (AES2050).",
"yield fixed": "yield fixed(n int) resumes after n fixed steps, before physics; use it for movement that must stay in step with FixedUpdate.\n\nyield fixed(1)",
"yield frames": "yield frames(n int) resumes after n frames; frames(1) is the same as a bare yield.\n\nyield frames(3)",
"yield wait": "yield wait(seconds float) resumes after the given game time has passed, at the earliest on the next frame.\n\nyield wait(0.25)"
}