跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
帮助
RustedWarfare Wiki
搜索
搜索
创建账号
登录
个人工具
创建账号
登录
查看“数组”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
链接
RustedWiki QQ群
←
数组
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
'''数组'''(array)是铁锈[[1.15|1.15p11]]加入的一种数据结构。 数组可以存储多个同种类型的元素,在铁锈中,数组存储数量最大值为10000。 ==支持的类型== {| class="wikitable" |+数组支持的类型 |boolean[] |布尔值 |- |float[] |浮点数 |- |number[] |整数(float) |- |unit[] |单位 |} ==定义== 与[[自定义内存|普通内存]]一样,在[core]节中,可以使用<code>defineUnitMemory</code>和<code>@memory</code>来定义数组,数组名字可以包含中文。 ===通过defineUnitMemory定义=== 在[core]节中添加: <code>defineUnitMemory:类型 名称[]</code> ===通过@memory定义=== @memory是defineUnitMemory的快捷方式,通常由多行多个@memory组成。 单个@memory的格式为: <code>@memory 名称:类型</code> {{折叠|@memory的例子|<pre> @memory dir:float[] @memory amo:number[] @memory armor_f:unit[] </pre>}} ==引用== ===下标=== 下标是一个整数,用来索引数组的特定项。在铁锈中,数组下标从0开始。 ===单位内部引用=== 要引用单位内部的自定义内存,可以直接使用 <code>memory.名称[下标]</code> 。 ===跨单位引用=== 要引用其他单位的内存,可以使用<code>readUnitMemory</code> <code>单位引用.readUnitMemory('名称',type='类型',index='下标')</code> ==跨单位读数组== readUnitMemory('名称',type='类型')['下标'] readUnitMemory('名称',type='类型')[('数学运算下标')] readUnitMemory('名称',type='类型').get('下标'){{折叠|readUnitMemory例子|<pre> self.customTarget1.readUnitMemory('a',type='number',index=114) </pre> }} 警告:截止1.15版,跨单位读数组,由于游戏bug,单位参考将被重定向。 {{折叠|例子|<pre> 代码: customTarget1.readUnitMemory("obj",type="unit[]").get(memory.index) customTarget1.readUnitMemory("obj",type="unit[]").get(self.hp) 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>}} thisActionIndex/index方法不受此影响。 使用消息接受数组,将返回空数组。 eventData("get",type="float[]")=[] 可用的方案: {{折叠|复制数组|<pre> [hiddenAction_copy] alsoTriggerAction:set alsoTriggerActionRepeat:customTarget1.readUnitMemory("obj",type="unit[]").size alsoTriggerOrQueueActionWithTarget:customTarget1 [hiddenAction_set] setUnitMemory:buffer[index]=thisActionTarget.readUnitMemory("obj",type="unit[]").get(index) </pre>}} 警告:使用接受消息时复制数组,如果这涉及了跨队伍且队伍不为0,会导致复制的所有项为空,你可以使用alsoTriggerOrQueueActionWithTarget:eventSource和thisActionTarget避免它,但是如果你添加了条件这也会复制空,需要使用shrinkArrays:obj修复它 详细请见 clipboard/data/typeAll.ini clipboard/data/floatTypes.ini 2.修改内存单位数据 详细请见 clipboard/gui/all-units.template [action_0] [action_next] clipboard/gui/edit.ini [action_last] [action_next] clipboard/gui/input.ini [action_0b] clipboard/gui/objput.ini [action_0b] [action_0n] 下载链接: https://cra.lanzouj.com/b0agtlmih 密码00 3.三重定向到自己的内存,需要内存单位持有自己。(如列3,这里不提供代码实现) == 专用用法 == * <code>数组名.size/数组名.length</code> 返回数组大小(元素个数) * <code>数组名=null</code> 清空数组,大小变为0 * <code>数组名.contains("数据")</code> 检测数组中是否包含这个数据 * <code>[action]shrinkArrays</code> 移除数组中空的部分 {{折叠|shrinkArrays例子|2=array a=1,2,0,3 <br> shrinkArrays:a <br> array a=1,2,3}} [[分类:模组制作]]
本页使用的模板:
模板:折叠
(
查看源代码
)
返回
数组
。
开关有限宽度模式