Destroy everything in a room
Deckrect
20 Nov 2016, 16:48How may i destroy all the items inside room, not knowing what or how many items are there?
hegemonkhan
20 Nov 2016, 17:23this involves using List Attributes... which is a bit more advanced... but not too hard to do this that you want:
all you need is the 'foreach' Script/Function:
http://docs.textadventures.co.uk/quest/scripts/foreach.html
and a 'scope' Script/Function (they return an Objectlist Attribute, which your 'foreach' Script/Function uses/will use, whatever, meh):
http://docs.textadventures.co.uk/quest/scopes.html ( separated out nicely as it's own page/section from the 'Function page/section' )
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (you can also find the 'scope' Functions in here)
and I think we'd use this one... (so confusing as to their differences and exactly what they mean... still... argh):
http://docs.textadventures.co.uk/quest/functions/corelibrary/scopevisiblenotheld.html
foreach (object_variable, ScopeVisibleNotHeld()) { // iterates through them (for each Object, which quest will automatically have represented/referenced (which is what the 'foreach' is programmed to do), by the use of my custom-named/labeled 'object_variable' variable --- you can name/label it as whatever you want, and hopefully within the Room you're in lol --- if I used the the right 'scope' Function, it will do the below seen script/action)
destroy (object_variable)
}
// hopefully... it won't destroy you the 'player' too... lol lol lol.... that's a funny/evil idea for ending the game, laughs... HK is evil game designer... lol
Deckrect
20 Nov 2016, 17:49Oh! God! I hate lists! Every time i tried using lists, it ended in frustration.
My idea here is simple. I am creating a deck of cards the player has in inventory. Most of cards may repeat, because they represent edges and traits for the character and the number of times the player may use it.
Initially, i was thinking that every time a card is used, it flags (or adds a counter) somewhere, perhaps the player, to calculate if and how many of them are in game. Then, when its relevance ends, i had to set counters to zero or unflag things. I thought that a better way of doing this would be creating a "Tabletop" room. The "Use" script for every card moves it to this "Tabletop" room. If i want to check if a certain card is in play, i just need to check if it is in the room. However, when the cards relevance ends, the room must be empty.
Wait. Thinking now, i guess i cannot count how many cards of a given type are in the room, right? Then, perhaps i should step back and work with counters, right?
hegemonkhan
20 Nov 2016, 18:40"Wait. Thinking now, i guess i cannot count how many cards of a given type are in the room, right? Then, perhaps i should step back and work with counters, right? (deckrect)"
you can... but it's some code work... using lists again..., an example:
<object name="room_00">
<object name="katana">
<attr name="type_string_attribute" type="string">sword</attr>
</object>
<object name="claymore">
<attr name="type_string_attribute" type="string">sword</attr>
</object>
<object name="broad_sword">
<attr name="type_string_attribute" type="string">sword</attr>
</object>
<object name="rifle">
<attr name="type_string_attribute" type="string">gun</attr>
</object>
<object name="pistol">
<attr name="type_string_attribute" type="string">gun</attr>
</object>
</object>
// scripting:
foreach (object_variable, ScopeVisibleNotHeldForRoom (room_00)) {
if (object_variable.type_string_attribute = "sword") {
game.sword_count = game.sword_count + 1
} else if (object_variable.type_string_attribute = "gun") {
game.gun_count = game.gun_count + 1
}
}
// Sword count: 3
// Gun count: 2
you can instead, use Object Types and the 'DoesInherit (xxx)' Script/Function
Deckrect
20 Nov 2016, 18:50Ok. So, lets call "Room_00" now as "Tabletop". This is a Room Object.
May it then count how many cards names "Academics Card" are inside the room and return a value?
And when i need to empty the "Tabletop" room, may i simply get rid of any item inside? I heard there is no way to actually destroy an item. I am a little concerned, because i fear the game start counting items i make invisible. I could create a "Dump" room, to get rid of everything i dont wany anymore, but i fear it starts consuming computer processing.
hegemonkhan
20 Nov 2016, 19:12names must/shall be unique, as the 'name' String Attribute is the ID for quest. I have unique DNA, which identifies (ID) that I am me (and makes me as me). You have unique DNA which identifies (ID) that you are you (and makes you as you).
and thus, the 'clone' Script/Function will add numbers to the end of your Object's name, or whatever it does...
if you have some kind of naming system/convention, you can use the 'string manipulation' Functions, instead of giving your Objects a String Attribute or an Object Type:
http://docs.textadventures.co.uk/quest/functions/ (scroll down to the bottom, to the 'string functions' section)
<object name="room_00">
<object name="katana_sword">
</object>
<object name="claymore_sword">
</object>
<object name="broad_sword">
</object>
<object name="rifle_gun">
</object>
<object name="pistol_gun">
</object>
</object>
// scripting:
foreach (object_variable, ScopeVisibleNotHeldForRoom (room_00)) {
if (EndsWith (object_variable.name, "sword")) {
game.sword_count = game.sword_count + 1
} else if (EndsWith (object_variable.name, "gun")) {
game.gun_count = game.gun_count + 1
}
}
// Sword count: 3
// Gun count: 2
'destroy' does just that, destroys (if interested in learning about how practically all programming software and your computer is now protected, keeping your computer's resources/memory/RAM/Disk-Space safe, a google search on 'java garbage collection' or 'memory leak' or 'dangling pointer' will give you a quick insight into some aspects of this stuff), an example:
// the content within the '<asl>content</asl>', IS your game. the 'asl' is the main/root OBJECT of aslx/xml/html/quest
// if we 'destroy' the orc:
// from this:
<asl version="550">
<object name="room">
<object name="orc">
</object>
</object>
</asl>
// to this:
<asl version="550">
<object name="room">
</object>
</asl>
'remove' simply sets the Object's 'parent' Object Attribute to 'null' (it's not inside of another sub Object - it's directly a child of the main/root parent OBJECT: '' ), which does this, an example:
// the content within the '<asl>content</asl>', IS your game. the 'asl' is the main/root OBJECT of aslx/xml/html/quest
// if we 'remove' the orc:
// from this:
<asl version="550">
<object name="room">
<object name="orc">
</object>
</object>
</asl>
// to this:
<asl version="550">
<object name="room">
</object>
<object name="orc">
</object>
</asl>
Deckrect
20 Nov 2016, 19:20I am understanding this time better. There are things i never seen before. This 'Endswith' function works only with the name's ending? How it would behave on my Objects like "Influence Card" and "Academics Card"?
Deckrect
20 Nov 2016, 19:30Hahaha... I find problems at every step. As there may be many Cards of the same type in game and in the inventory, i have been cloning it during all process. I decided that when the player uses a card, it should then move to the "Tabletop" room. So, i added to the "On Use" of the Object, the script of "Move Object". What happens is that the game is not moving the card i click, but some other card, if any at all.
hegemonkhan
20 Nov 2016, 19:44I'm sure it simply does this:
(string comparison checking... should be a simple concept, I hope)
last character, does it match up with "d"
if yes, move onto:
2nd last character, does it match up with "r"
if yes, move onto:
3rd last character, does it match up with "a"
if yes, move onto:
4th last character, does it match up with "C"
etc etc etc
// ---------------
// example with an 'if' Script:
// player.alias = "HK"
// if (player.alias = "HK") {
// -> msg ("Yes, I am me, HK")
// } else {
// -> msg ("No, you're not me, you're not HK")
// }
// work it does (success example):
// if ("K" = "K") {
// if yes (true), then:
// if ("H" = "H") {
// if yes (true), then:
// TRUE -> msg ("yes, I am me, HK")
// else if the any of the checks failed:
// FALSE -> msg ("No, you're not me, you're not HK")
//
// work it does (failure example):
// player.alias = "Ed")
// if ("d" = "K") { // fail/false, quest is case sensitive, skip to 'FALSE -> ...'
// if yes (true), then:
// if ("E" = "H") {
// if yes (true), then:
// TRUE -> msg ("yes, I am me, HK")
// else if the any of the checks failed:
// FALSE -> msg ("No, you're not me, you're not HK")
not sure how well quest handles 'spaces/white space/the spacebar key' ... usually in/with programming you never want to use spaces (as it's not easy to program the parsing of spaces), people usually use the underscore '_' symbol for spaces or to use single camel case (intStrength) or double camel case (IntStrength), to help us humans with separating words. You can then use the built-in 'alias' String Attribute for outputing a name with spaces, for examples (using my descriptive naming/labeling convention/system, lol):
(good naming/labeling conventions/systems only really matter for really complex/advanced code/game designs)
<object name="playable_character_player_object">
<attr name="alias" type="string">playable character player object</attr>
</object>
<object name="playableCharacterPlayerObject">
<attr name="alias" type="string">playable character player object</attr>
</object>
<object name="PlayableCharacterPlayerObject">
<attr name="alias" type="string">playable character player object</attr>
</object>
hegemonkhan
20 Nov 2016, 19:50"How it would behave on my Objects like "Influence Card" and "Academics Card"? (Derelick)"
you'd use the 'StartsWith(xxx)' Function for that naming/labeling convention/system of yours
(or even a combination of both of them, lol. First check if it ends with 'Card' and if it does, then check what it starts with):
okay... it is indeed a card
okay... now what type of card is it...
okay... if it's this 'blah1' type of card... do blah1
okay... if it's this 'blah2' type of card... do blah 2
or...
okay... it's not a card... what to do now or do nothing?
"Hahaha... I find problems at every step (Deckrect --- did I finally not massare your name this time? argh, lol)"
this is called learning to code, hehe :D
welcome to the frustrating and slow process of learning to code :D
The Pixie
20 Nov 2016, 20:05Can the player only have one card active at a time? If so, instead of having a "tabletop" room, have an attribute on the player (call it "tabletop" if you like) that gets set to the card. Want to know what card is relevant? It is player.tabletyop
. When it stops being relevant, set player.tabletyop
to null.
The Pixie
20 Nov 2016, 20:06Hahaha... I find problems at every step. As there may be many Cards of the same type in game and in the inventory, i have been cloning it during all process. I decided that when the player uses a card, it should then move to the "Tabletop" room. So, i added to the "On Use" of the Object, the script of "Move Object". What happens is that the game is not moving the card i click, but some other card, if any at all.
This may be because you are using the name of the original in the "on use" script. Replace that with this
, which is a special value that refers to the object that the script belongs to.
Deckrect
20 Nov 2016, 20:09Hmmm... I see... I am understanding a little better about how Quest works and about programming. Really thank you for all the tips.
However, i guess my Cards system is not working and i cannot figure out why. Once again, i am getting frustrated with Quest! lol
I suppose i should step back once again and rethink the resolution system i want using. Perhaps something gone wrong when i started cloning cards and the game cannot identify the one i am referring to. Perhaps i should just use the more regular system of numbers, setting player's attributes as numbers i may compare during game. Perhaps i may find a way of preserving some of the character traits in another shape different from cards.
Anyway, thank you. I am sure there will be many other future problems to solve, no matter the core system i decide using to run this game.
hegemonkhan
20 Nov 2016, 20:11"May it then count how many cards names "Academics Card" are inside the room and return a value? (Deckrect)"
Functions can only return a single thing/value, so you can't directly return two things/values. Though if you just use Attributes you don't need to return, as the Attributes are immediately adjusted/set/re-set within the Function's scripting, as they're global VARIABLES. You can simple use the Attribute, and it'll have the new value from the Function's scripting. If you need to do returning with the Function, then a way around only being able to return a single thing, is to have that thing be something that can hold/contain multiple things within it (such as an Object, a List Attribute, or a Dictionary Attribute, and maybe a few more too).
Deckrect
20 Nov 2016, 20:20Oh, no! In the case of abandoning the "Cards Concept", i guess i will not need to count items inside a room.
The whole idea was the player would have a deck of cards in hand, to steer up story and actions. As i cannot solve this mechanics, i will then try using the far simple way of giving player INT attributes. Numbers will be easy to take into account.
What i am planning as an alternative mechanics then, is having just three basic attributes stored in the player object: Social, Mental and Physical. This will work with numbers and will be the very base to solve all the conflicts.
I am wondering if i may still configure some items in the game that will work as a sort of character traits. Perhaps, by using it, the character spends a narrative point stored as a fourth attribute and get a special effect or something. I don't know yet how i will deal with this. I must go back to the planning. It is a shame. I was quite ready to start building up the story itself, so all i had doing was finishing the character creation and the basic mechanics.
Here i go again!
hegemonkhan
20 Nov 2016, 20:28if you're working with clones... the only way to handle them that I know of is this, an example:
<object name="room">
<object name="sword">
</object>
<object name="axe">
</object>
</object>
// the clones 'name' will be something like this:
// sword2, sword3, etc etc etc
// axe2, axe3, etc etc etc
<![CDATA[[ // this is only for/when writing directly in-code (the GUI/Editor handles this for you), to tell quest that the '<' and '>' symbols are to be seen/recognized as 'greater than' and 'lesser than' operations and not as the aslx/xml/quest 'creation' tag line/block beginning and ending tags
foreach (object_variable, ScopeVisibleNotHeld (room)) {
if (StartsWith (object_variable.name, "sword") and object_variable.name > LengthOf ("sword")) { // the 'LengthOf' is to prevent the original Object from being included (it'll only use the clones)
game.sword_count = game.sword_count + 1
} else if (StartsWith (object_variable.name, "axe") and object_variable.name > LengthOf ("axe")) { // the 'LengthOf' is to prevent the original Object from being included (it'll only use the clones)
game.axe_count = game.axe_count + 1
}
]]>
try to keep your design as simple as possible / limited to what you can do and get to work correctly, so that you can implement it correctly, having it actually work for you.
trying to do a more complex design than you're capable of... leads to lots of issues...
there's an infinite number of different designs... all you should care about is using one that you can do successfully, lol.
Deckrect
20 Nov 2016, 20:37I confess i did it because i thought it would be simple. However, i got stuck on an unpredictable issue.
I am already working to check if i may downgrade the complexity of the game mechanics and reach a good result.
hegemonkhan
21 Nov 2016, 00:43we can help you with whatever... but we need very specific and detailed intruction/explanation/goals/desires/descriptions/etc of exactly what you want be it just some thing simple or a complex/advanced system, as well as being able to see your game code, to see what and how you've already tried to do, to better understand what you want, as seeing code is often more clear than trying to describe/explain what and how you want to do something in your game, in words.
Deckrect
21 Nov 2016, 13:47I see and i am really glad you and the people here are trying to help.
As i am doing things in layers, it is a little hard to place code here, because there is already a lot of text included. But i will try selecting larger portions of the code in order to show what is happening in the game.
Anyway, i decided changing the basic mechanics and making it far more simple. I still using the same basic logic of Objects. So, in this version, i am adding to the inventory a bunch of items which represents Traits instead of Cards. I am comfortable doing this for two reasons: i believe the game will not have much regular items and if i need to, i may always put in use Pixie's secondary inventory pane to store different types of Objects (named, Traits or Items)
So far i create three different attributes for the 'Object:player': Archetype, where the player selects what kind of character he/she will be playing, the Experience, dictating some of previous experience the character had and the Narrative, which represents the bunch of Narrative Points the character/player has. The first two are added to the Status attributes as strings and the last one as an Integer. In all cases, these selections adds Traits (which are objects) and more Narrative Points to the player.
Basically, i am creating a cross-over between a parser game and a game book. No big deal. We seen it a lot of times before. The only different stuff i want doing is that i will not use Exits to mimic choices. I plan using Objects for this purpose. it is the same as having and Object and on using it, the object performs the scripts to move the player to another room, where there are the results of the choices.
Why using Objects? For two reasons. The first is that by performing these scripts, i may add simple options that does not move the main story, but changes some circumstances. So i will not have many pages, just to add a few details. These details will be added to the current "page" (i.e. Room Object). The second reason is that in many game books, players has to guess what the author means with a given option and frequently the player is not informed about how the character will perform that action. By having Objects as choices, i may add the details inside the "Look at" description, without accumulating a lot of text to the main page. Player will inspects only what is desired.
So, here comes my first question. I plan placing the resolution of action to run as scripts for the "Use" button of the Objects which represents choices. Is there a way to group similar choices on the same Object without having to add commands to the game?
Ex: Object named "Enter the Locker Room". Buttons the Object has: "Look at", "Walk Inside" and "Sneak Inside". Is it possible (and simple) adding buttons to an Object and make it work in the same simplicity as the "Use" button?

Father
21 Nov 2016, 14:48Had you thought of creating an identical room with an identical description (minus objects) .
Then remove the exit to the original room, replace it with an exit to and from the new room.
Move the player to the new room( or wherever he/she is supposed to be. )
This would isolate all objects in the original room (and , in fact the room itself) from the game. You would
You could even delete the original room completely.
Deckrect
21 Nov 2016, 15:06I am understanding the concept, however i am not sure if i understand the use of the idea. may you elaborate a little more?
Oh! Nevermind! You are talking about how to destroy the room. It is a good idea, i think.
The Pixie
21 Nov 2016, 15:13So, here comes my first question. I plan placing the resolution of action to run as scripts for the "Use" button of the Objects which represents choices. Is there a way to group similar choices on the same Object without having to add commands to the game?
Ex: Object named "Enter the Locker Room". Buttons the Object has: "Look at", "Walk Inside" and "Sneak Inside". Is it possible (and simple) adding buttons to an Object and make it work in the same simplicity as the "Use" button?
Using verbs you can do exactly that. The second links describes how to make them display properly.
https://github.com/ThePix/quest/wiki/Using-Verbs
https://github.com/ThePix/quest/wiki/Using-Display-and-Inventory-Verbs-Successfully
Deckrect
21 Nov 2016, 15:21Of course i will need to read all the two links, but by doing a fast test, it seems to work perfectly well. Thank you, Pixie!