Creating New Commands

Hey, I just now found out we can create commands in QuestKit!

---
command: switchon
patterns: ["switch on #object#","switch #object# on","turn on #object#","turn #object# on"]
action:
    script: |
        if (get (object, "switchable")){
          if (get (object, "switchedon")){
            msg("It's already switched on.");
          } else {
            msg ("You switch on the "+questkit.displayAlias(object)+".");
            set (object, "switchedon", true);
          }
        } else {
          msg ("You can't do that.");
        }
    
---
command: switchoff
patterns: ["switch off #object#","switch #object# off","turn off #object#","turn #object# off"]
action:
    script: |
        if (get (object, "switchable")){
          if (!get (object, "switchedon")){
            msg("It's already switched off.");
          } else {
            msg ("You switch off the "+questkit.displayAlias(object)+".");
            set (object, "switchedon", false);
          }
        } else {
          msg ("You can't do that.");
        }

Sweet! Now, if I could only figure out how to get the parser to work with lastObjects...

Then, I'll probably find 1,001 other things which need to be set up...


---
command: usesingle
pattern: "use #object#"
action:
    script: |
        if (getscript(object, "use")){
          var func = getscript(object, "use");
          func();
        } else {
          msg ("You can't do that.");
        }
        
---
command: useon
pattern: "use #object1# on #object2#"
action:
    script: |
        if (getscript(object2, "use["+object1+"]")){
          var func = getscript(object2, "use["+object1+"]");
          func();
        } else {
          msg ("You can't do that.");
        }

You are in a lounge.
You can see a TV, a Bob, a table, a lamp, a double bass and a defibrillator.
You can go north or south.
This is quite a plain lounge with an old beige carpet and peeling wallpaper.

> use def on bob
Miraculously, the defibrillator lived up to its promise, and Bob is now alive again. He says his head feels kind of fuzzy.


I've gotten it this far:

https://gist.github.com/KVonGit/20645be1a33187ab15755f436db2121c


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums