逍遥MIR 发表于 2024-7-17 23:59:45

77M2引擎的传奇如何使用静态数组和动态数组脚本范例

unit UnitArray;

inte**ce
uses SysUtils;

const
JobNames: array of String=('战士', '法师', '道士', '刺客', '弓箭手'); //这是一个静态数组,运行期不需要改变,所以定义为const

var
Job_AddAbility: array of array of Integer;//这是动态数组      

procedure Main(Npc: TNormNPC; Player: TPlayObject; Args: TArgs);

implementation

procedure Main(Npc: TNormNPC; Player: TPlayObject; Args: TArgs);
begin
Player.Say(IntToStr(Job_AddAbility)); //访问数组数据
end;

procedure InitArry;
var
I: Integer;
begin
//定义数组大小
SetLength(Job_AddAbility, 5);
for I := 0 to 4 do
    SetLength(Job_AddAbility, 3);

//赋值
Job_AddAbility := ;
Job_AddAbility := ;
Job_AddAbility := ;
Job_AddAbility := ;
Job_AddAbility := ;
end;

procedure FinaArry;
begin
FillChar(Job_AddAbility, SizeOf(Job_AddAbility), #0);
end;

initialization
InitArry;//单元初始化的时候执行数组初始化(M2退出或重加载脚本)

finalization
FinaArry; //单元初始化的时候执行数组初始化(M2退出或重加载脚本)

end.
页: [1]
查看完整版本: 77M2引擎的传奇如何使用静态数组和动态数组脚本范例