ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

How do you write to an array with a text variable 2 another?

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.

How do you write to an array with a text variable 2 another?

Postby DazaKiwi » Sat Sep 12, 2020 3:21 am

How do you write to an array with a text variable inside it to another text array?

I have created a system to randomly pick an event from an array and not repeat it. It moves the picked data to the end of the array where the index counter reduces by 1 so that the pool of random choices lessens and thus the events will not reappear again. This method works for the most part. I have tested it with just plain text in the array.

However i want to have my event text in a variable and output that when chosen (see example further below code example).

Using text variables inside an array and output them works fine, however in my system im using a temporary Array placeholder (CurrentList) for 2 different variations of my system (one outputs 3 choices being non-events eg. choosing a reward out of a list and the other will pick a single event). Even if i wasn't using a placeholder i still want to be able to move the text variable to the back of the array.

But i do not know how to write the text variable (inside the array) to the temporary array (CurrentList), letters or numbers is easy. Here is an example (This is a task that is looped and using a counter for the index will move across data in the array to the CurrentList array.)

adrift Code: Select all
Set variable CurrentList[%DataCrossOverCounter% to %Test2MasterList[%DataCrossOverCounter%]%


Inside the Test2MasterList array is data like so; %Event1Group1%

Which in that text variable is like;

This happened (event 1)

1) Do nothing
2) Do something
3) Do this

Then using the array that has text variables inside, this causes a bad expression error. I suspect the issue is the % is not being written/carried over, so is there a way i can do this? a work around?

I'm hoping there is a way to append the % % but if not, i guess the way to do it requires a little more work, having instead a code number like E1 that is picked and run through a series of tasks to match E1 and then output the text. I have used a system using objects and groups. But wanted to see if i can make something more easier with just arrays.

I hope this makes sense.
User avatar
DazaKiwi
 
Posts: 755
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61

Re: How do you write to an array with a text variable 2 anot

Postby DazaKiwi » Thu Sep 17, 2020 11:16 pm

Solved this problem.

You add text variables to an array without the %% and in the task you output the array in the Output window have
%%CurrentList[%RandomPick1%]%%

A simple solution thankfully.
User avatar
DazaKiwi
 
Posts: 755
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 3 guests

cron