Adding a "Search" Verb to a room.

Anonynn
So my idea is to use a script if the player types in the word "search or search area" which is ordinarily like any other "if script"

My problem is I don't know how to set up the beginning of the script since the room is a room.object and has no "verb" tab. I figure going into the "scripts" of the room.objects is the first step.

Basically I would like...

player types "search or search area"
First Time Script
If Script
Else
Else
Else If

then if they try it again, msg ("You've already searched here."), meaning they can only do it once per room.

Any ideas?

XanMag
Can you just add a scenery object called "room" and give it other names like "area", "surroundings", etc and then add a command for each "room" object called "search; explore; analyze" etc. then just run an 'If' script for the results. Each 'Else If' would need to have a set/unset flag for each unique response.
If I understand your problem correctly, that should work? I just based a little game on that very concept. :)

Sorry if I misunderstood your intent.

The Pixie
XanMag's way is the simple way, but will be more work if you have lots of rooms.

The complicated way is to set up a global command, and have it check the current room. Add a script like this:
if (GetBoolean(player.parent, "alreadysearched")) {
msg ("You've already searched here.")
}
else {
if (HasScript(player.parent, "search")) {
do(player.parent, "search")
}
else {
msg ("You search but find nothing.")
}
player.parent.alreadysearched = true
}

Any room that has something to find, give it a script attribute called "search", that gives an appropriate message, and either makes a object visible or moves it into the room.

Anonynn

Can you just add a scenery object called "room" and give it other names like "area", "surroundings", etc and then add a command for each "room" object called "search; explore; analyze" etc. then just run an 'If' script for the results. Each 'Else If' would need to have a set/unset flag for each unique response.
If I understand your problem correctly, that should work? I just based a little game on that very concept. :)

Sorry if I misunderstood your intent.



The only problem is what Pixie basically said, I have a ton of rooms and adding an object called "room" to all of them would be a massive pain in the butt, plus I think having "room" or something along those lines would only confuse the player, especially in rooms with a lot of objects. I just want things as simple as possible for the player, but give them a lot of options at the same time.

Btw, great to hear from you again Xan, how've you been?

The complicated way is to set up a global command, and have it check the current room



Just to clarify, Pix, if I set up that global command, would I be able to assign "If's" to each specific room? It's sort of the idea that each room of the game (even the outside areas) could yield items sometimes, or money, or weapons, or nothing, or sometimes even little extra scenery ambience. It sounds like it'll do what I want, but how do I go to each room and set up a "search script" with specific if's? How would that look?

Set up Variable or Attribute: Search ?

Also, are the Global Commands the same as "Commands" listed usually under the verbs?

XanMag
I've been great. Just busy. Soccer is finally over and I have more free time on my hands, which means I will probably be on here a little more frequently! Thanks for asking.

I still think my way wouldn't take too long or be that big of a pain, but I'm getting to the point where I am mastering the efficiency of the pain way. If the object is scenery, there should be no confusion, right? If a player wants to search the room a little more, they simply type search room, which leads them to a script you could just copy-paste in every room, only changing the description or results. You'd have to do that for each room anyway. Perhaps I misinterpret your intent and I only defend my suggestion because I am stubborn and do not understand (yet) Pixie's suggestion! :lol:

Happy Gaming!

XanMag

HegemonKhan
a different design, is to use the old RPG game designs:

http://img.gamefaqs.net/screens/c/6/1/gfs_29015_2_9.jpg

to do this design, you add Objects and give them Verbs, for example:

'character button' Object
-> 'stats screen button' Verb
-> 'magic screen button' Verb
-> 'equipment screen button' Verb
-> 'items screen button' Verb
'action button' Object
-> 'talk button' Verb
-> 'fight button' Verb
-> 'search~explore button' Verb
-> 'take button' Verb
-> 'drop button' Verb
-> 'cast spell button' Verb
etc etc etc

// or using non-grouping by Objects:
'talk button' Object
-> 'talk button' Verb
'search-explore button' Object
-> 'search-explore button' Verb
etc etc etc

---------------

as for how to set it up, you could add these Objects and their Verbs to every room (and their scriptings would be set up for each of those rooms) ... very inefficient, but simple to do. Or, you could simply add these Objects to your 'player' Player Object, thus being carried around by him-her (as inventory objects), which you can click on, for use in each~every room that you go to, though you'll need your scripting to account for the various situations of each room... of course.

as to the specific details of setting up either design, I can help with that.

-------------

the other design would be to use input by the person playing the game, ie: they type in 'search' to search a room, which means using Commands.

or, you can use the inline hypertext links too instead of typed-in input, but this still uses Commands (and the text processor commands)

--------------

yes, 'Commands' are the Commands Element under the 'Game' Object Element:

Game
-> Verbs ( http://docs.textadventures.co.uk/quest/ ... /verb.html )
-> Commands ( http://docs.textadventures.co.uk/quest/ ... mmand.html )

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

----

(the very generalized term of 'commands' for anything~whatever, I use lowercase 'c' for, and I use the upper case 'C' for the Command Element, to differentiate them. Lastly I use all caps for when using it as a main category: COMMANDS, VARIABLES, etc):

COMMANDS:
-> Command Element
-> Verb Element

VARIABLES:
-> Variable
-> Attribute***
-> Parameters

***ATTRIBUTES:
-> String Attribute
-> Integer Attribute
-> Double Attribute
-> Script Attribute
-> Boolean Attribute
-> Object Attribute
-> etc etc etc

Objects:
-> Game Object
-> Room Objects
-> Player Objects
-> Non-room, Non-player Objects

OOD~P (Object-Oriented Design~Programming)'s OBJECTS (the main units of the user-level of quest), called 'Elements' in quest:
-> Objects
-> Commands
-> Verbs
-> Exits
-> Functions
-> Object Types (Types)
-> Turnscripts
-> Timers
etc etc etc

---

technically, actually 'verbs' are a sub-type of a Command Element in terms of their underneath programming:

COMMAND ELEMENTS:
-> Command Element
-> Verb Element

---

as you know, Verbs are for individual Rooms~Objects: Verbs are 'local' to ONLY that Room~Object

whereas, Commands are global~universal (game-wide), but they require typed-in input during game play, to activate them and send any other needed inputs to and for usage in the Command's scripting (via Parameters).

(I have a post somewhere on Commands... not sure if I can find it though... wish me luck, laughs)

I think this is it (Yay!):

viewtopic.php?f=10&t=5389&p=37407&hilit=Verbs+and+Commands#p37407 (hmm... not that useful... I see if I have and can find another post that is more informative on using Commands)
^^^^^^^
viewtopic.php?f=10&t=5414&hilit=Verbs+and+Commands (you may want to look at this link too, as I try to explain how to code with quest)

ah, I think this is a little more detailed (read over all posts and~or scroll down to my posts on Commands):

viewtopic.php?f=10&t=5365&hilit=Verbs+and+Commands

---------

ask if you need any help!

Anonynn
Yeah, I think it would work either way.

If I use the verb, "Search Area" and make it scenery like Xan suggested, then I could just add that to each room and customize it.

Pixie suggested using a "Command" which sounds pretty intriguing, but I don't know how to apply it to different rooms. I know the only real way to apply anything to a room is to use it's "Scripts" tab. As I said though, I don't know how to apply that to a "Room Object" in the scripts tab. Like...is that a "Set Variable", or a "Get Input?"

So either way works, but I just want to know what the best way is :) and how to implement it.

I mean hell, this could also open up a movement randomization thing as well. Like, for example...

When exiting a room, you could potentially get one of three or four different randomized rooms. So each playthrough would be different. But I'll save that until the search area, and combat system are implemented. One thing at a time! (I wish!)

HegemonKhan
Commands, like Turnscripts, can be global (game-wide), or local to specific rooms.

Commands use typed-in input or clicking on the hyerlinks during game play, though Commands do require a bit more scripting, which you may need help with. Otherwise, a Command is just like a Verb or Turnscript (once you dealt with the Command's properties: its 'pattern' mainly), as it just holds your scripting (add new scripts), like Verbs and Turnscripts do, well, aside from the conditional scripting you'll need as well, which will be a bit difficult too.

---------

(basic) Randomization (usage), actually isn't that hard to implement, wink ;)
(well, you do need to understand lists, as randomization uses lists to "randomly" select its choice~item from the list)

-------

here's a simple Command example:

<command name="character_stat_screen_command">
<pattern>stats</pattern>
<script>
ClearScreen
msg ("Strength: " + player.strength)
msg ("Endurance: " + player.endurance)
msg ("Dexterity: " + player.dexterity)
msg ("Agility: " + player.agility)
msg ("Speed: " + player.speed)
msg ("Luck: " + player.luck)
msg ("Intelligence: " + player.intelligence)
msg ("Spirituality: " + player.spirituality)
msg ("Mentality: " + player.mentality)
// etc etc etc
wait {
ClearScreen
}
</script>
</command>


during game play, you'd jsut type in: stats, to see your character stats info outputed:

(screen~text gets cleared)
Strength: 100
Endurance: 100
etc etc etc
([press continue hyperlink], to clear the screen~text again, "closing the stat screen")

this is the simpliest usage of a Command, as it doesn't require any inputs to be sent into its scripting

------

and, here's one that uses inputs:

<command name="adding_five_integers_command" parameters="value1,value2,value3,value4,value5">
<pattern>add #text1# #text2# #text3# #text4# #text5#</pattern>
<script>
sum = value1 + value2 + value3 + value4 + value5
msg (value1 + " + " + value2 + " + " + value3 + " + " + value4 + " + " + value5 + " = " + sum)
</script>
</command>

// the inputs may need to be converted into 'ints' for the arithmetic-addition, if they're 'strings' still, obviously
// can't remember if quest handles this or not for you


during game play you type in:

add 1 9 2 8 10
// output: 1 + 9 + 2 + 8 + 10 = 30

conceptually how Parameters work with Commands:

value1 <--- #text1# <--- 1
value2 <--- #text2# <--- 9
value3 <--- #text3# <--- 2
value4 <--- #text4# <--- 8
value5 <--- #text5# <--- 10

HegemonKhan
"Just to clarify, Pix, if I set up that global command, would I be able to assign "If's" to each specific room? It's sort of the idea that each room of the game (even the outside areas) could yield items sometimes, or money, or weapons, or nothing, or sometimes even little extra scenery ambience. It sounds like it'll do what I want, but how do I go to each room and set up a "search script" with specific if's? How would that look? (neonayon)"

Pixie's design is this (hopefully I can explain so the concept makes sense to you, and hopefully I am understanding it myself correctly, laughs):

1. (upon typing the activation 'pattern' during game play) the global 'search' Command, will attempt to search the room that the player is in.
2. the 'attempt' by the 'search' Command is a checking of if the room has a 'search' Attribute added to it ('roomX' Room Object -> 'Attributes' Tab -> Attributes -> Add -> 'search' Script Attribute), and whether it has been already searched or not (must use int~string~boolean roomX Attributes as flags, and NOT 'firsttime~otherwise' Scripts~Functions, if you want to do it within the global 'search' Command's scripting one time, instead of doing it for every single Room Object's 'search' Script Attribute)
3. roomX's 'search' Script Attribute is what happens for that room (do~if you find something, get a message, or something happens, or not).
4. so, your 'search' Command is just checking if the room you're in, has a 'search' Script Attribute, and if so, then the 'search' Command activates~runs the room's 'search' Script, which is what is actually is going to ... (give you an item, a message, do soemthing, or not), and if the room has no 'search' Script Attribute, then the 'search' Command will gives you its message that you can't search or can't find anything. There could be some minor redundency involved if not careful, between the 'no search attribute' in the Command and the 'nothing found or you already searched this room' msg script of the roomX.

---------

here's a quick example:

<command name="global_search_command">
<pattern>search</pattern>
<script>
if (HasScript (player.parent, "search") {
invoke (player.parent.search)
} else {
msg ("You're unable to search this room and~or weren't able to find anything of value")
}
</script>
</command>

<object name="room1">
</object>

<object name="room2">
<attr name="search" type="script">
firsttime {
MoveObject(gold_coin, player)
} otherwise {
msg ("You already searched this room thoroughly, there's nothing that you missed.")
}
</attr>
</object>

<object name="room3">
<attr name="search" type="script">
msg ("Upon searching, you set off a trap, gruesomely resulting in your messy death.")
msg ("GAME OVER")
finish
</attr>
</object>

<object name="room4">
<attr name="search" type="script">
firsttime {
msg ("You search and search, yet are unable to find anything of significance")
} otherwise {
msg ("You already searched this room thoroughly, there's nothing that you missed.")
}
</attr>
</object>

<object name="player">
</object>

<object name="gold_coin">
</object>


when you type in 'search' during game play in:

room1, the output is: You're unable to search this room and~or weren't able to find anything of value
room2, the output is: (if firstime: you get the gold_coin added to your inventory, otehrwise: You already searched this room thoroughly, there's nothing that you missed.)
room3, the output is: (I'm lazy: death and game over messages, aka you die, game over)
room4, the output is: You search and search, yet are unable to find anything of significance

does this design of Pixie's makes sense now?

(firsttime~otherwise, can NOT be used in the 'search' Command's scripting, it must be used in the individual rooms' 'search' Script Attributes)

(there's other methods, if you want a global, aka in the 'search' Command's scripting, firsttime~otherwise messages such as using int~string~boolean roomX Attributes as flags to be checked by the 'search' Command's scripting, instead of applying 'firsttime~otherwise' Scripts~Functions over and over again to every single Room Object's 'search' Script Attribute)

The Pixie
HegemonKhan wrote:"Just to clarify, Pix, if I set up that global command, would I be able to assign "If's" to each specific room?

You set a script on the specific room called "search", and the command checks for that, so no, you do not assign "if"s to specific rooms, but the system can (and is designed to) be set so each room is handled specifically.

Anonynn
Alrighty, so this is what I got from what you both said...Is this correct?

Command Pattern
"global_pillage_command"
Name: pillage
Unresolved object text:

//SCRIPT
if (HasScript (player.parent, "pillage") {
invoke (player.parent.pillage)
}
else {
msg ("You're unable to search this room and~or weren't able to find anything of value")
}
//((^---- this is failing to load))
//INDIVIDUAL ROOMS
object name = "creation_room"
//ADD ATTRIBUTE
pillage (command pattern)
//ROOM SCRIPTS
//BEFORE OR AFTER ENTERING THE ROOM
firsttime {
msg ("You cannot search this room, but you're getting the hang of it!")
} otherwise {
msg ("Nope.")
}
//NEXT INDIVIDUAL ROOM (that you can actually search)
//ADD ATTRIBUTE
pillage (command pattern)
//ROOM SCRIPTS
//BEFORE OR AFTER ENTERING THE ROOM
firsttime {
If (RandomChance(40)) {
msg ("You found blah blah blah!)
Move blah blah to inventory
}
else if {
msg ("You found 10 blah blah gold")
set variable or attribute player.gold = playergold + 10
}
else if {
msg ("Blurg!")
}
else {
msg ("You already searched this room thoroughly, there's nothing that you missed.")
}
^---- ((is this how it's done?))

HegemonKhan
your Command's 'pattern' should be: pillage
(during game play, you'd type in the pattern, which in this case, would be: pillage)

your Command's name should be: (whatever you want as its name ~ you don't need the global, nor underscores, in it, as that's just something I like to do to convey it's to be a global Command and not a local-room Command, and I just like underscores, lol)

unresolved object text: (I believe this is to be the message that gets displayed when the command fails to run, a "defaultexpression" as it's called with Verbs, I think)

'invoke' and 'do' are generally the same thing, with just different syntax setup for them, and there's some minor differences when an 'invoke' won't work, whereas a 'do' will. If you like using 'MoveObject(x,y)', then you'll be more familiar with using 'do', whereas if you like 'x.parent = y', then you'll like using 'invoke', laughs. I obviously fall on the side of 'x.parent=y' and 'invoke', lol.

----------------

Neonayon wrote:if (HasScript (player.parent, "pillage") {
invoke (player.parent.pillage)
}
else {
msg ("You're unable to search this room and~or weren't able to find anything of value")
}
//((^---- this is failing to load))


try using 'do' (see Pixie's usage of 'do' or look 'do' up in the quest docs, for its syntax) instead of 'invoke', otherwise, it just might be a typo somewhere... we'd need possibly the full game code to check it for you, if you can't find the issue.

-------------

no, you don't want to 'add pillage (command pattern)' to your rooms!

you want to create~add a 'pillage' Script Attribute to your rooms:

'room1' -> 'Attributes' Tab -> Attributes -> Add -> (see below)
// and do the same for: room2, room3, etc etc etc

(Object Name: room1)
Attribute Name: pillage
Attribute Type: script
Attribute Value: (add in your scripts: add new script)

IMPORTANT:

also, this means *NO* usage of 'onenterroom' and 'onexitroom' Scripts for the room, in relation to your 'pillage' Command. We're making~adding our own Script Attribute, called 'pillage', to the room, for our 'pillage' Command to check for and possibly call upon ~ activate it.

----------

if you meant for the 'pillage' Command to be global, you don't need to add it to each of your rooms.

you just do this to make a global Command (it has nothing to do with the Types you've been learning about, if this was your possible thinking):

Game
-> Verbs
-> Commands -> Add -> (set it up)
(this is a global Command, you can type in 'pillage' in any room during game play, and the 'pillage' Command will be used~run~called~activated~etc)

--
I'm not familar with your doing of (or what you mean by):

//add attribute
pillage (command pattern)
--

Anonynn

if (HasScript (player.parent, "pillage") {
do (player.parent.pillage)
}
else {
msg ("You're unable to search this room and~or weren't able to find anything of value")
}



This is still having a failing to load error. :P

your Command's 'pattern' should be: pillage
(during game play, you'd type in the pattern, which in this case, would be: pillage)

your Command's name should be: (whatever you want as its name ~ you don't need the global, nor underscores, in it, as that's just something I like to do to convey it's to be a global Command and not a local-room Command, and I just like underscores, lol)



Done and done!

no, you don't want to 'add pillage (command pattern)' to your rooms!



Okay! I wasn't going to until you guys gave the go ahead lol, I was too scurred.

you want to create~add a 'pillage' Script Attribute to your rooms:

'room1' -> 'Attributes' Tab -> Attributes -> Add -> (see below)
// and do the same for: room2, room3, etc etc etc

(Object Name: room1)
Attribute Name: pillage
Attribute Type: script
Attribute Value: (add in your scripts: add new script)



Okie dokie! I understand this so far as well.


also, this means *NO* usage of 'onenterroom' and 'onexitroom' Scripts for the room, in relation to your 'pillage' Command. We're making~adding our own Script Attribute, called 'pillage', to the room, for our 'pillage' Command to check for and possibly call upon ~ activate it.



^--- okay! I wouldn't need to anyway, since I can put the Script right on the Attribute page of each room as you described above so no worries.

I'm not familar with your doing of (or what you mean by):

//add attribute
pillage (command pattern)



Oh! I was just trying to be proactive and guess how it works basically. But to explain myself, we are using a Command Pattern, well if you go into the Attributes Tab of a room you make, you can actually pick from the list of options (like Boolean, Integer etc), Command Pattern. So at first I thought we would link the Command Pattern via the Attribute page by making the Attribute a Command Pattern, and then "Pillage" as a way to connect the two. But obviously they have nothing to do with one another! Haha. That's what I get for thinking!

By the way, thank you for your help so far HK (and you too, Pixie! Hope everything has been okay lately! You're so quiet!)

HegemonKhan
this:

do (player.parent.pillage)

is *NOT* the correct syntax for 'do'.

here's the 'do' syntax:

http://docs.textadventures.co.uk/quest/scripts/do.html

do (object, string attribute name)
do (object, string attribute name, dictionary parameters)

so, you'd do~use~type-in this:

do (player.parent, "pillage")

sorry for the confusion with how to use 'do', as it's not the same as how you use 'invoke'.

---------

so, the GUI~Editor, has a 'command pattern' option... another thing that confuses me about it, laughs. I'll continue to stick with the code! :D

The Pixie
Set up the command like this:
search1.png

This is an example room with something to be searched. Set it up like this:
search2.png

Here is a complete example game:
<!--Saved by Quest 5.6.5783.24153-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="searching">
<gameid>47c5d11e-6314-4f54-89b2-455fb853eba3</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="east" to="room_with_something">
<inherit name="eastdirection" />
</exit>
</object>
<command name="search_room">
<pattern>search;pillage;search room;search area</pattern>
<script>
if (GetBoolean(player.parent, "alreadysearched")) {
msg ("You've already searched here.")
}
else {
if (HasScript(player.parent, "search")) {
do (player.parent, "search")
}
else {
msg ("You search but find nothing.")
}
player.parent.alreadysearched = true
}
</script>
</command>
<object name="room_with_something">
<inherit name="editor_room" />
<search type="script">
msg ("You search the room and find a gem.")
gem.visible = true
</search>
<object name="gem">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<take />
</object>
<exit alias="west" to="room">
<inherit name="westdirection" />
</exit>
</object>
<walkthrough name="test">
<steps type="simplestringlist">
search
search
east
search
take gem
search
</steps>
</walkthrough>
</asl>

Anonynn
Great! I think it's working out well so far! Thank you both so much for helping! I also appreciate Xan offering another solution too!

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

Support

Forums