Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Scripts and Thread Efficiency?

Asked by 8 years ago

Let's say I'm trying to create an RPG world with numerous near-identical monsters. In the case of AI, would it be more efficient to have a script per monster or a single script somewhere else that handles all of them abstractly, but in a multi-threaded fashion?

For sake of passing the not-a-question filter: r.Stepped:connect(function() --Do AI stoof end)

tl;dr: Single multi-threaded script or multiple single-threaded scripts?

Also, is it more proper to refer to them as coroutines or threads?

2 answers

Log in to vote
1
Answered by 8 years ago

The most efficient way would most likely be a single thread for all the monsters. However, for this question I suspect that multiple coroutines would likely be faster (as multiple scripts will run on multiple threads, anyway, and have different global environments and require the actual Script object)

0
Thank you for your input, I forgot to take into account the script itself. Dynamese 35 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

I'm thinking a good way would be having a ModuleScript in each monster and have one base script to control all of the monsters in case you want some monsters to have different AI as different monsters but have the same basic functions.

0
Neat idea! I'll be sure to do that! Dynamese 35 — 8y
0
I thought about doing this, but was not sure if the source would replicate (and thus be under threat of theft.) Of course, a ModuleScript which requires a ModuleScript in ServerScriptService/ServerStorage is safer. SwardGames 325 — 8y

Answer this question