You need to wait for Check userID to complete asynchronously before use userArray Load data. Just like you add the LocalStorage callback condition below. But you have already done this because you use another array object user_data below. And you don't have any information about AJAX here, so you may have written it wrong.
And, the user_check function, This loop Array condition, you may need to use it as a sub-condition.
I don't quite understand whether the two array objects user_data and userArray are the same thing, But what you want to load from LocalStorage is already in the user_data array object.
中文版回答:
LocalStorage 是一个异步动作,你需要等待异步完成才能得到请求的数据。不能直接挨着写 userArray 读取数据。要像下面一样: 先检查是否存在,如果存在再获取数据,获取到了再读取。
不过,你已经是知道了要这么做的,因为你已经在 On item userID get 里面,用另一个数组 user_data Load 到了本地数据。本地数据都在这里面。
我不是很理解 user_data 和 userArray 这 2 个数组对象是否是相同的东西,但如果你希望从 LocalStorage 中读取存档,再进行遍历数据,你需要将上面的 userArray 的 Load 动作,也放到下面的 On item get 里面。
或者在中间夹一个 "等待前面异步完成" 动作,然后继续用 userArray 读取数据。然后添加一个子条件,把开头系统循环的事件放在子条件继续执行
Hello~ "userArray" and "user_data" are used to store different types of data.
Since my users are pre-established, I use AJAX to call the file and store the static data in "userArray."
However, each user's attributes are dynamic and constantly change during the game, so "user_data" is used to store them.
Then I tried adding "wait for the previous action to complete" after local storage, but I still can't restore the player's attribute variables when returning to the game next time. Do you have any suggestions? Thank you very much!