- Joined
- Mar 25, 2008
- Messages
- 2,955
Hi,
today we'll do a simple
(difficulty: 2/10)
We need:
ints[1] will change every ten seconds
intm[0] will change every 60 seconds
intm[1] will change every 600 seconds (ten minutes)
inth[0] will change every 3600 seconds (one hour)
(inth[1] will change every 36000 seconds (every ten hours))
Have fun
today we'll do a simple
Multiboard counter
.(difficulty: 2/10)
-----------------------------
- medium knowledge about variables
- an existing multiboard
- three (six) integer variables
- GUI
-----------------------------
The Set-up:
Open your Triggers-Editor, and click on the 'x' stating 'variables (or press CTRL + X, as you want to create a new one.
Now you create a new variable of the type integer, name it whatever (it's gonna be our seconds-integer).
After, create one more for the minutes and a third one for the hours.Now - I did it with arrays of size 2 - but you also can use another variable (makes two for seconds, two for minutes and two for the hours, they way it's done is pretty the same.The trigger itself
Alright, now create a new trigger and give it the event:
- Time - Every 1.00 seconds of game time
We're gonna do this using the arrayed variables, so read carefully now.
I named my integer for the seconds 'ints[]', for the minutes 'intm[]' and for the hours 'inth[]'.
As we want to make the counter look pretty, we do it like this:
Inth[] : intm[] : ints[]
You might know that if an integer is of the value 0, it will show 0 ingame.
But you might want 00:00:00 - that's where we need the arrays come in (or the second variables of each type).
Now, we set it up as follows:
-
Actions
- Set ints[0] = (ints[0] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ints[0] Equal to 10
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = (ints[1] + 1)
- Else - Actions
-
If - Conditions
The 'Set ints[1] =' increases the counter by +10.
It sounds more complicated than it is.
Basically, every second, int[0] is increased.
When int[0] reaches the value '10', (means after ten seconds), int[1] is increased by 1 and int[0] being reset to 0.
Next for the minutes:
We want to change the integer for the minutes to increase by 1 if the seconds reach 60, that's clear.
Now, the trigger-part looks like that
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ints[1] Equal to 6
-
Then Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = (intm[0] + 1)
- Else - Actions
-
If - Conditions
Now for a better understanding, do it yourself for the minutes and hours:
Set the variables correctly so the intm[1] is raised by 1 every ten minutes and if the integer reaches 6, reset all values but increase the values for the hours by one.
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- intm[0] Equal to 10
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = 0
- Set intm[1] = (intm[1] + 1)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- intm[1] Equal to 6
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = 0
- Set intm[1] = 0
- Set inth[0] = (inth[0] + 1)
- Else - Actions
-
If - Conditions
Our whole trigger now looks somewhat like this:
-
Actions
- Set ints[0] = (ints[0] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ints[0] Equal to 10
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = (ints[1] + 1)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ints[1] Equal to 6
-
Then Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = (intm[0] + 1)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- intm[0] Equal to 10
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = 0
- Set intm[1] = (intm[1] + 1)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- intm[1] Equal to 6
-
Then - Actions
- Set ints[0] = 0
- Set ints[1] = 0
- Set intm[0] = 0
- Set intm[1] = 0
- Set inth[0] = (inth[0] + 1)
- Else - Actions
-
If - Conditions
The Multiboard-implementation
Last thing is to put it right into your multiboard.
This is pretty easy too, you just need a bunch of strings.
The actual multiboard will look like:Code:inth[1] inth[0] : intm[1] intm[0] : ints[1] ints[0] 0 0 : 0 0 : 0 0
For the actual action, just don't forget to leave spaces between the :
- Multiboard - Set the text for (Last created multiboard) item in column x, row y to ((((String(inth[1])) + (String(inth[0]))) + :) + (((String(intm[1])) + (String(intm[0]))) + (: + ((String(ints[1])) + (String(ints[0]))))))
-----------------------------
Conclusion:
ints[0] will change every secondints[1] will change every ten seconds
intm[0] will change every 60 seconds
intm[1] will change every 600 seconds (ten minutes)
inth[0] will change every 3600 seconds (one hour)
(inth[1] will change every 36000 seconds (every ten hours))
Have fun
Last edited by a moderator: