Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#CLIENTSIDE
- const resetTime = 2;
- function onCreated() {
- configKeyOrders();
- this.test = "";
- }
- function onKeyPressed(keycode, key) {
- this.test = (this.combosenabled?this.test:"") @ key;
- temp.check = ((this.testcheck!=false)
- ? this.testcheck(this.test)
- : this.check(this.test)
- );
- if (temp.check.type() == 3) { // check if it's an array
- keyCombo(this.test, temp.check[1], temp.check.subarray(2));
- }
- scheduleEvent(resetTime, "remove");
- }
- function keyCombo(sequence, action, options) {
- /* Go through each sequence to do sequence-based actions */
- switch(sequence) {
- case "dream":
- if (player.level.name == "dungeon01-b2.nw") {
- player.addAchievement("foundhiddendungeon1");
- }
- }
- /* go through the action key words and execute them with options*/
- switch(action) {
- /* single key actions */
- case "grab":
- player.movement.grab();
- break;
- case "attack":
- player.attack();
- break;
- case "useskill":
- player.useSkill();
- break;
- // add your own code to execute different actions
- case "opendoor":
- findlevel(options[0]).(@ options[1]).openDoor();
- break:
- case "addachievement":
- player.addAchievement(options[0]);
- break;
- }
- }
- function onRemove() {
- this.text = this.text.substring(1);
- }
- // Change the options for each key order here
- // this._<keyorder> = {"action", "param0", "param1", ...};
- function configKeyOrders() {
- // single key non-combo actions
- this._s = {"attack"};
- this._d = {"useskill"};
- this._a = {"grab"};
- // Answer the final riddle in the dungeon to gain access to the boss
- this._catcher = {
- "opendoor", "dungeon04-c3.nw", "doorboss"
- };
- // Answer the riddle to enter the hidden dungeon
- this._dream = {
- "opendoor", "overworld01-b2.nw", "doorentrance"
- };
- /* This is a function used to check for a valid key done in sequence.
- Return false if there's nothing valid,
- return array if the variable is valid.
- Here you could actually expand the system a lot, and even take in keys for slashing, jumping,
- use items etc, and only do combos under a certain event from another system for example.
- Then you could actually have all player key input done in one system, instead of having it
- spread out in different scripts
- */
- this.check = function(value) {
- // single keys are not a combo, so don't execute
- if (this.combosenabled && value.length() = 1) return false;
- // check if the value exists, then give the data if valid
- temp.array = makevar("this._" @ value);
- return ((temp.array.type() == 3)?temp.array:false);
- };
- this.testcheck = false;
- this.combosenabled = false;
- }
- // Allows you to change the check function temporary, includes a reset
- public function changeCheckFunction(func) this.testcheck = func;
- public function resetCheckFunction() this.testcheck = false;
- // enable or disable combos
- public function enableCombos() this.combosenabled = true;
- public function disableCombos() this.combosenabled = false;
- // allows you to re map keys
- public function changeKeys(oldkey, newkey) {
- temp.oldkey_value = makevar("this._" @ oldkey);
- if (temp.oldkey_value.type() == 3) {
- makevar("this._" @ newkey) = temp.oldkey_value;
- makevar("this._" @ oldkey) = NULL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement