New here , have a few questions!

HolisticIllusion
08 Jun 2016, 20:26
Hello guys , i have been using Quest for a few days and i'm currently creating a text adventure survival game.

Everything is working great but here are some problems i came across :

1) How do i change the name/description of objects? For example i have an object that is a broken gun , i want the player to be able to fix it and change it's name to just "gun" and the description too.

2) How do flashlights work? I can't seem to make the light/dark system work.

3) Day and Night cycles? Do i use timers for this or do i need to get into scripting?

Your help is appreciated , thanks!

HegemonKhan
09 Jun 2016, 03:35
1. This involves learning the next major fundamental needed for taking your game beyond the basics of quest: learning Attribute and the 'if' Script usage. These two things, especially when used together, let's you do 90% of everything that you want to do in your game.

viewtopic.php?f=18&t=5559

A. naming/labeling:

usually people use the built-in 'alias' String Attribute for the name/label (as this is what people playing the game will see - it will over-ride the built-in quest ID 'name' String Attribute for the displayment during game play), leaving the built-in quest ID 'name' String Attribute for helping the game maker with organization and etc (for example... name: orc_1, alias: orc; name: orc_2, alias: orc; name: orc_99, alias: orc). You can also create/add a custom (your own) String Attribute too, for example, a 'first_name' String Attribute.

Attribute creation/manipulation can be done through scripting, which in the GUI~Editor is done this way, for an example of using a custom 'fix' Verb on a 'gun' Object:

'gun' Object (initial 'alias' String Attribute set'ted Value: "broken_gun") -> 'Verbs' Tab -> Add -> name: 'fix'

'fix' Verb -> run as script -> add new script -> 'variables' Category/Section -> 'set a variable or attribute' Script -> [EXPRESSION] -> (see below)

set variable gun.alias = [EXPRESSION] "repaired_gun"

we can make this a bit more functionally fancy, conceptually (in code):

if (not gun.alias = "repaired_gun") { gun.alias = "repaired_gun" }

what this is doing is checking the current Value of the 'gun.alias' (the 'alias' String Attribute of the 'gun' Object), if it is not already "repaired_gun" (if it is still "broken_gun"), then it'll be changed to being "repaired_gun". If it is already "repaired_gun", then there's no reason to be changing/setting it to being "repaired_gun".

here's how it'd be done in the GUI~Editor:

(instead of doing the above with the 'fix' Verb only having the 'set variable or attribute' Script, we'd do this stuff below)

'gun' Object (initial 'alias' String Attribute set'ted Value: "broken_gun") -> 'Verbs' Tab -> Add -> name: 'fix'

'fix' Verb -> run as script add new script -> 'scripts' Category/Section -> 'if' Script -> [EXPRESSION] -> (see below)

if [EXPRESSION] not gun.alias = "repaired_gun"

then,

-> add new script -> 'variables' Category/Section -> 'set a variable or attribute' Script -> [EXPRESSION] -> (see below)

set variable gun.alias = [EXPRESSION] "repaired_gun"

--

B. Descriptions:

(here's a link by Pixie that explains a method/way design of doing this stuff too: viewtopic.php?f=18&t=4807 )

the 'description' Attribute can either be a String Attribute (GUI~Editor: [message] option) or a (in code: 'msg' / GUI~Editor: 'print a message') Script Attribute (GUI~Editor: [run as script] option)

this is a bit more complex, as it involves more understanding of Attribute usage, in order to have a dynamic description design. The easiest method is to use the text processor commands:

http://docs.textadventures.co.uk/quest/ ... essor.html

for example:

'gun' Object -> ??? Tab -> 'description' -> [MESSAGE] -> You look at the {gun.alias}.

or, if the above doesn't work, you can do this too:

'gun' Object -> ??? Tab -> 'description' -> [run as script] -> add new script -> 'output' category/section -> 'print a message' Script -> [EXPRESSION] -> (see below)

print message [EXPRESSION] "You look at the {gun.alias}."

if you weren't to use the text processor commands, it'd then look like this:

print message [EXPRESSION] "You look at the " + gun.alias + "."

// the '[MESSAGE]' option means you're just using TEXT (this is why I'm not sure if you can use the text processor commands with it or not): "Hi, my name is HK."
// VARIABLE (usually using Attributes) usage allow for dynamic-ness, so without using VARIABLES, you got static-ness, as it'll always:
// output: Hi, my name is HK.

// the '[EXPRESSION]' option means that you're using VARIABLES (just VARIABLES or VARIABLES+TEXT): "Hi, my name is " + player.alias + "."
// player.alias = "HK"
// output: Hi, my name is HK.
// player.alias = "HollisticIllusion"
// output: Hi, my name is HollisticIllusion.

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

2. here's some links for you on how the 'dark-light' stuff works:

here's a guide on making a 'portable lantern (light source)' : viewtopic.php?f=18&t=4610

http://docs.textadventures.co.uk/quest/ ... kness.html (this is one of the important things to understand)
http://docs.textadventures.co.uk/quest/ ... tdark.html
http://docs.textadventures.co.uk/quest/ ... light.html
http://docs.textadventures.co.uk/quest/ ... ength.html (this is one of the important things to understand)
http://docs.textadventures.co.uk/quest/ ... ength.html (this is one of the important things to understand)

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

3. Timers (using real/clock time) are a bit messy... you may want to create a 'turns/hrs/mins/secs' system instead (though this isn't trivial either - Pixie has a very good/advanced time/date library that you can use), but aside from this system of determining when it is day vs night, the simpliest means of doing the actual toggling between day and night, would be to use a Boolean Attribute, for example:

'game' Game Object -> 'Attributes' Tab -> Attributes (the top box I think - or maybe it's the bottom box, meh) -> Add -> (see below)

(Object Name: game)
Attribute Name: is_night
Attribute Type: boolean
Attribute Value: (false ~ if you want your game to start during the day, or: true ~ if you want your game to start during the night)

in code: game.is_night = false // or: game.is_night = true

which you can then manipulate (change/toggle between true and false) and use for 'if' Script checking

The Pixie
09 Jun 2016, 07:22
Are you using the online editor or offline?
HolisticIllusion wrote:1) How do i change the name/description of objects? For example i have an object that is a broken gun , i want the player to be able to fix it and change it's name to just "gun" and the description too.

As HK says, change the alias attribute, and it is also worth changing the description attribute too.

2) How do flashlights work? I can't seem to make the light/dark system work.


See here:
viewtopic.php?f=18&t=5571

3) Day and Night cycles? Do i use timers for this or do i need to get into scripting?


Do you want time to pass in real time (i.e., day can become night after a certain amount of time playing)? Or after a set number of turns? Use timers for the former or a turn script for the latter (the latter is probably better for the player and easier, as HK says timers are messy).

If you go for a turnscript, try this:
if (not HasBoolean(game, "is_night")) {
game.is_night = false
game.turn_count = 0
}
game.turn_count = game.turn_count + 1
if (game.turn_count % 30 = 0) {
game.is_night = not game.is_night
}

Check game.is_night to see if it is night (but not on the first turn, as it will not be set up yet).

HolisticIllusion
09 Jun 2016, 13:10
Thank you very much , the methods are working well i only seem to be having trouble with the description.

If i understood correctly , by using this expression : "You look at the {gun.alias}." in the object description , it would be translated to "You look at the gun (whatever the alias is right now)".

When i use it the game returns You look at the {gun.alias}.

I am using the online editor if that's the problem.

EDIT : my mistake i was using an incorrect alias.

HegemonKhan
09 Jun 2016, 16:59
if the problem isn't fixed... you may need to surround it in double quotes:

"You look at the {gun.alias}."

or, you may need to change the [message] option to the [expression] option, and type in this (it's the same as the above line):

"You look at the {gun.alias}."

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

Note: I learned how to do VARIABLES the "normal (more confusing, lol)" way, I don't use the much more simple and non-confusing text processor commands much, so that's why I'm using the "normal" way and not text processor commands, below

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

hopefully, you understand basic Algebra, algebraic substitution, using variables:

x = 10 // the Variable and its Value (a simple Expression: 10)
y = x + 5 // the Variable and its Value (a complex Expression: x + 5)
// y = (10) + 5 = 15

well, that's the exact same thing as is done with programming/coding/quest, except we can use any string for our VARIABLE name and work with strings/text for the expressions, as well as using numeric amounts/values:

Variables:

Variable_name = Value

Variable_name: x
Variable Value: 10

x = 10 // the Variable and its Value (a simple Expression: = 10)
msg ("The value is " + x + ".") // think of the 'msg' key-word/key-command as like the 'y' Variable (except it's doing an action, as it's a key-command/Script/Function), and the content inside of the parenthesis is its Value (a complex expression: "The value is " + x + ".")
// output: The value is 10.

// if we change the value of x from 10 to 5, then the output is: The value is 5.

value = 10
msg ("The value is " + value + ".")
// output: The value is 10.

abc_def = 50
msg ("The value is " + abc_def + ".")
// output: The value is 50.

m = 21
msg ("The value is " + m + ".")
// output: The value is 21.

------

now programming has Attribute VARIABLES too:

Object_name.Attribute_name = Value

Object_name: game
Attribute_name: x
Attribute Value: 10

game.x = 10
msg ("The value is " + game.x + ".")
// output: The value is 10.

player.strength = 100

player.alias = "john smith"

HK.intelligence = 0

orc.dead = false
orc.dead = true

player.flying = false
player.flying = true

<object name="sword">
</object>
player.right_hand = sword

game.greeting = "Hi, welcome to my game, I hope you don't die, as dying in the game, will kill you in real life, good luck, you'll need it, muwhaha!"

HK.favorite_color = "black"

HK.favorite_color_list = split ("black;red", ";")

game.conditions_list = split ("normal;poisoned; stunned; asleep; dead; unconscious; paralyzed; petrified; silenced", ";")

player.conditions_list = split ("normal", ";") // player's condition(s): normal
list remove (player.conditions_list, "normal") // player's condition(s): null (none/blank)
list add (player.conditions_list, "poisoned") // player's condition(s): poisoned
list add (player.conditions_list, "paralyzed") // player's condition(s): poisoned and paralyzed

Attributes are held/contained by/in Objects, so, so long as the Object exists/still exists, you can use an Attribute anywhere, it is 'global'

whereas just a Variable VARIABLE, is only stored/saved for that specific Script location in the game that it is within, once the Script is finished, the Variable is erased ~ it is NOT preserved, so you can't use that Variable elsewhere in your game ~ you'll get an error as the Variable doesn't exist (as it was erased), it is 'local'. This is the difference between Variable VARIABLES and Attribute VARIABLES.

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

'if' Scripting (conditionals) examples:

if (x = 10) {
msg ("The value is " + x + ".")
} else if (x > 10) {
msg ("The value is " + x + ". This is greater than 10.")
} else if (x < 10) {
msg ("The value is " + x + ". This is lesser than 10.")
}

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

msg ("What is your name?")
get input {
if (result = "HK") {
msg ("Ah, so your name is HK, this is so cool, I'm such a huge fan of yours!")
} else {
msg ("Oh, so your name is " + result + ". I don't know who you are, but it is nice to meet you.")
}
}

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

<object name="room">
</object>

<object name="player">
<attr name="parent" type="object">room</attr>
<attr name="alias" type="string">HK</attr>
<attr name="damage" type="int">100</attr>
<attr name="current_life" type="int">999</attr>
</object>

<object name="monster">
<attr name="parent" type="object">room</attr>
<attr name="alias" type="string">orc</attr>
<attr name="dead" type="boolean">false</attr>
<attr name="damage" type="int">50</attr>
<attr name="current_life" type="int">500</attr>
<attr name="fight" type="script">
fight_function
</attr>
</object>

<verb>
<property>fight</property>
<pattern>fight</pattern>
<defaultexpression>You can't fight that!</defaultexpression>
</verb>

<function name="fight_function">
if (monster.dead) {
msg ("The " + monster.alias + " is already dead, silly.")
} else {
monster.current_life = monster.current_life - player.damage
msg ("You attack the " + monster.alias + ", doing " + player.damage + " damage to it, leaving it with only " + monster.current_life + " life left.")
if (monster.current_life <= 0) {
monster.dead = true
msg ("You've not only damaged the " + monster.alias + ", but you've killed it.")
} else {
player.current_life = player.current_life - monster.damage
msg ("The " + monster.alias + " attacks you, doing " + monster.damage + " damage to you, leaving you with only " + player.current_life + " life left.")
if (player.current_life <= 0) {
msg ("The " + monster.alias + " has killed you.")
msg ("GAME OVER")
finish
}
}
}
</function>


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

quest's structure:

VARIABLES (3 Types):
-> Variables: some examples: result = "HK", handled = false, you_go_first = true, x = 10, y = "yes"
-> Attributes: some examples: game.state = 0, player.alias = "HK", orc.dead = false, game.x = 10, player.y = "yes", game.handled = true, game.you_go_first = false
-> Parameters: these are for Functions/Commands/etc