ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Is it possible to increase an array as the game progresses?

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Is it possible to increase an array as the game progresses?

Postby DazaKiwi » Sat Feb 11, 2017 11:29 am

I don't think it is possible in Adrift, what i want to do is add keywords to an array on the fly so only specific keywords collected in the course of the game will be in the array. I think you can only define an array with values at the start or during the game, but you cannot add to it later on without overwriting what is stored, is that correct? Is the same case for a string variable?

If its not possible then a work around is using objects named as the keywords and push them into a group, this way you can define if a keyword is in a list (or group in this case).
User avatar
DazaKiwi
 
Posts: 466
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand

Re: Is it possible to increase an array as the game progress

Postby ralphmerridew » Sat Feb 11, 2017 1:20 pm

If nothing else, you can initialize it to a bunch of empty values.
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier
User avatar
ralphmerridew
 
Posts: 2489
Joined: Fri Dec 13, 2002 11:56 pm
Location: Missouri

Re: Is it possible to increase an array as the game progress

Postby DazaKiwi » Sat Feb 11, 2017 10:04 pm

ralphmerridew wrote:If nothing else, you can initialize it to a bunch of empty values.


Hmm, another possibility yes. I wanted to use an array (a topic) to put a characters name into it and reference it originally.

Another idea is to simply create a character group for a topic and add the character you spoke with into it once the topic has been completed. More ideal if many characters share the same topics. However i am a bit rusty with my expressions and i am having trouble trying to get it right. <#if(groupkey.characterkey.count=1, "" etc but it gives me errors. How do you have it so it checks if a character is in a group (i know i can use alt dec restriction for this, but expressions are faster to do esp with copy and paste).

an Example of what i am doing in the display area of a topic ;

adrift Code: Select all
<#if(groupKey.Characterkey.Count=1,"<font color=red>2) A question?</font>","2) A question?")#>


So if the topic has already been chosen by player it will display the multi-choice options in red text.

Another method would be to create a property for characters that can be selected, with the topic heading. Which i might have to do if i cannot work with groups in this manner for the expression. I suppose it is the same amount of work to create groups for topics.

*Update* Manage to get it to work with using basic select properties for topics. Still im interested to know if it can work with groups as i was trying to do earlier..?
User avatar
DazaKiwi
 
Posts: 466
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand

Re: Is it possible to increase an array as the game progress

Postby saabie » Sun Feb 12, 2017 12:56 am

No, you can't filter a group with an item, only with a property.
The usual way to do this is to add properties to characters (one for each topic) which are initially selected and then cleared when the topic is chosen. (It doesn't work the other way around)

If you really want to use groups then you could use the instr function to test if a particular key is in the group:
adrift Code: Select all
<#if(instr("GroupKey.Known", %character%)=0, "2) A question?", "<font color=red>2) A question?</font>")#>

"Known" can be any selection-only property that all of the characters in the group have set. This is needed because a key by itself is not recognised by ADRIFT.
This lists all the keys in the group, separated by pipe characters like this:
FredBlogg|Sally|Harry|DazaKiwi|JohnSmith
The instr function returns zero if the %character% key is NOT in the above string, otherwise it returns the character position of the beginning of the key in the string.
saabie
 
Posts: 818
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia

Re: Is it possible to increase an array as the game progress

Postby DazaKiwi » Sun Feb 12, 2017 1:52 am

saabie wrote:No, you can't filter a group with an item, only with a property.
The usual way to do this is to add properties to characters (one for each topic) which are initially selected and then cleared when the topic is chosen. (It doesn't work the other way around)

If you really want to use groups then you could use the instr function to test if a particular key is in the group:
adrift Code: Select all
<#if(instr("GroupKey.Known", %character%)=0, "2) A question?", "<font color=red>2) A question?</font>")#>

"Known" can be any selection-only property that all of the characters in the group have set. This is needed because a key by itself is not recognised by ADRIFT.
This lists all the keys in the group, separated by pipe characters like this:
FredBlogg|Sally|Harry|DazaKiwi|JohnSmith
The instr function returns zero if the %character% key is NOT in the above string, otherwise it returns the character position of the beginning of the key in the string.


Thanks saabie for that example. I am currently not using groups and just using selection-only property for topics. But i am glad to know how to use groups also now, will come in handy for other uses i might need for that. I will file that example away in my notes. Cheers.
User avatar
DazaKiwi
 
Posts: 466
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 2 guests

cron