数组:修订间差异

无编辑摘要
(大更改,需要修正)
标签移动版编辑 移动版网页编辑 可视化编辑
无编辑摘要
标签移动版编辑 移动版网页编辑 可视化编辑
 
(未显示2个用户的23个中间版本)
第6行:
{| class="wikitable"
|+数组支持的类型
|boolean[]
|布尔值
|-
|float[]
|浮点数(更新日志未提到)
|-
|number[]
|整数(float)
|-
|unit[]
|单位
|}
第28行:
@memory是defineUnitMemory的快捷方式,通常由多行多个@memory组成。
 
单个@memory的格式为: <code>@memory 名称:类型[]</code>
{{折叠|@memory的例子|<pre>
@memory dir:float[]
第47行:
要引用其他单位的内存,可以使用<code>readUnitMemory</code>
 
<code>单位引用.readUnitMemory('名称',type='类型',index='下标')</code>
 
<code>self.customTarget1.readUnitMemory('a',type='number',index=114)</code>
这是它的其他写法
 
=== 修改数组 ===
在[action]中,可以通过<code>setUnitMemory</code>来直接修改内存的值,格式为<code>setUnitMemory:名称[下标]=值</code> 。
 
当修改的下标在数组中不存在时,数组大小将会更改为修改的下标。
{{折叠|setUnitMemory例子|<pre>
# [action] 中
setUnitMemory:a[1]=1,b=memory.b[memory.a[1]]+1
</pre>}}
和内存一样,数组也可以通过<code>[core]updateUnitMemory</code>来更新。
 
==跨单位读数组==
readUnitMemory('名称',type='类型')['下标']
 
readUnitMemory('名称',type='类型')[('数学运算下标')]
 
readUnitMemory('名称',type='类型').get('下标'){{折叠|readUnitMemory例子|<pre>
self.customTarget1.readUnitMemory('a',type='number',index=114)
</pre>
}}
警告:截止1.15版,跨单位数组引用在下标中包含逻辑时。由于游戏bug,单位参考将被重定向。
 
警告:截止1.15版,跨单位数组引用在下标中包含逻辑时。由于游戏bug,单位参考将被重定向。
如:
<pre>
代码:
customTarget1.readUnitMemory("obj",type="unit[]").get(selfmemory.hpindex)
 
customTarget1.readUnitMemory("obj",type="unit[]").get(memoryself.indexhp)
 
customTarget1.readUnitMemory("obj",type="unit").get(self.hp)
 
customTarget1.readUnitMemory("obj",type="unit").get(memory.unit.readUnitMemory("index",type="float"))
 
实现运行(伪代码)
 
customTarget1.readUnitMemory("obj",type="unit[]").get(memory.unit.readUnitMemory("index",type="float"))
运行(结果:(伪代码)
customTarget1.memory.obj.get(customTarget1.memory.index)
 
customTarget1.memory.obj.get(customTarget1.hp)
 
customTarget1.memory.obj.get(customTarget1.memory.unit.memory.index)
</pre>
index/thisIndex方法局部函数不受此影响。
如:thisActionIndex/index,eventSource,thisActionTarget。
 
使用消息接受数组,将返回空数组。
index/thisIndex方法不受此影响。
 
eventData("get",type="float[]")=[]
可用的方案:
 
1.{{折叠|复制数组|<pre>
[hiddenAction_copy]
 
alsoTriggerAction:set
2.修改内存单位数据
 
alsoTriggerActionRepeat:customTarget1.readUnitMemory("obj",type="unit[]").size
clipboard.zip已使用改方案作为内核
 
alsoTriggerOrQueueActionWithTarget:customTarget1
 
[hiddenAction_set]
3.三重定向到自己的内存,需要内存单位持有自己。
 
setUnitMemory:buffer[index]=thisActionTarget.readUnitMemory("obj",type="unit[]").get(index)</pre>
在[action]中,可以通过<code>setUnitMemory</code>来直接修改内存的值,格式为<code>setUnitMemory:名称[下标]=值</code> 。
}}
 
===重定向到自己===
当修改的下标在数组中不存在时,数组大小将会更改为修改的下标。
使用局部变量重定向到自己。
{{折叠|setUnitMemory例子|<pre>
<pre>
# [action] 中
[hiddenAction_0]
setUnitMemory:a[1]=1,b=memory.b[memory.a[1]]+1
alsoTriggerAction:1
</pre>}}
alsoTriggerOrQueueActionWithTarget:self
和内存一样,数组也可以通过<code>[core]updateUnitMemory</code>来更新。
[hiddenAction_1]
debugMessage:customTarget1.readUnitMemory("arr",type="float[]").get(thisActionTarget.readUnitMemory("index",type="float"))
</pre>
 
===修改值===
使用发信等方式修改目标的值,通过被重定向目标进行访问(这里不提供代码实现)
 
== 专用用法 ==
255

个编辑