random messages

InfectedBehaviour
Hi I'm new to Quest. Been working on a game for almost two months now.

I've already gotten some random messages to appear in my game but now I need to do it in a different way. I'm trying to add roughly over 500 messages, so the player doesn't get tired reading the same messages over and over again.

I tried adding an "if" statement with a random chance but since I added to many messages, Quest froze every time I tried going to that tab. I fixed that now.

Is there another way for creating random messages to appear and how to do that please. I'm a noob with code and can't read it to save my life.

I think I need to add these random messages to "timers" though I'm not sure how to set a random chance without using the "if" statement.

I did check if this topic was posted before but couldn't find it.

If you need me to explain more, Let me know and thanks.

HegemonKhan
A good way is by using List and~or Dictionary Attributes, but they're a bit step up in learning, though. But, if you're willing:

(unfortunately, I'm not familiar with the GUI~Editor, so this will be in code, if it scares you too much, than just ignore my~this post, laughs)

the basic concept:

you have a list of all your random messages, and then you randomly select one of the messages from the list, to display to the person playing the game

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

http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... aries.html

and my guide on using them:

viewtopic.php?f=18&t=5137&p=35563&hilit=lists+and+dictionaries#p35563

randomization methods:

http://docs.textadventures.co.uk/quest/ ... eroll.html
http://docs.textadventures.co.uk/quest/ ... omint.html
http://docs.textadventures.co.uk/quest/ ... ouble.html
http://docs.textadventures.co.uk/quest/ ... hance.html

ask if you need any help or got any questions.

--------

Timers and Turnscripts aren't really for Randomization at all, they're for when you want a constant checking and~or just constantly activating~executing~running~firing scriptings, for example, checking if the 'player' is dead (player.life <= 0), ending the game:

<game name="blah">
</game>
<turnscript name="game_over_global_turnscript">
<enabled />
<script>
if (player.life <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
</script>
</turnscript>

HegemonKhan
quest's code really isn't that difficult to understand...

in English language, the blocks are called 'pararaphs' (and the lines are called 'sentences' ), each paragraph block beginning with a tab indent, an Uppercase symbol of your first word's symbol, and ending with a symbol (a period, an exclamation mark, a question mark, etc):

{tab indent}This paragraph is a block in the English language. Blah blah blah xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx blah blah blah content. This is the end of the block.{the period to the left marks the end of the block}


quest's code block (horizontal):

<Element name="xxx" {etc optional or non-optional tag attributes}>{the contents}</Element>


quest's code block (vertical):

<Element name="xxx" {etc optional or non-optional tag attributes}>
// the contents
</Element>


http://docs.textadventures.co.uk/quest/elements/ (Elements: Objects, Exits, Functions, Commands, Verbs, Turnscripts, Timers, Object Types, etc)
http://docs.textadventures.co.uk/quest/types/ (Attributes)

examples:

the~a game file's block (your game's entire code):

// the game file itself (this has nothing to do with this code stuff), has the extension of: *.aslx

<asl version="###">
// {mass of your game code's contents}
</asl>

the~a library file's block:

// the library file itself (this has nothing to do with this code stuff), has the extension of (the same as a game file): *.aslx

<library>
// {mass of your library's contents}
</library>

the special 'game' Game Object (for your game's global settings~options):

<game name="xxx">
<gameid>xxx</gameid>
<author>xxx</author>
<description>xxx</description>
<subtitle>xxx</subtitle>
<version>xxx</version>
<firstpublished>xxx</firstpublished>
<category>xxx</category
<difficulty>xxx</difficulty>
<cruelty>xxx</cruelty>
<pov type="object">xxx</pov>
<start type="script">
// scriptings (action~event code lines~blocks)
</start>
// etc Attributes
</game>

Objects:

<object name="xxx">
// Attributes and~or other Objects
</object>

Attributes (the various syntaxes, and~or shortened syntax forms, make these a bit complicated~confusing):

horizontally:

<attr name="xxx" type="xxx">value~contents</attr>

// or (vertically):

<attr name="xxx" type="xxx">
// value~contents
</attr>

// etc Elements' tag blocks

a new (default) game code:

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="xxx">
<gameid>xxx</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>
</object>
</asl>


-----------

all the 'tag' block stuff: <xxx>xxx</xxx>, is creation of 'physical' stuff.

any code lines without the 'tags', is the scriptings (action~event code lines~blocks, or in the GUI~Editor: run as script -> add new~a script), which this post doesn't get into, as it's a total separate discussion, than this 'tag', the creation of the 'physical', stuff.

InfectedBehaviour
Thanks. Not really sure what you just told me but I gather it's the same thing a friend told me to try and do. I'm going to read what you sent me and do my best. Thanks again. :)

HegemonKhan
see if you can figure out how to work with List Attributes in the GUI~Editor ...

(I'll get on the GUI~Editor, figuring it out, to help you, but it'll take a bit of time ~ at most a day or two)

Dwellewd
Another thing which may be helpful since the gui and code view gets ammended simultaniously is to make a change in GUI and then go into code view to see the syntax. Do this enough times and you may find it easier to start block copying and pasting for similiar coding instead of messing with the gui and drop downs etc...

For example, look at the tabs tutorial and see how you can easily block copy a single spell and paste all applicable code while quickly changing the descriptions for a different spell.

~Dwellewd~

The Pixie
InfectedBehaviour wrote:Hi I'm new to Quest. Been working on a game for almost two months now.

I've already gotten some random messages to appear in my game but now I need to do it in a different way. I'm trying to add roughly over 500 messages, so the player doesn't get tired reading the same messages over and over again.

I am not sure quite what you mean, but if you want random messages to appear every now and again without the player typing anything, see this tutorial page:
http://docs.textadventures.co.uk/quest/ ... ripts.html

If you want to change around what the player sees when he does type some, say in a room description, use the text processor. A description might look like this, with the random bits in the curly braces:
This is a pretty room. You can see {random:balloons:a mouse wearing a hat:a pigeon pecking at the window}.

You just type that into the room description as normal.

I tried adding an "if" statement with a random chance but since I added to many messages, Quest froze every time I tried going to that tab. I fixed that now.


How many is that? Could you post your code so we can see it and see if that is the problem? If the game will still play, it could well be the GUI struggling to display multiple nested if statements, but there might be a better way to do it.

InfectedBehaviour
Sorry I've been busy.

I've actually worked out away to get my messages to go random using only the gui editor, since coding at the moment is way over my head. I just find that the gui editor is easier to understand.

Plus trying to work around a few bugs here and there but so far so good.

InfectedBehaviour
The Pixie wrote:
I am not sure quite what you mean, but if you want random messages to appear every now and again without the player typing anything, see this tutorial page:
http://docs.textadventures.co.uk/quest/ ... ripts.html

If you want to change around what the player sees when he does type some, say in a room description, use the text processor. A description might look like this, with the random bits in the curly braces:
This is a pretty room. You can see {random:balloons:a mouse wearing a hat:a pigeon pecking at the window}.

You just type that into the room description as normal.

I tried adding an "if" statement with a random chance but since I added to many messages, Quest froze every time I tried going to that tab. I fixed that now.


How many is that? Could you post your code so we can see it and see if that is the problem? If the game will still play, it could well be the GUI struggling to display multiple nested if statements, but there might be a better way to do it.



Basically I'm working on a game that's in a shopping mall and the announcements I would like to come in random and not always have the same announcements popping up. Though I think I've find my solution but will be happy with any help thanks.

InfectedBehaviour
I had over twenty different "if" statements and that froze quest. I solved it by only adding six "if" statements while also creating different timers for each "if" statements.

HegemonKhan
just like in math, the 'order of operations' matters vitally, well so too does it matter vitally with coding. Make sure you click on the the correct 'add a script' circle buttons (though it's not easy to do this correctly, one of the reasons I like coding better, as you can directly see the indenting~'nesting' of the code lines), which determines the 'order of operations'. If you literally think of it as an outline format, then it'll help you greatly (though there's still a lot of hurdles regardless, laughs).

The most error-free scripting structure is this (using an outline for example):

diagonally from the upper left to the lower right (a single path of operation)

I. xxx
A. xxx
1. xxx
a. xxx
(1). xxx
(A). xxx


in PSEUDO code, an example:

if (xxx) {
if (xxx) {
if (xxx) {
if (xxx) {
if (xxx) {
}
}
}
}
}


you get into more difficulty with the 'order of operations' when you do this (outline example):

I. xxx
A. xxx
1. xxx
a. xxx
(1). xxx
(A). xxx
2. xxx
a. xxx
(1). xxx
(A). xxx
B. xxx
1. xxx
a. xxx
(1). xxx
(A). xxx
II. xxx
A. xxx
1. xxx
a. xxx
(1). xxx
(A). xxx
2. xxx
a. xxx
(1). xxx
(A). xxx
B. xxx
1. xxx
a. xxx
(1). xxx
(A). xxx


in PSEUDO code example:

if (xxx) {
if (xxx) {
if (xxx) {
}
}
} else if (xxx) {
if (xxx) {
if (xxx) {
}
}
} else {
}
if (xxx) {
if (xxx) {
}
} else if (xxx) {
if (xxx) {
if (xxx) {
}
}
} else {
}


the reason is because of this (ignore my poor drawing skills, lol):

(1) xxx
|.\
|..(2) xxx
|
(3) xxx

as can (hopefully) be seen, (2) and (3) are activating~running~executing~firing_off at the same time, which can cause conflicts.

and it gets even worse, the more complex you get, as well as especially when you try to do looping as well. getting code to work under the rules of the 'order of operations' is not easy for code noobs (like myself).

InfectedBehaviour
If I suck at coding, I don't even fall under code noobs lol but thanks for your help. Thanks again for the help. It will come handy.

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

Support

Forums