This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

bots istances aren't processed properly at startup

All reported bugs that's actually by design.
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

bots istances aren't processed properly at startup

Post by JakSparro98 » Wed Jul 20, 2016 8:50 pm

When I use a startup trigger to load a script to count both users and bots only the players instances are loaded into the array but if i run the method by a timer with 0 seconds of delay it works.

The code is this:

Code: Select all

public void EntityCounter(TriggerArgs args){

IPlayer[] entities=Game.GetPlayers();
int i=0;

foreach (IPlayer count in entities){
i++;
}
Game.ShowPopupMessage(""+i);
}
The map for testing the issue:
http://download1076.mediafire.com/ezq9t ... 3/bug.sfdm

I don't know if this is a bug but surely the bots istances are loaded after the first game clock cycle is run.
Last edited by JakSparro98 on Wed Jul 20, 2016 10:19 pm, edited 1 time in total.
0 x

User avatar
gwendalaze
Superfighter
Superfighter
Posts: 84
Joined: Sat Mar 19, 2016 12:55 pm
Title: Jarate Yellow Belt
Started SFD: PreAlpha 1.1.4
Location: France

Post by gwendalaze » Wed Jul 20, 2016 9:28 pm

if I remember well, startup trigger take acion before OnStartup method
Anyway, you should put a link the map you used to test this for the devs to understand where the bug is coming from
0 x
- Gwendalaze, failing at being fun, just like this signature

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Wed Jul 20, 2016 10:20 pm

gwendalaze wrote:if I remember well, startup trigger take acion before OnStartup method
Anyway, you should put a link the map you used to test this for the devs to understand where the bug is coming from
Thanks for the reply, I've tried your advice but nothing changed, now I also posted the map. I didn't do it before because it's an empty map, I rewrited code more times before open this topic but it seems a problem of the first moments of the map initialization.
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Wed Jul 20, 2016 10:55 pm

You're assuming that the game should be smart enough to figure out the priority order for all your "Activate on startup" triggers. This is not the case. The OnStartup will run before any triggers are activated. All "Activate on startup" triggers runs in a non-defined order (depending on how the map is edited, how/when you create the tiles etc...). Maybe you want 3 out of 6 bots to spawn before your script runs, or after, or before. You need to defined the order of events to accomplish what you're trying to do.

To define the order simply set false to the "run on startup" property to all triggers. Now they won't trigger so we need to do it. You could let one well defined "StartupTrigger" be your starting point and let it point on the first PlayerSpawnTrigger. Let that one in turn activate the second PlayerSpawnTrigger. Let that one in turn activate the third PlayerSpawnTrigger and so on... let the last PlayerSpawnTrigger call the script you want to run.

Or use a delay timer.

We have plans to add other events in the future to the ScriptAPI to simplify certain thinks like "AfterStartup" and "OnPlayerCreated" to simplify things.
0 x
Gurt

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 27

Post by JakSparro98 » Thu Jul 21, 2016 12:18 am

Gurt wrote:You're assuming that the game should be smart enough to figure out the priority order for all your "Activate on startup" triggers. This is not the case. The OnStartup will run before any triggers are activated. All "Activate on startup" triggers runs in a non-defined order (depending on how the map is edited, how/when you create the tiles etc...). Maybe you want 3 out of 6 bots to spawn before your script runs, or after, or before. You need to defined the order of events to accomplish what you're trying to do.

I see, for some reason I thought that the properties added in the editor before the simulation was stored as actions to process during the loading of the map itself so all was before the first clock of the map.

I even studied process concurrency and semaphores at school... :oops:
0 x

Locked