Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
What you have to do is
To create a delay you essentially got three ways:
1 count program executions
- that is a simple integer that increases per execution until a certain value is reached
- this approach has to be done at the "top level" of any PB
2 use timestamps to check how many reach seconds have been passed
- that is essentially defining a delay in [milli]seconds, have the last execution time and check if the current execution time is farther from the last time than the delay defines
- this approach however depends on real time and thus low sim speed has a negative impact unless manually corrected
- this approach works at any place and doesnt require a "tp level" implementation
3 use the ElapsedTime the PB defines
- this approach should be sim speed corrected but i dont know if that really is the case
- it has to be implemented at the "top level" as well
With "top level" i mean that it has to be done shortly after the void Main(string arg) start and before any actual heavy work or escape code is present.
I hope that helps
The first approach seems the simplest. Will this count script exectutions or can it be used to count loop iterations within a method? I could be wrong but one script execution happens every game 'tick' therefore you would have to re-run a script to count once as opposed to counting several times within one script?
Thanks for your help so far.
However it can also be once every few ticks if it works with other methods or through a chain of multiple timers that work in sequence.
Additionally it could be a whole second if you make the timer "Start" itself with a 1s delay.
Thus if you have a construct like
However keep in mind that the PB could also get executed outside the expected usage.
That is either any PB that runs all other PBs it can get, using it through the terminal or buttons etc etc.
That is especially important when you got large delays in the timer but less so if the unexpected calls happen very rarely compared to the timer blocks calls.
You could of course also use that method for "loop iterations" but that is what the good old for-loop is for.
https://en.wikipedia.org/wiki/Finite-state_machine
Have a state variable that defines where you currently are.
Have possible transitions for each state with depending conditions to move to another state with according actions.
Here are two examples how that could look like in a simple case:
http://flylib.com/books/4/70/1/html/2/images/fig405_01.jpg
http://i.stack.imgur.com/tLbXm.png
How you model your states is up to you then.
Lets assume a single PB with one argument "toggleDoor" that is meant to open or close a door with more precision than the simple open toggle as that doesnt really care about the real state.
You could build it with 3 or 4 states.
3 states => door open, door, closed, door changing
4 states => door open, door, closed, door opening, door closing
Also there is always an initial state, that is either a completely different state or you define one of the states as such. In the case of that door, it is best to have a separated initial state.
For the sake of examples lets do the 4 state version.
We use an integer "state" that gets associated with these states:
0 initial state
1 door open
2 door closing
3 door closed
4 door opening
The following code was not tested and serves as example
I hope that helps.
Cheers