In the original implementation of global in sim-agents, we compiled global first, then compiled instances.
But during QA with older project files, the instance ids from older project specs were interfering with the global id, resulting in global agents being reassigned to other agents. So we had reversed the order, compiling instances to establish the base ids, then compiling global so it uses a new unique id.
The problem of course, is this means global properties are not available to instances immediately. This was not an obvious error if the instance scripts only referenced global during # PROGRAM UPDATE. But references in # PROGRAM INIT would cause errors because global is not yet defined during INIT.
This fixes the problem by compiling global first, then compiling instances. In addition, we add a check to throw an error if we encounter an older project file that has a conflicting id. If the project does not appear to load, check the console for the following error:
Instance id already in use by Global! Please review your instance ids!!!
The error should list the problem instance spec.
In the current build, the global id is usually 154. (The id is consistently 154 because of the other sm-objects that are created before global -- note that this may change in the future).
TO TEST
Because this changes the compile order, we strongly recommend opening and running all current scripts to make sure there no errors.
You can trigger an error by setting the id of any instance defined in a project to the number 154 (note, not string "154" -- use a text editor to edit the instances array at the end of a project file).
Merges dev-bl/global-precompile -> dev-next
In the original implementation of global in sim-agents, we compiled global first, then compiled instances. But during QA with older project files, the instance ids from older project specs were interfering with the global id, resulting in global agents being reassigned to other agents. So we had reversed the order, compiling instances to establish the base ids, then compiling global so it uses a new unique id.
The problem of course, is this means global properties are not available to instances immediately. This was not an obvious error if the instance scripts only referenced global during
# PROGRAM UPDATE
. But references in# PROGRAM INIT
would cause errors becauseglobal
is not yet defined duringINIT
.This fixes the problem by compiling global first, then compiling instances. In addition, we add a check to throw an error if we encounter an older project file that has a conflicting id. If the project does not appear to load, check the console for the following error:
Instance id already in use by Global! Please review your instance ids!!!
The error should list the problem instance spec.
In the current build, the global id is usually 154. (The id is consistently 154 because of the other sm-objects that are created before global -- note that this may change in the future).
TO TEST
Because this changes the compile order, we strongly recommend opening and running all current scripts to make sure there no errors.
You can trigger an error by setting the id of any instance defined in a project to the number
154
(note, not string "154" -- use a text editor to edit theinstances
array at the end of a project file).