Setting game difficulty, restarting function etc

kadan007
Howdy folks, thanks for a wonderful program. I'm still a noobie and suck at programming but i'm having fun creating my own games using the GUI. i'm busy working on 3 at the moment. One has potential and would like some help please. I definetly do not want any of my games coming out before they are ready. So without further ado, here are 3 of my main challenges at the moment.

Firstly, how do i get the player to either click on a restart hyperlink or type "restart" and it will take them to the start again or must they use ctrl+R at the end of a game. Same with exiting.

The next i want to know how to enable and disable hyperlinks if a player chooses "beginner" or "expert" in the beginning of my game e.g ive created a new string called gamedif with the 2 choices above and menu text "Game difficulty?" Then if a player chooses "beginner" then hyperlinks must be enabled else not.

Lastly, if a player drinks some water from a water bottle which has a weight of 1000 grams, how would i decrease it by say 50 grams everytime he takes a sip.

I know these seem fairly simple and yes i have gone through all the tutorials but i cant seem to figure this out.

Please help and thanks again.

HegemonKhan
for your 3rd question:

these two 'Super' Scripts, will allow you to do like 90% of anything~everything that you want to do in your game

1. the 'if' Script:

run as script -> add a script -> scripts -> if -> [EXPRESSION] -> (see below)

2. the 'set a variable or attribute' Script:

run as script -> add a script -> variables -> set a variable or attribute -> (see below)

we're going to use some coding~programming, but don't worry, it's hopefully pretty easy and simplistic for you:

Object_name.Attribute_name = Value_or_Expression

examples (using my own labeling method for them):

1) hk.strength_integer = 100 // (value)
2) hk.damage_integer = hk.weapon_damage_integer + hk.weapon_damage_integer * (hk.strength_integer - orc.endurance_integer) / 100 // (expression)
3) orc.dead_boolean = false // (value)
4) hk.favorite_color_string = "black" // (value)
5) hk.favorite_colors_stringlist = split ("black;red", ";") // (expression)

but you can just do this labeling method for yourself (for an example):

1) hk.strength = 100
2) hk.damage = hk.weapondamage + hk.weapondamage * (hk.strength - orc.endurance) / 100
3) orc.dead = false
4) hk.favoritecolor = "black"
5) hk.favoritecolors = split ("black;red", ";")

or, whatever labeling method you want for your Object's Name and Attribute's Name, but the syntax~structure~pattern~format must be the same, as this is how you 'talk' to quest~computer.

-----------

so...

for the 'set a variable or attribute' Script, an example:

the equal sign is already there by quest's GUI, so you just would write in the stuff to the left and right of the equal sign

left of equal sign: hk.strength
right of equal sign: 100

run as script -> add a script -> variables -> set a variable or attribute -> hk.strength = 100

the 'if' Script, an example:

Object: orc
Verb: fight
'fight' Verb's Scripting: (see below)

run as script -> add a script -> scripts -> if -> [EXPRESSION] -> orc.dead = true
-> then -> add a script -> output -> print a message -> [MESSAGE] -> The orc is already dead, silly.
else if -> add a script -> scripts -> if -> [EXPRESSION] -> orc.dead = false
-> then -> add a script -> variables -> set a variable or attribute -> orc.dead_boolean = true // this is the same as the GUI~Editor's 'SetObjectFlagOn' Script
-> add a script -> output -> print a message -> [MESSAGE] -> You attack the orc, killing it.

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

about the boolean~(flag) Attribute Type:

GUI~Editor:

'orc' (Object) -> Attributes (Tab) -> Attributes -> Add ->

// this initially sets~creates the boolean attribute, via the GUI~Editor's tab, instead of doing it via~in~by the GUI~Editor's scripting. (you can initially set~create the boolean attributes either way you want).

(Object: orc)
Attribute Name: dead
Attribute Type: boolean
Attribute Value: false
// conceptually: we're (initially) setting the orc as being 'alive'

in-code // using GUI~Editor:

// conceptually, we're either (initially) setting or re-setting the 'orc' as either 'dead (orc.dead=true)' or 'alive (orc.dead=false)'

// to initially set~create the boolean attribute via GUI~Editor's scripting, we can't use the 'SetObjectFlagOn~Off' as this just changes an already setted~created boolean attribute, we have to use the 'set a variable or attribute' to initially set~create the boolean attribute

orc.dead = false // run a script -> add a script -> Objects -> SetObjectFlagOff // or: run a script -> add a script -> variables -> set a variable or attribute -> orc.dead = false

orc.dead = true // run a script -> add a script -> Objects -> SetObjectFlagOn // or: run a script -> add a script -> variables -> set a variable or attribute -> orc.dead = true

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

as for the basic computational scripting of integer (non-decimal numbers) or double~float~floating point (decimal numbers):

run as script -> add a script -> variables -> set a variable or attribute -> (see below)

Addition:

example: hk.strength_integer = hk.strength_integer + 50

Subtraction:

example: hk.strength_integer = hk.strength_integer - 30

Multiplication:

example: hk.strength_integer = hk.strength_integer * 2

Division:

example: hk.strength_integer = hk.strength_integer / 3

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

conceptually, how they work:

Initial (old): hk.strength = 10
hk.strength (new) = hk.strength (old) + 50
hk.strength (new) = 10 + 50 = 60
new: hk.strength = 60
old: hk.strength = 60
hk.strength (new) = hk.strength (old) + 50
hk.strength (new) = 60 + 50 = 110
new: hk.strength = 110
etc etc etc

and you can make it more complex too:

hk.weapon_damage = 50
hk.strength = 100

hk.damage = hk.weapon_damage + hk.weapon_damage * (hk.strength / 100)

hk.damage = 50 + 50 * (100 / 100) = 100

jaynabonne
Taking your three questions in turn:

1) Quest games run in a form of web browser (even in the desktop version), so you can leverage that to reload using JavaScript. This will reload the game (tested on the desktop player, but should work - in theory - in the web one as well)

JS.eval ("location.reload();")

If you want to add it using the editor, select the "Run Javascript" script and put eval ("location.reload();") as the parameter.

2) Hyperlinks are controlled by the game attribute "enablehyperlinks". Setting it to true shows hyperlinks for subsequent commands. Setting it to false disables showing hyperlinks for subsequent commands.

3) As far as the emptying water bottle, you don't say how you want the player to be aware of the amount left. I'll assume the approach that it shows you the amount left when you look at it.

First, let's assume you have a "waterbottle" object. Create an integer attribute on it called "quantity" and default it to 1000. (Click on the waterbottle object and go to the "Attributes" tab and add it there.)

Second, set the "look at" description for the waterbottle to "The water bottle has {waterbottle.quantity} grams of water left."

Third, whenever they sip, subtract 50 from the waterbottle quantity attribute:

waterbottle.quantity = waterbottle.quantity - 50

In the editor, choose "Set a variable or attribute" under the "Variables" section, and set it to:

Set variable [waterbottle.quantity] to [expression] [waterbottle.quantity-50]

Hope that helps!

kadan007
Thanks so much guys for your quick responses. i will have a look at this more closely and get back to you. At this stage it seems a little to complex for me but i like a challenge.

kadan007
Ok so ive managed to get the waterbottle quantity sorted out now but im still struggling with the other 2.

When i use the javascript you gave me for restarting game it restarts but then does not continue from there.

Also i cant get the hyperlinks to enable or disable. Can you please show me in the GUI how i would do this? In code it says something about <enablehyperlinks> type boolean = true but when i paste it or move it to the code where i want it, it does not work.

please and thank you

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

Support

Forums