String 构造函数2-如何让它读取字符串并对每个字符做出不同的反应?

String 构造函数2-如何让它读取字符串并对每个字符做出不同的反应?,string,foreach,character,construct-2,String,Foreach,Character,Construct 2,我希望有一个字符串数组,然后为每个字符串创建一个for-each循环,但我还希望它读取每个字符并以不同的方式作出反应: | | Global text variable "TextVar" = "" Global number variable "TextIndex" = 0 Event: System - On start of layout --Actions: AJAX - Request text.txt, tag "Tag" Event:

我希望有一个字符串数组,然后为每个字符串创建一个for-each循环,但我还希望它读取每个字符并以不同的方式作出反应:

|               
|
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)


|               
|   
如果char=0向左射击,如果char=1向右射击,诸如此类

|               
|
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)


|               
|   

因此,我可以使用字符串来编程操作。

我不太擅长使用数组,但我可以告诉您如何使用文本文件进行编程

|               
|
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)


|               
|   
首先,创建AJAX对象和函数

|               
|
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)


|               
|   
接下来,导入文本文件

|               
|
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)


|               
|   
然后生成以下变量和事件:

|               
|
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)


|               
|   
希望这有帮助

|               
|
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)


|               
|