Space Engineers

Space Engineers

Ver estadísticas:
Rontagosh 7 ABR 2015 a las 2:39 p. m.
C# and Question about Timer Blocks - Milliseconds
Anyone know if the devs plan on allowing the timer blocks to work in milliseconds? Are there any mods that enable this? Can it be done with a programming block? Thanks in advance for any answers.

Also, feel free to talk C#
Última edición por Rontagosh; 10 MAY 2017 a las 12:24 p. m.
< >
Mostrando 1-15 de 27 comentarios
Gekkibi 7 ABR 2015 a las 2:46 p. m. 
A timer block on trigger-now loop can run a script extremely often. Then you would only need to create a counter that goes up every frame.
VanGoghComplex 7 ABR 2015 a las 3:18 p. m. 
I think the one-second time minimum is a performance-minded cap, but that's just conjecture. I haven't read anything anywhere though about them decreasing it.
Rontagosh 8 ABR 2015 a las 2:20 a. m. 
@Van - Not neccesarily for <1 second timers. Could be used for 1.5, 1.6, 5.76, and so on. If it is perfomance based issue (I'm not sure why it would be, if even just for one timer), then I may deduce it will be done in at least the late stages of development(or so I hear); I hope anyway.

I couldn't find anything about them decreasing it either. :/

@Gekkibi - Is there something similar to 'sleep' (java) in C# that works in-game? Are you saying you can delay a timer (to trigger now) in milliseconds via programmable block (and possibly another timer)? I'm not clear on that.

Edit: http://stackoverflow.com/questions/91108/how-do-i-get-my-c-sharp-program-to-sleep-for-50-msec
Is this applicable in-game?
Última edición por Rontagosh; 8 ABR 2015 a las 2:28 a. m.
Paranoidmarv 8 ABR 2015 a las 3:05 a. m. 
I think you have to import system libraries to use that and as far as I know Space Engineers doesn't support that.

I had this problem earlier when I was trying to make a laser array that fired at <1 second intervals. What I did was I made a mechanical clock out of a rotor using sensors.
Rontagosh 8 ABR 2015 a las 3:11 a. m. 
Publicado originalmente por Paranoidmarv:
I think you have to import system libraries to use that and as far as I know Space Engineers doesn't support that.

I had this problem earlier when I was trying to make a laser array that fired at <1 second intervals. What I did was I made a mechanical clock out of a rotor using sensors.

Gotcha.

Ingenious workaround, but won't work for what I'm doing. Thanks for sharing.
zgrssd 8 ABR 2015 a las 3:49 a. m. 
Publicado originalmente por Rontagosh:
@Van - Not neccesarily for <1 second timers. Could be used for 1.5, 1.6, 5.76, and so on.
There is never "only one timer" in a world. There are going to be hundreds in a world.
So <1 second is a really bad idea.

Interestingly while Ctrl+Click allows you to set the value up to the 3rd decimal place, it appears to get rounded.
According to mod API this value is a float already. So at the very least they have room for this kind of change.
Última edición por zgrssd; 8 ABR 2015 a las 3:53 a. m.
SievertChaser 8 ABR 2015 a las 4:44 a. m. 
I'm all for more precise timers. However, I've noticed that the game seems to operate on a mixed 60 Hz - 1 Hz physics step. My torpedoes, after being decoupled, can spend almost a second adrift, even though the decoupling and activation are triggerred by the same timer.
zgrssd 8 ABR 2015 a las 10:11 a. m. 
I just understood why you cannt set timers down to miliseconds:
They don't want polling scripts to be run too often (<1 second).

If we could set timers to 1.5, how long would it take for someone too set up 3 timers*:
A is set to 1.5 delay and then start/trigger now C
B and C are set to 1 second delay, restarting themself and triggering the same work
Start A and B at same time.

After 2.5 seconds you have two timers doing the same action every 0.5 seconds.
Just give me one timer with ms precision, one programming block and a large enough vanilla timer group and I will make you a script doing the same operation at any time resolution.

I guess they just really saw that comming.


*From writing this post it is 0 seconds
Última edición por zgrssd; 8 ABR 2015 a las 10:13 a. m.
plaYer2k 8 ABR 2015 a las 10:20 a. m. 
These arguments with "they dont want us to run timers too often" is flawed as we can use Trigger Now and thus run timers once per game tick.

Thus it actually forces us to use a less elegant solution to get what we want.

As for the current solution, you can set up a timer and programmable block in such a way:
Timer:
- run the PB
PB:
- store the last time the script ran
- store the time you want to wait
- check if the different between stored time and current time exceeds the time you want to wait
- if not then terminate the script
- if it does then do what you want to do
Gekkibi 8 ABR 2015 a las 1:21 p. m. 
Publicado originalmente por Rontagosh:
@Gekkibi - Is there something similar to 'sleep' (java) in C# that works in-game? Are you saying you can delay a timer (to trigger now) in milliseconds via programmable block (and possibly another timer)? I'm not clear on that.
Sorry for the late response. There isn't. But like I said, you can do a counter and an if statement that is run only every x frame.
AlexMBrennan 8 ABR 2015 a las 1:34 p. m. 
I think you have to import system libraries to use that and as far as I know Space Engineers doesn't support that.
That's not gonna work - no time passes while scripts are executing, so even if you could make the script wait that long it would simply result in extreme lag between frames which is not what you want.
plaYer2k 8 ABR 2015 a las 2:00 p. m. 
Well both Sleep(x) aswell as Wait() and Notify() could be implemented for programmable blocks.
The script would not continue in both cases, backup the stack and store the current position with the execution.

When the time x for Sleep has passed in case of a Sleep(x) call or the PBs Notify() method was called in case of Wait(), then it would continuee where it previously halted with the stack backup at the old/stored position.

So it actually would be possible.

Handling all PBs through separate threads internally would make the whole setup even easier.
The huge drawback of that however is the performance impact that approach had.

Instead, it is best to use the approach i described above and check the passed time relative to a stored time.
Paranoidmarv 8 ABR 2015 a las 2:27 p. m. 
Publicado originalmente por plαYer2k:
Timer:
- run the PB
PB:
- store the last time the script ran
- store the time you want to wait
- check if the different between stored time and current time exceeds the time you want to wait
- if not then terminate the script
- if it does then do what you want to do

Just to clarify, you're saying that the Timer will keep executing the PB with Trigger Now until the current time exceeds the time you want to wait.


plaYer2k 8 ABR 2015 a las 2:29 p. m. 
If you apply the TriggerNow action to that timer from within the PB before you terminate the loop, yes. So it looks like this:

Timer -> run PB
PB -> checks time diff
PB -> do work if time is above waiting time
PB -> TriggerNow Timer

and it loops again, the time runs the PB, PB checks ....
Paranoidmarv 8 ABR 2015 a las 2:34 p. m. 
That's awesome.

Thanks!
< >
Mostrando 1-15 de 27 comentarios
Por página: 1530 50

Publicado el: 7 ABR 2015 a las 2:39 p. m.
Mensajes: 27