Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New "Thread"
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
New "Thread"
Hey guys.
Very long time I wrote DM. When the player died, I created a timer, so he was resurrected after a certain period of time. It's pretty convenient.
1) And now I have a question, how do I better organize several threads, through timers or use the Thread class?
2) There is one more problem related to IDialogue. When the dialog is not closed, the ElapsedTime property in any case is 0. What should I do?
3) Can I use the async await statements in the code?
Very long time I wrote DM. When the player died, I created a timer, so he was resurrected after a certain period of time. It's pretty convenient.
1) And now I have a question, how do I better organize several threads, through timers or use the Thread class?
2) There is one more problem related to IDialogue. When the dialog is not closed, the ElapsedTime property in any case is 0. What should I do?
3) Can I use the async await statements in the code?
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
1) We cannot use the Thread class but in future there will be coroutines to avoid some performance related problems.kirill240 wrote: ↑Tue Jun 27, 2017 10:45 pmHey guys.
Very long time I wrote DM. When the player died, I created a timer, so he was resurrected after a certain period of time. It's pretty convenient.
1) And now I have a question, how do I better organize several threads, through timers or use the Thread class?
2) There is one more problem related to IDialogue. When the dialog is not closed, the ElapsedTime property in any case is 0. What should I do?
3) Can I use the async await statements in the code?
2) I didn't played so much with the IDialogue but it seems that 0 is for make the text stay the right amount of time to let the player read, based on how many words or letters are showed, I think, so keep that value unchanged.
3) As I said above, this won't happen, but there is a planned solution here.
Last edited by JakSparro98 on Thu Jun 29, 2017 12:01 pm, edited 1 time in total.
0 x
- Gurt
- Lead Programmer
- Posts: 1884
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
JakSparro98 wrote: ↑Wed Jun 28, 2017 12:25 pm1) We cannot use the Thread class but in future there will be coroutines to avoid some performance related problems.kirill240 wrote: ↑Tue Jun 27, 2017 10:45 pmHey guys.
Very long time I wrote DM. When the player died, I created a timer, so he was resurrected after a certain period of time. It's pretty convenient.
1) And now I have a question, how do I better organize several threads, through timers or use the Thread class?
2) There is one more problem related to IDialogue. When the dialog is not closed, the ElapsedTime property in any case is 0. What should I do?
3) Can I use the async await statements in the code?
2) I didn't played so much with the IDialogue but it seems that 0 is for make the text stay the right amount of time to let the player read, based on how many words or letters are showed, I think, so keep that value unchanged.
3) As I said above, this won't appen, but there is a planned solution here.
Just to clarify: We do not have anything planned to support threading in the script API.Gurt wrote:Threading (using threads or tasks) will not be supported in SFD
0 x
Gurt
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Indeed, not threading but async loops, I thought something like coroutines would be implemented, maybe the topic I quoted was just a possible suggestion and nothing planned, I misunderstood it for all the time...Gurt wrote: Just to clarify: We do not have anything planned to support threading in the script API.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
How can it be possible? because all the namespaces available do not allow us to use background operations and so to open threads, can you explain better?
0 x
system.componentmodel.backgroundworker worker = new system.componentmodel.backgroundworker();JakSparro98 wrote: ↑Thu Jun 29, 2017 12:04 pmHow can it be possible? because all the namespaces available do not allow us to use background operations and so to open threads, can you explain better?
//Other code
With "Task" and others is the same story
0 x
- Motto73
- Superfighter
- Posts: 316
- Joined: Mon May 09, 2016 7:35 am
- Title: Lazy ass
- SFD Account: Motto73
- Started SFD: Multiplayer Test Demo
- Location: Sunny City
- Gender:
- Age: 24
Oh, wow, something that lets us create "threads". I tried doing them via System.Threading.Thread, but it obviously gave permission error, as did System.Io things. I hope that we some day get a real way using i/o and some standardized ways of tasking, whatever is the plan now.
Maybe we can use pointers and unsafe code to read and write files while we dont have any other supported ways... dunno, gotta check if its possible.
Maybe we can use pointers and unsafe code to read and write files while we dont have any other supported ways... dunno, gotta check if its possible.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
I'm very interested using paralelism but threading in SFD scripts it's not worth the pain because you cannot access objects behind a thread, well, you can but you have to synchronize the new thread with the main thread and I still didn't figured out how.Motto73 wrote: ↑Wed Aug 16, 2017 1:32 pmOh, wow, something that lets us create "threads". I tried doing them via System.Threading.Thread, but it obviously gave permission error, as did System.Io things. I hope that we some day get a real way using i/o and some standardized ways of tasking, whatever is the plan now.
Maybe we can use pointers and unsafe code to read and write files while we dont have any other supported ways... dunno, gotta check if its possible.
Someone could say "why we need to synchronize the new thread if we can use it even immediately?" imagine this: in the main thread, when the scene finishes loading it is "disassembled" to reload all the scene again, if the thread accidentally wants to access an object when the scene is disposed you will get a NullReferenceException because, of course, it isn't loaded yet but the script cannot handle exception through threads and as a result the whole process hangs.
Currently I've implemented some kind of coroutines with the IEnumerator class (based of concurrency and not parallelism), still cannot get the perfect balance between performance and code reactivity, in case we cannot use threads we just need to know that Gurt managed to put game and AI code all in one thread, maybe using a similar solution.
0 x
- Motto73
- Superfighter
- Posts: 316
- Joined: Mon May 09, 2016 7:35 am
- Title: Lazy ass
- SFD Account: Motto73
- Started SFD: Multiplayer Test Demo
- Location: Sunny City
- Gender:
- Age: 24
O yea, it would be good if the AI could be executed in its own thread. Maybe it could be used with some attribute in a method that uses AI? Maybe like, Ai class should be its own thread, acting like an user and inputting stuff?JakSparro98 wrote: ↑Wed Aug 16, 2017 2:12 pm...
Currently I've implemented some kind of coroutines with the IEnumerator class (based of concurrency and not parallelism), still cannot get the perfect balance between performance and code reactivity, in case we cannot use threads we just need to know that Gurt managed to put game and AI code all in one thread, maybe using a similar solution.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Like in Unity 3d the APIs are not thread-safe, but this doesn't mean you cannot perform actions that doesn't require object references, you can even process a whole path for an entity requiring pathfinding in a separate thread, but all the information needed have to be passed at the moment the thread start cause they won't access, for instance, to an object position through GetWorldPosition(), even if you stored the object reference before the new thread started (since, as I already said, It's like the object never existed)
0 x