some beginner questions

Hello, im learning to use it from 2 days, my english is not perfect, especially in computer language, so i tried to understand it alone on a "trial and error method". I use game adventure, text looked to complicated and i wanted to have some pictures. Anyway, thats my questions do i making right the follows:

  • for example, i want to have a sword. So i create flag on "sword" with new link "take the sword". Since that i posses sword until flag sword will be off. So i use scripts IF flag sword on i kill the beast or IF flag sword off i run. Is it correct?
  • for the same think as above i use counters, for exaple if counter power is 1 i can climb the mountain. if 2 higher etc.
  • than i tried add some currency with that counter but it doesnt look good. I created counter money and setting its value with scripts for example when collecting 5 money i set that value to 5. Problem is when i try to show how much money i have in any situation: {if countername=value:text} - ok but i need to enter that value at anytime - is there any possibility that counter can show exact value of money on its own?
    Thats all what i menaged to learn myself.
  • i dont understand at all that variables (set a variable or atrribute), how to using expression (and what it is?), functions? (dont know anything)
    Can u please explain me how to use it in some very simple examples? Thank u very much in advance

Best advice I can give:

  1. Go through the tutorial completely.
  2. Start small. The stuff you are asking about is a bit more advanced.
  3. Make a bunch of small games and just mess around with simple things first. You’ll be surprised how quickly you’ll catch on.

And, what is your native language?


Thank u XanMag.

1.Of course i tried to understands tutorials. But there are 2 problems: its mostly about text adventure not gamebook, my knowledge about scripts and computer language egual zero. I wouldnt understand it even in my native language (its polish). All what i learned is from examples.

  1. Yes i started it with very small things to understand mechanics
  2. Yes i think i catched some things. Just tell me is it right direction what i wrote? That things about sword, flags, counters? Is it ok how i used it? Maybe u can give me some very simple examples of how that expression work? Any other simple things? Yes u right, functions can be to much complicated for the start.

Maybe one simple story...how would u add currency to the game?


Welcome:
First off... go with text adventure, it is not any harder than gamebook, and you get MANY more tools to use.
Text adventure can do everything gamebook can do, AND LOTS more.
Money: there is a check box that enables it.
First, a few terms:
One the left side of the screen (Quest window) is the tree of objects.
Select game.
On the tab "Features", check Money.

On the tab "Player", there is a "Format for money" and a long box.
In the box is how you format the money.
Try this
! gold
Now your money is counted in gold coins.
Want dollars?
$!
The "!" will be replaced by the amount of money you have...
Like:
25 gold
or
$25.


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


Data Types:

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


Amount Data Types:

able to do arithmetic/math (addition, subtraction, multiplication, division, modulus) on them

integers (int): ..., -999, -1, 0, 1, 999, ...

doubles: ..., -999.123, -1.00004, 0.0, 5.9983, 999.123987, ...


Non-Amount Data Types:

not able to do arithmetic/math on them

strings:

"a"
"abc"
"1"
"123"
"abc123"
"abc_123"
"hi, my name is HK, what is your name?"

booleans:

true
false

object memory address/location references/pointers:

(ignoring these for now)

lists:

(ignoring these for now)

dictionaries:

(ignoring these for now)

scripts:

(will get into these further down)


VARIABLES (3 types):

these are sub-containers, able to store/hold values (and the 'Script' VARIABLE: actions/scripting)

  1. Attributes: stored/held by/within a container, so they're global and permanent (so long as the container exists / still exists)
  2. Variables: not stored/held by/within a container, so they're local and temporary, only
  3. Parameters: VARIABLES specifically for Functions and Commands

examples (in-code):

Attributes:

// the 'player' is an existing 'Object' Element

player.strength = 100
player.alias = "HegemonKhan"
player.dead = false

Variables:

strength = 100
alias = "HegemonKhan"
dead = false

Parameters:

(ignoring these for now)


CONTAINERS:

these are known as the "Elements" in quest: http://docs.textadventures.co.uk/quest/elements/

Elements: Objects, Verbs, Functions, Commands, Timers, Turnscripts, Exits, etc

the 'Elements' are your main "physical things" in quest

being containers, they can hold/store data (Attributes) and/or actions (direct scripting or Script Attributes)

also, VARIABLES are a type of sub-container as well (they do hold/store values): http://docs.textadventures.co.uk/quest/types/


for the Text Adventure:


in the GUI/Editor:

to add/create an 'Object' Element, there's many menu bar options, drop downs, right clicking, and etc methods of doing so (see tutorial) -> Name: NAME_OF_YOUR_OBJECT

add Object -> Name: ball // creates/adds a 'ball' Object to the game
add Object -> Name: npc // creates/adds a 'npc' Object to the game

to add/create Attributes and set their initial values, within an Object:

'ball' Object -> 'Attributes' Tab -> Attributes Box (at the bottom) -> Add -> (see below, repeat as needed)

(Object name: ball)
Attribute Name: color
Attribute Type: string
Attribute Value: red

(Object name: ball)
Attribute Name: quantity
Attribute Type: int
Attribute Value: 1

(Object name: ball)
Attribute Name: inflated
Attribute Type: boolean
Attribute Value: true


or, in the GUI/Editor's scripting:

'WHATEVER' scripting Element -> add new script -> 'objects' (I think) category/section -> 'create/add object' (or something like this) Script -> Name: NAME_OF_YOUR_OBJECT

to add/create Attributes and set their initial values, within an Object:

'WHATEVER' scripting Element -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable VARIABLE = [EXPRESSION] VALUE_OR_EXPRESSION

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
set variable NAME_OF_Variable = [EXPRESSION] VALUE_OR_EXPRESSION

set variable ball.color = [EXPRESSION] "red"
set variable ball.quantity = [EXPRESSION] 1
set variable ball.inflated = [EXPRESSION] true


or, directly in-code scripting:

to add/create an 'Object' Element:

create ("NAME_OF_YOUR_OBJECT")

create ("ball") // creates/adds a 'ball' Object to the game
create ("npc") // creates/adds a 'npc' Object to the game

to add/create Attributes and set their initial values, within an Object:

VARIABLE = VALUE_OR_EXPRESSION

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION
NAME_OF_Variable = VALUE_OR_EXPRESSION

ball.color = "red"
ball.quantity = 1
ball.inflated = true


Scripting:


Programming Scripting:

the Assignment Operator/Operation:

VARIABLE = FINAL_VALUE

the 'FINAL_VALUE' on the right side of the '=' symbol is STORED INTO the 'VARIABLE' on the left side of the '=' symbol

you can't reverse the expression like you can in math (as it's just not programmed to understand/parse it in reverse):

// math is actually doing a comparison operation: "equal to", such as with Algebra, so that's why it's okay to reverse it in math, but NOT in programming's Assignment operation, unless you're doing a Comparison operation: if (CONDITIONAL_EXPRESSION):

Assignment operations:

x = 10 // NO error
10 = x // ERROR!

player.strength = 10 // NO error
10 = player.strength // ERROR!

Comparison Operations:

if (x = 10) { /* scripting */ } // NO error
if (10 = x) { /* scripting */ } // NO error

if (player.strength = 10) { /* scripting */ } // NO error
if (10 = player.strength) { /* scripting */ } // NO error

examples:

player.strength = 0

the '0' final value is stored into the 'strength' Integer Attribute of the 'player' Player Object

player.strength = 5 + 12

the '17' final value is stored into the 'strength' Integer Attribute of the 'player' Player Object

game.introduction = "Welcome" + " " + "to" + " " + "my game" + ", I hope your enjoy it!"

the 'Welcome to my game, I hope you enjoy it!' final value is stored into the 'introduction' String Attribute of the 'game' special and required Game Settings and Publishing Info Object


Arithmetic Scripting:

in the GUI/Editor's scripting:

'WHATEVER' scripting Element -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

simple examples:

Addition:

set variable player.strength = [EXPRESSION] player.strength + 5

Subtraction:

set variable player.strength = [EXPRESSION] player.strength - 7

Multiplication:

set variable player.strength = [EXPRESSION] player.strength * 3

Division:

set variable player.strength = [EXPRESSION] player.strength / 2

Modulus (division, but it gets/finds/returns the REMAINDER: cyclic usage, and factors/divisibility of numbers, which includes number being 'odd' or 'even'):

// Modulus' cyclic usage examples:

set variable time.civilian_clock_hours = [EXPRESSION] time.hours % 12 // time.civilian_clock_hours = [0 to 11]
set variable time.military_clock_hours = [EXPRESSION] time.hours % 24 // time.military_clock_hours = [0 to 23]

set variable time.clock_minutes = [EXPRESSION] time.minutes % 60 // time.clock_minutes = [0 to 59]
set variable time.clock_seconds = [EXPRESSION] time.seconds % 60 // time.clock_seconds = [0 to 59]

// Modulus' factors/divisibility (including odd/even of a number) example:

number = GetRandomInt (0,100) // number = [randomly selects a number in this inclusive range: 0 to 100]

if (number % 2 = 0) {
  msg ("The number (" +number + ") is an even number")
} else if (number % 2 = 1) {
  msg ("The number (" +number + ") is an odd number")
}

// only checking for prime number divisibilty/factors for example below to avoid having to handle with logic issues with the coding (too lazy to deal with it, lol):
// (challenge: can you understand why there's logic issues to handle with the coding if I was checking also for non-prime numbers?)
if (number % 2 = 0) {
  msg ("The number (" +number + ") is divisible by 2, or to say it differently, 2 is a factor of the number (" + number + ")" )
} else if (number % 3 = 0) {
  msg ("The number (" +number + ") is divisible by 3, or to say it differently, 3 is a factor of the number (" + number + ")" )
} else if (number % 5 = 0) {
  msg ("The number (" +number + ") is divisible by 5, or to say it differently, 5 is a factor of the number (" + number + ")" )
} else if (number % 7 = 0) {
  msg ("The number (" +number + ") is divisible by 7, or to say it differently, 7 is a factor of the number (" + number + ")" )
} else if (number % 11 = 0) {
  msg ("The number (" +number + ") is divisible by 11, or to say it differently, 11 is a factor of the number (" + number + ")" )
} else if (number % 13 = 0) {
  msg ("The number (" +number + ") is divisible by 13, or to say it differently, 13 is a factor of the number (" + number + ")" )
}
// etc 'else ifs' to infinity

complex expression example (using a Data/Attribute Type that I didn't explain in this post, so if don't understand the below example, don't worry about it):

create ("katana")
set variable katana.damage = [EXPRESSION] 50

create ("dagger")
set variable dagger.damage = [EXPRESSION] 25

--------

set variable player.strength = [EXPRESSION] 100
set variable player.weapon = [EXPRESSION] katana
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [100] / 100
// player.damage = 100

--------

set variable player.strength = [EXPRESSION] 75
set variable player.weapon = [EXPRESSION] katana
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [75] / 100
// player.damage = ~ 88

----------

set variable player.strength = [EXPRESSION] 100
set variable player.weapon = [EXPRESSION] dagger
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [25] + [25] * [100] / 100
// player.damage = ~ 50

---------

set variable player.strength = [EXPRESSION] 50
set variable player.weapon = [EXPRESSION] dagger
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [25] + [25] * [50] / 100
// player.damage = ~ 37

the 'if' Script:

in the GUI/Editor scripting:

'WHATEVER' scripting Element -> add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] CONDITIONAL_EXPRESSION


// Boolean examples for the conditional expression:

if [EXPRESSION] ball.inflated // if (TRUE) // if (ball.inflated = true)

-> then -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "You play with your friend, kicking the ball back and forth"

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "After kicking the ball so much, it has lost too much air, and has become deflated (flat), so let's actually make it deflated, see below"

-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable ball.inflated = [EXPRESSION] false

else // if (FALSE) // if (ball.inflated = false)

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Your ball is deflated (flat), you need to pump it back up with air, so it's inflated again, before you can play with it, kicking it back and forth, with your friend"

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "So, let'sinflate the ball (pump up the ball with air), see below"

-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable ball.inflated = [EXPRESSION] true


more examples for the 'if' Script (tired/lazy now, so just showing these examples in-code, hopefully you can understand them and match it up with doing it in the GUI/Editor):

string_variable = "dragon"

if (string_variable = "dragon")
  msg ("TRUE")
} else {
  msg ("FALSE")
}

// result/output: TRUE

---------

// quest is upper-lower case sensitive

string_variable = "dragoN"

if (string_variable = "dragon")
  msg ("TRUE")
} else {
  msg ("FALSE")
}

// result/output: FALSE

---------

// quest is upper-lower case sensitive

string_variable = "dragon"

if (string_variable = "dragoN")
  msg ("TRUE")
} else {
  msg ("FALSE")
}

// result/output: FALSE

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

integer_variable = GetRandomInt (0,2)

if (integer_variable = 0)
  msg ("zero")
} else if (integer_variable = 1) {
  msg ("one")
} else if (integer_variable = 2) {
  msg ("two")
}

// result/output: [depends on the random selection of the 'GetRandomInt' Function, which randomly selects a number in the inclusive range: 0 to 2, which will through the 'if' block, output/display its matched up result: zero, one, or two]

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

// high to low checking:

if (test.score >= 90) {
  test.grade = "A"
} else if (test.score >= 80) {
  test.grade = "B"
} else if (test.score >= 70) {
  test.grade = "C"
} else if (test.score >= 60) {
  test.grade = "D"
}  else {
  test.grade = "F"
}

// same as above, but a bit more efficient:

if (test.score > 89) {
  test.grade = "A"
} else if (test.score > 79) {
  test.grade = "B"
} else if (test.score > 69) {
  test.grade = "C"
} else if (test.score > 59) {
  test.grade = "D"
}  else {
  test.grade = "F"
}

// low to high checking:

if (test.score < 60) {
  test.grade = "F"
} else if (test.score < 70) {
  test.grade = "D"
} else if (test.score < 80) {
  test.grade = "C"
} else if (test.score < 90) {
  test.grade = "B"
}  else {
  test.grade = "A"
}

Thank u all for u effort to help, but i didnt understand a word. I think it all applies to text adventure, in gamebook it looks diffrent and doesnt explain me anything i asked. Also noone answered to any of my question.

Thanks anyway, regards


I hope you're still here. You cannot make flags or attributes or variables on gamebooks, except for the player and the game. Maybe the pages too, but don't quote me on that. The gamebooks work like standard gamebooks: you write a story, you make a set of choices for the player to choose, the player picks the page link, and so on.

Here's a description of the book forms of gamebooks:
"A gamebook is a work of printed fiction that allows the reader to participate in the story by making choices. The narrative branches along various paths, typically through the use of numbered paragraphs or pages. Gamebooks are sometimes called choose your own adventure books or CYOA after the influential Choose Your Own Adventure series originally published by US company Bantam Books."
-Wikipedia

So the game forms of it are extremely similar, except it's a game. The game book setting is not what you want for making attributes and objects and complicated scripts. You will most likely need to start over, and choose the text adventure format next time.


  • for example, i want to have a sword. So i create flag on "sword" with new link "take the sword". Since that i posses sword until flag sword will be off. So i use scripts IF flag sword on i kill the beast or IF flag sword off i run. Is it correct?

It looks like you understand that well enough.

  • Problem is when i try to show how much money i have in any situation: {if countername=value:text} - ok but i need to enter that value at anytime - is there any possibility that counter can show exact value of money on its own?

To display the value of a counter in a 'text' page (not within a script), you use the text processor directives {counter:countername} or {=game.countername}.

  • i dont understand at all that variables (set a variable or atrribute), how to using expression (and what it is?), functions? (dont know anything)

You probably don't need to use variables, attributes, and functions unless you are doing complex scripting.

It seems that you already understand flags and counters. Flags and counters are a simplified form of attributes, designed for use with gamebooks. For example, a flag named "sword" is actually an attribute called game.sword. And a counter called "money" is actually an attribute game.money.

If you have some problem you can't solve just using flags and counters, then let us know what that problem is. Then someone can show you how to do it.


Hello, sorry i wasnt here a while :)
jmnevil54 - yes, thats the definition of game i want play (gamebook), thank you :)
mrangel - yes, that was help what i really expected, thank you for it very much. That script {counter:countername} was exactly what i needed and asked for, i didnt find it at tutorial (but i admit i could missed it in that huge book).
Yes i have 1 problem, but not sure should i ask here or make other topic, but i try:

  • i have problems with connecting text scripts:
    {if not sword: here is my text nr 1} {if sword:here is my text nr 2} - thats clear, sword is my flag
    and...problem is how to connect it with scripts such as {once:text}, {random:text 1:text 2:text 3}, {notfirst:text}
    I just mean (really sorry for my poor english) is it at all possible?
    what i want is "if sword random text is....if not sword random text is...." or if sword not first text is...if not sword not first text is..." i really tried to connect it in many ways using { and } in many directions but game didnt understand it.
    Very sorry i know it must very hard to understand what im writing but maybe someone understanded what i meant :) best regards, and its really fun and great application :)

{if not sword: here is my text nr 1} {if sword:here is my text nr 2} - thats clear, sword is my flag

It's more efficient to use either in that case. Like:
{either game.sword:This text will appear if you have a sword:This text will appear if you don't have a sword}.

({if has some special behaviours, like letting you miss out the game. before a flag or counter name. But the way this is done introduces some other problems. When you find that an {if gives strange errors, try using {either instead.)

"if sword random text is....if not sword random text is...."

You mean if the player has a sword it will randomly show text A or text B, but if they don't have a sword it will show text C or text D?

{either game.sword:{random:text A:text B}:{random:text C:text D}}


i need some time to practice what u wrote but...are u sure u talking about gamebook not text adventure? How u can exchange command IF for EITHER on gamebook? I think either means something other than if

Well not exactly, i meant in some specific locations if sword(flag) is on random text is {random:eee:beeee:veeee} and if not sword (flag) random text is {random:aaaa:uuuuu:kaaaaa}


are u sure u talking about gamebook not text adventure?

Yes. I checked the source.

How u can exchange command IF for EITHER on gamebook?

You type {either instead of {if.

I think either means something other than if

{either is an {if and an {if not put together.

For example:
{either game.aaaa:bbbb} is the same as {if aaaa:bbbb}.

{either game.aaaa:bbbb:cccc} is the same as {if aaaa:bbbb}{if not aaaa:cccc}

I prefer to use either, because {if sometimes does odd things you don't expect.

Well not exactly, i meant in some specific locations if sword(flag) is on random text is {random:eee:beeee:veeee} and if not sword (flag) random text is {random:aaaa:uuuuu:kaaaaa}

{either game.sword:{random:eee:beeee:veeee}:{random:aaaa:uuuuu:kaaaaa}} should work.


Thanks again mrangel for u time. That doesnt work for me with that either, and what is "game" in u instruction? I suppose sword is flag. But with further trying i discover such connection myself what works:

{if sword:{random:text 1:text 2:text 3}} {if not sword:{random:text 4:text 5:text 6}}

i still cant connect that "if sword and if not sword" with things like {notfirst:text} or {once:text}


game is the game element. It's a special element in Quest. game.sword is a flag named "sword".

It tells Quest where to find a particular piece of data. In a text adventure, the part before the dot could be a room, an NPC, an object, or the player.
In gamebooks it's simpler. You don't have any other objects to worry about, so the part before the dot is always game. Some instructions ({if and {counter) automatically add the game. so you don't need to include it.


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

Support

Forums