construct2 - How can I have it read a string and react differently to each character?

1.6k views Asked by At

I would like to have an array of strings, then make a for each loop that goes through each string, but then also I want it to read each character and react in different ways:

If char = 0 shoot left, if char = 1 shoot right, that sort of thing.

So that I can use strings to program the actions.

1

There are 1 answers

0
Brute Force On BEST ANSWER

I'm not too good with arrays, but I can tell you how to do this with a text file

First, create the objects AJAX and Function

Next, import the text file

Then make these variables and events:

|               
|
Global text variable "TextVar" = ""

Global number variable "TextIndex" = 0

Event: System - On start of layout

--Actions:
    AJAX - Request text.txt, tag "Tag"

Event: AJAX - On "Tag" completed

--Actions:

----System - set TextVar to AJAX.LastData

Event: System - Every 0.1 seconds

--Actions:

----Function - Call "function" (mid(TextVar, TextIndex, 1))

----System - Add 1 to "TextIndex"

Event: Function - On "function"

--Sub-Event: Function - Parameter 0 = "0"

----Actions: (stuff)

--Sub-Event: Function - Parameter 0 = "1"

----Actions: (stuff)


|               
|   

Hope this helps