Multi word command for Custom Command pane

I've so far not dealt with commands yet but I want to add some attack moves into a custom command pane, however I have only seen examples of single command names like "Attack" or command names and a generic verb like '"Attack" + Object' so I have no idea how to script them.

It's sort of like Pokemon attack moves, I want to display the description of the move like "Hyper Beam (5pp)" but tie it to a specific command name and script to run when used.

Also the command pane seems to place all of the commands on single line and word wrap, how do I format it to place each command on separate lines?

I haven't gone any example code to share as this is going to be newly implemented.


(filler for getting my edited post, updated/posted)


you use a semicolon to separate the command 'patterns' (or the regex expressions, but I've not learned how to use these, KV and others can help with using regex), just as you can do so with Verbs.

http://docs.textadventures.co.uk/quest/elements/command.html

Also, you got to use the longest pattern first, and work your way down to the shortest, if you're doing those types of patterns, in order for the parsing of it to work correctly.

// user input during game play, examples:

fight orc with katana
attack orc with katana
hit orc with katana

fight orc
attack orc
hit orc

fight
attack
hit

// --------------------------------

<command name="example_command">

  <pattern>attack #object_monster_parameter# with #object_weapon_parameter#; fight #object_monster_parameter# with #object_weapon_parameter#; hit #object_monster_parameter# with #object_weapon_parameter#; attack #object_monster_parameter#; fight #object_monster_parameter#; hit #object_monster_parameter#; attack; fight; hit</pattern>

  <script>
    if (object_monster_parameter = null and object_weapon_parameter = null) {
      // blah scripting
    } else if (not object_monster_parameter = null and not object_weapon_parameter = null) {
      // blah scripting
    } else if (object_monster_parameter = null) {
      // blah scripting
    } else if (object_weapon_parameter = null) {
      // blah scripting
    }
  </script>

</command>

Um, there is no special trick. Type "Hyper Beam (5pp)". ....don't type the quotation marks, it's just a grammar thing...
I'd like to help more, but I'm making a Pokemon game now.


there's pros and cons to using '#object# / #objectXXX#' and '#text# / #textXXX#' Parameters:

the '#object# / #objectXXX#' Parameter only looks for Objects within the same Room Object that you're in, so you can type in an Object that exists in the game, but if it's not in the same Room Object that you're in, you'll get the 'unresolved' Command's response, and/or an error and/or the Command just doesn't work (as it can't work)

the '#text# / #textXXX' Parameter, is just text/string, so you'll have to do additional code work [ simplest code work is: GetObject (text) / GetObject (textXXX), but it can be much more involved code work too, depending on what you're doing ] for if its suppose to be Objects, and their handling.


"It's sort of like Pokemon attack moves, I want to display the description of the move like "Hyper Beam (5pp)" but tie it to a specific command name and script to run when used (Shadow Edge 19)"


an example (very quick, bad/poor, and incompleted code: lots more handling is needed, but it's just an example):

<object name="player">
  <attr name="ability_objectlist_attribute" type="objectlist">normal_attack_object</attr>
</object>

<object name="ability_data_object">
  <object name="normal_attack_object">
    <attr name="look" type="string">This is your normal attack</attr>
  </object>
  <object name="hyper_beam_ability_object">
    <attr name="look" type="string">The hyper beam is a very powerful attack</attr>
  </object>
  <object name="weak_beam_ability_object">
    <attr name="look" type="string">The weak beam is a very weak attack</attr>
  </object>
</object>

<command name="_command">
  <pattern>fight #object_enemy_parameter# using #text_ability_parameter#</pattern>
  <script>
    if (object_enemy_parameter = null) {
      msg ("wrong input, try again (the inputted enemy must be an enemy in the same location as you)")
    } else if (ListContains (player.ability_objectlist_attribute, GetObject (text_ability_parameter))) {
      object_variable = GetObject (text_ability_parameter)
      msg (object_variable.look)
    } else {
      msg ("wrong input: either you inputted an ability that doesn't exist/typo'ed, or you've not learned that ability yet")
    }
  </script>
</command>

I was thinking that I would be attacking a hard coded object value, such as player.parent (the room itself) and that to the player themselves all they would see is the custom command pane button and not need to type anything.


What? You make a command pattern of "Hyper Beam (5pp)", not the player.... I think that's what you meant....
I have two games that might be useful.
This is the tutorial I used (The Pixie made it for the Online Quest Version). https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)
This is what I made for practice. http://textadventures.co.uk/games/view/xb0ge9kzbewhodrtmxnnqw/the-legend-of-the-secret-of-the-smelly-stinky-fish
This is the Pokemon game I'm making.
http://textadventures.co.uk/games/view/0p9uxrxu2ueatixrnt1ixg/pokemon-type-harley-johto-and-sinnoh


@ Shadow Edge:

did you want to create a Verb instead? (Verbs use the hyperlinks and/or the buttons on the right pane, no typing is used for Verbs)


I sometimes type for verbs... on my mom's phone.


K.V.

Make your attacks into objects. When you USE the object, make it run its attack script.

Then use Pixie's library (or follow his steps to create your own pane).

https://github.com/ThePix/quest/wiki/Second-Inventory-Library


You can give your attack objects attributes and use conditional statements to choose which attack script gets run, too.

When so-and-so attribute is true, change the object's alias to ATTACK(5500HP).


Actually, you can make one game, add the inventory library onto it, copy the code, and then make your own pane.

Although this may only help me, he-he.


K.V.

>Actually, you can make one game, add the inventory library onto it, copy the code, and then make your own pane.

Yep, yep!


The word-wrap thing perturbs me, too.

Even when you use &nbsp;, Quest still breaks the line.

I just add unnecessary commands in front of my multi-word commands until it lines up like I want it. (I'm a dirty hacker!)


I have them as display verbs on an object within the room already, but I was hoping to make them as commands without relying on an unnecessary object the user first has to focus on in order to see the display verbs available.


K.V.

This method (http://textadventures.co.uk/forum/quest/topic/jwp3gkwae0uy3k2oijphog/multi-word-command-for-custom-command-pane#074188aa-5457-4128-9b94-8c805f4abf29) puts them all in their own pane.

The player only needs to click on them to interact.

...you would need to make them objects this way, but it's how most people handle spells, which are very similar to commands.

When you use the objects, it makes it easy to alter the alias that's displayed in the pane.


If you've written a lot of game, I'm sorry to keep bringing up objects, but it is a very efficient way to handle things.


As KV said,

Objects are very powerful: there's a lot of ways you can handle/use and organize/encapsulation-of them, and they're able to hold both actions/behavior (Script Attributes / Script Attributes + Delegates, and Script Dictionary Attributes) and data (String, Boolean, Integer/Double, List, and non-script Dictionary Attributes).


Here's a hypothetical for you guys, is it possible to have a HTML hyperlink from within the Custom Status Pane, instead of the Custom Command Pane, and when the user clicks in the link it calls a script for that verb?


K.V.

Yes.


K.V.
if (not DictionaryContains(player.statusattributes, "activeQuests")) {
  dictionary add (player.statusattributes, "activeQuests", "<a onclick=\"ASLEvent('HandleButtonClick', 'quest');\" style=\";cursor:pointer;\" title=\"Click here to view a list of active Quests!\">Active Quests: !</a>")
 }

<a onclick=\"ASLEvent('HandleButtonClick', 'quest');\" style=\";cursor:pointer;\" title=\"Click here to view a list of active Quests!\">Active Quests: !</a>

This calls the command: QUEST when you click on Active Quests in the status pane.

image


I have it set up so Active Quests only displays in the pane when there are active quests.


Okay so that calls a command, so provided my command name is named correctly I can use that to call the functions I have available for my existing display verbs?

Btw which line on your status pane is that highlight connected to?


K.V.

Okay so that calls a command, so provided my command name is named correctly I can use that to call the functions I have available for my existing display verbs?

As long as you can enter it on the keyboard as a command, it should work. But I forgot to include the HandleButtonClick function:


HandleButtonClick (function)
PARAMETER: s

msg ("")
msg (">" + s)
msg ("")
HandleSingleCommand (s)
JS.scrollToEnd ()

Btw which line on your status pane is that highlight connected to?

Active Quests: !


K.V.

if (not DictionaryContains(player.statusattributes, "activeQuests")) {

This checks if activeQuests is already in one of the dictionaries which is tied to the status pane.


dictionary add (player.statusattributes, "activeQuests", "<a onclick=\"ASLEvent('HandleButtonClick', 'quest');\" style=\";cursor:pointer;\" title=\"Click here to view a list of active Quests!\">Active Quests: !</a>")

dictionary add adds to the dictionary (of course)

player.statusattributes is the dictionary to which we are adding

"activeQuests" is the key.

"<a onclick=\"ASLEvent('HandleButtonClick', 'quest');\" style=\";cursor:pointer;\" title=\"Click here to view a list of active Quests!\">Active Quests: !</a>" is the entry.


Let's break that last bit down.

<a href="http://textadventures.co.uk/">CLICK ME TO VISIT textadventures.co.uk/</a> is a normal HTML link.

href="http://textadventures.co.uk/" tells the browser where the link leads.

CLICK ME TO VISIT textadventures.co.uk is the link which will be displayed.

If you hover over this link, nothing happens.

CLICK ME TO VISIT textadventures.co.uk/

...but we can add title="" to remedy that:

<a href="http://textadventures.co.uk/" title="Click here to visit textadventures.co.uk">CLICK ME TO VISIT textadventures.co.uk/</a>

CLICK ME TO VISIT textadventures.co.uk/


Now, I showed you that to show you this:

You can use onclick in place of href (note that the cursor doesn't change on hover):

<a onclick="http://textadventures.co.uk/" title="Click here to visit textadventures.co.uk">CLICK ME TO VISIT textadventures.co.uk/</a>

CLICK ME TO VISIT textadventures.co.uk/

Now, let's make the cursor a pointer:

<a onclick="http://textadventures.co.uk/" title="Click here to visit textadventures.co.uk" style="cursor:pointer">CLICK ME TO VISIT textadventures.co.uk/</a>

CLICK ME TO VISIT textadventures.co.uk/


Now, when it comes to using this in Quest it gets slightly tricky.

You cave to escape the double-quotes " with \MOST of the time, depending upon where and how you are entering the text.

If you're using the UI and print message, you need no backslashes (most of the time).

Otherwise, you need to replace all instances of " within the tag with \".

So my last link would become:

<a onclick=\"http://textadventures.co.uk/\" title=\"Click here to visit textadventures.co.uk\" style=\"cursor:pointer\">CLICK ME TO VISIT textadventures.co.uk/</a>

That would work in Quest.


To make the link interact with Quest, you need to use an ASLEvent.

A simple example would be this:

ASLEvent('HandleSingleCommand', 'look')

That would handle the single command "LOOK", without having to set up any functions or anything.

If we plug it into a link:

<a onclick=\"ASLEvent('HandleSingleCommand', 'look');\" style=\";cursor:pointer;\" title=\"Click here to LOOK!\">CLICK HERE TO CHECK OUT YOUR SURROUNDINGS</a>

Now, you could use that in Code View, and the player could click it to LOOK.

msg ("<a onclick=\"ASLEvent('HandleSingleCommand', 'look');\" style=\";cursor:pointer;\" title=\"Click here to LOOK!\">CLICK HERE TO CHECK OUT YOUR SURROUNDINGS</a>")

When you create the HandleButtonClick function, you can use it across the board for all of your links, and the function passes whatever you enter as the second parameter as a command.

So clicking this would be the same as entering QUEST as a command:

<a onclick=\"ASLEvent('HandleButtonClick', 'quest');\" style=\";cursor:pointer;\" title=\"Click here to view a list of active Quests!\">Active Quests: !</a>

NOTE: The ! is a Quest wildcard. It is tied to the integer held by the attribute activeQuests.


References:

http://docs.textadventures.co.uk/quest/quest_code.html (scroll down to Quotes in Strings)
https://www.w3schools.com/TagS/tag_a.asp
https://www.w3schools.com/jsref/event_onclick.asp
http://docs.textadventures.co.uk/quest/using_dictionaries.html
http://docs.textadventures.co.uk/quest/ui-callback.html
https://www.w3schools.com/cssref/pr_class_cursor.asp


Oh cool thanks!
I have managed to get what I needed implemented and it works just great! It's been a long time since I worked with HTML and JS so thanks for the refresher course.


K.V.

Oh cool thanks!

No problem!


I have managed to get what I needed implemented and it works just great!

Rock and Roll!


It's been a long time since I worked with HTML and JS so thanks for the refresher course.

I started to omit all of that, but thoroughness prevailed.

I never really know who knows what, you know? I try to refrain from seeming condescending...

...but I always decide providing too much information is better than not providing enough. (Plus, I usually write these sorts of posts with anyone who might happen upon it in mind.)


Yeah I tend to search for an existing answer first before posting my own, so anyone looking for any Custom Commands or ideas like I did will not have to search any more.

Now all I need to do is come up with a colour display design to separate all of my status sections...


@ShadowsEdge19 White or black?
Grey scale forward
Grey scale backward
Red orange yellow
Yellow orange red purple pink
Red purple blue green
Red blue green purple


K.V.

JS.setCss ("#gamePanes", "background:black") will change the area just around the panes black.

I've got a link to the info if you need to know how to change the border color of the panes, too.

And...

It sounds as if jmnevil54 knows a tad more about this than I do, too. (Yay! Teach us tricks, jmnevil54!)


Hey!

I forgot about the pizza, jmnevil54! I'm on it right now, though!


Yeah I tend to search for an existing answer first before posting my own, so anyone looking for any Custom Commands or ideas like I did will not have to search any more.

Yep, yep!

Whoo-hoo!


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

Support

Forums