{"id":26898489,"url":"https://github.com/runestar/cs2","last_synced_at":"2025-05-13T01:49:20.830Z","repository":{"id":47528060,"uuid":"147910710","full_name":"RuneStar/cs2","owner":"RuneStar","description":"Old School RuneScape cs2 decompiler","archived":false,"fork":false,"pushed_at":"2021-08-25T09:10:26.000Z","size":4209,"stargazers_count":41,"open_issues_count":0,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T01:49:17.380Z","etag":null,"topics":["oldschool-runescape","osrs","runescape","runescript"],"latest_commit_sha":null,"homepage":"https://github.com/RuneStar/cs2-scripts","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RuneStar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-08T07:10:57.000Z","updated_at":"2025-01-12T15:44:31.000Z","dependencies_parsed_at":"2022-07-21T02:48:38.796Z","dependency_job_id":null,"html_url":"https://github.com/RuneStar/cs2","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuneStar%2Fcs2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuneStar%2Fcs2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuneStar%2Fcs2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuneStar%2Fcs2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RuneStar","download_url":"https://codeload.github.com/RuneStar/cs2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856614,"owners_count":21974576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oldschool-runescape","osrs","runescape","runescript"],"created_at":"2025-04-01T05:47:51.394Z","updated_at":"2025-05-13T01:49:20.809Z","avatar_url":"https://github.com/RuneStar.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cs2 [![Discord](https://img.shields.io/discord/384870460640329728.svg?logo=discord)](https://discord.gg/G2kxrnU)\n\n[**View scripts**](https://github.com/RuneStar/cs2-scripts)\n\nClientScript2 (cs2) is a client-side scripting language used in Old School RuneScape to dynamically update interfaces.\nPlayers load scripts from the game cache in a custom bytecode format to be interpreted by the client.\n\n#### Model\n\nThere are two main kinds of scripts:\n\nClientScript: Added as callbacks for actions such as user interactions with interface components.\nWhen the user performs the action, such as click or mouse-leave, the script is executed.\nCannot return any values.\n\nProcedure: can only be called inside of another script.\nThe caller may be of either kind.\nAble to both take arguments and return values.\n\n#### Signature\n\nThe first line of a script is its signature.\nIt contains the script's kind, name, the types and names of its parameters, and its return types.\nA script may return multiple values.\nA Procedure is indicated by `proc` and a ClientScript by `clientscript`.\n\n`[proc,min](int $a, int $b)(int)`\n\n`[clientscript,settrans](component $component, int $trans)`\n\nEach script can take a maximum of 50 arguments and return a maximum of 50 values.\nIf a script does not return anything, the parentheses around its return types can be omitted.\n\n#### Variables\n\nGlobal variables:\nDefined outside of scripts in config files.\nCan be used and modified inside any script.\nAccessed by prefixing its name with a percent sign, like `%raids_lobby_partysize`.\nInternally stored as either varps, varbits, or varcs.\n\nGlobal constants:\nUnable to be modified.\nDefined outside of scripts.\nAccessed by prefixing its name with a caret, like `^iftype_rectangle`.\n\nLocal variables:\nMust be defined and initialized to a valid value before being used.\nOnly accessible inside the script in which it is defined.\nAccessed by prefixing its name with a dollar sign, like `$scrollbar`.\nArguments are also local variables which are initialized to the passed in values.\n\n#### Types\n\n`null` is a valid value for all types except for `string`\n\n* `int` : a 32-bit signed integer. Written normally or as a hexadecimal literal. `null` is equivalent to `-1`\n    * `5`, `-10`, `0x7f7f7f`\n* `string` : a sequence of characters, can be empty.\nWritten enclosed in quotes.\nString interpolation can be performed by enclosing a `string` typed expression in angle brackets and\nembedding it in a `string` literal.\n    * `\"Show\"`, `\"Magic level: \u003ctostring($lvl)\u003e\"`\n* `boolean` :\n    * `true`, `false`\n* `coord` : a tile. Written as 5 numbers separated by underscores:\nthe plane, the coordinates of the map-square, then the coordinates inside of the map-square\n    * `0_1_2_3_4`\n* `component` an interface component. Written as the interface, a colon, then the component\n    * `poh_jewellery_box:frame`\n* `obj` : an item\n* `namedobj` : an item explicitly specified in the code. Can be used as an `obj`\n    * `lawrune`\n* `enum`\n* `stat` : a skill.\n    * `attack`, `smithing`\n* `graphic` : a sprite. Written with its name enclosed in quotes\n    * `\"magicoff,12\"`\n* `inv` : an inventory of items such as the player's inventory or the bank\n* `model`\n* `category`\n* `loc`\n* `area`\n* `maparea`\n* `fontmetrics` : a font\n    * `p11_full`\n* `char`\n* `struct`\n* `synth`\n* `mapelement`\n* `npc`\n* `seq`\n\n#### Arrays\n\nAre a fixed length and all elements must be the same type.\nCan be of any type except for `string`.\nMax length of 5000.\n`int` elements are initialized to `0`, all other types to `null`.\nMax of 5 arrays per script.\nScripts may take only 1 array argument.\nArrays can only be local variables and never globals.\n\nDefining `$array` as an `int` array of length `$len` : `def_int $array($len);`\n\nGetting the `$i`th element of `$array` : `$array($i)`\n\nSetting the `$i`th element of `$array` to `$n` : `$array($i) = $n;` \n\n#### Control Flow\n\nThe only things which can be used in the test condition of an `if` or `while` statement are the following operators:\n\n* Equality comparisons\n    * `=` : equals\n    * `!` : not equals\n* Relational comparisons\n    * `\u003c` `\u003e` `\u003c=` `\u003e=` \n* Short circuiting logical operators\n    * `\u0026` : AND\n    * `|` : OR\n\nCombinations of these operators may also be used. \nVariables or other expressions of type `boolean` may not be used on their own or as arguments to the logical operators.\nThese operators cannot be used outside of an `if` or `while` statement.\n\nUsing an `if` statement to clamp an `int` value between `$max` and `$min`\n\n```\nif ($n \u003e $max) {\n    return($max);\n} else if ($n \u003c $min) {\n    return($min);\n} else {\n    return($n);\n}\n```\n\nUsing a `while` statement to repeat something 10 times\n\n```\ndef_int $i = 0;\nwhile ($i \u003c 10) {\n    // ...\n    $i = calc($i + 1);\n}\n```\n\nThere is no continue or break functionality.\n\nSwitch\n\nAny expression that is not of type `string` can be the target of a `switch` statement.\nThe cases must be constants.\nMultiple cases may lead to the same block.\nThere is no fall-through between blocks.\nAn optional `default` case can be used if none of the other cases are matched.\n\n#### Comments\n\n`//` Indicates the start of a line comment and all following text up until the end of the line is ignored\n\n#### Instructions\n\nMost instructions are indicated by their name followed by a list of their arguments, `sound_synth(2266, 1, 0)`.\nIf it takes no arguments the parentheses can be omitted, `clan_leavechat`.\n\nA Procedure is called by using a tilde followed by its name and arguments, `~min($a, $b)`.\nIf it takes no arguments the parentheses can be omitted, `~wilderness_level`.\n\nMath on `int` expressions is performed using the `calc` instruction.\nIt supports the infix operators `+` (addition), `-` (subtraction), `/` (division), `*` (multiplication), `%` (modulus),\n`|` (bitwise OR), `\u0026` (bitwise AND).\nPrecedence can be established using parentheses.\nThe entire mathematical operation is passed as an argument to `calc` and the result is returned.\n`def_int $c = calc($a * $b + 2);`\n\nAn instruction which returns multiple values can be used either directly as multiple arguments to another instruction or\nassigned to multiple variables, `$int2, $int3 = ~poh_jewellerybox_getbuttonspacing(590:2, 3);`\n\n#### Hooks\n\nA ClientScript can be assigned as a reoccurring callback for an action by using one of the instructions which start with either `if_seton` or `cc_seton`.\nThey take as their first argument the name of the ClientScript and its arguments all enclosed in quotes.\nThe ClientScript is not executed immediately but instead executed with the given parameters each time the action occurs.\n\n`cc_setonmouseover(\"autocast_tooltip($component1, $obj5)\");`\n\nInstead of using existing variables as arguments, special values starting with `event_` can be used which are resolved at the time the action occurs.\nIf a mouse event is being used `event_mousex` will be replaced by the mouse's x position when the event is triggered.\n\n`cc_setondrag(\"scrollbar_vertical_drag($component0, $component1, event_mousey, false)\");`\n\nClientScripts can not only be assigned to interface actions but also to changes in varps, skills, or inventories.\nIn this case the values which should be watched are added in braces after the arguments.\n\n`if_setonvartransmit(\"deadman_tournament_hudupdate(){var1542, var1293}\", 90:11);`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunestar%2Fcs2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunestar%2Fcs2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunestar%2Fcs2/lists"}