I try to make a game that works on time, for now it works but i want to make some adjustments.
I would like to make the array with the fastest times.
I created a function in visualization where you have to enter your name, the time played must be linked to the name entered and sorted in the array.
I have a start and stop sensor for detecting the played time.
Is there sombody who can help me in the right direction?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would do it like this:
Create a structure with string (for the players name) and time
Declare f.eg. TopTen : Array [1..10] of struct xxxxx
do in a loop:
if Gespeelde_Tijd is higher than the time in Array10 do nothing and exit loop.
if Gespeelde_Tijd is lower than the time in Array10 and higher than Array9 replace Array10 with Gespeelde_Tijd and name and exit loop.
if Gespeelde_Tijd is lower than the time in Array9 then copy Array9 to Array10 and go to next loop.
in the next loop cycle:
if Gespeelde_Tijd is lower than the time in Array8 then
copy Array8 to Array9 and got to next loop cycle
else store Gespeelde_Tijd and name of the player in Array9 and exit loop
and so on.
Hope you can understand my english explanations, my native language is german
and i'm rigth, you are dutch?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you axplain create a structure with string (for the players name) and time?
Do i have to that in a DUT?
Declare f.eg. TopTen : Array [1..10] of struct xxxxx
I do this in the PLC_PRG?
Do i also have to make the loop in the PLC_PRG?
I program in funtion blocks how do i add the text?
if Gespeelde_Tijd is higher than the time in Array10 do nothing and exit loop.
if Gespeelde_Tijd is lower than the time in Array10 and higher than Array9 replace Array10 with Gespeelde_Tijd and name and exit loop.
if Gespeelde_Tijd is lower than the time in Array9 then copy Array9 to Array10 and go to next loop.
Or can i make a POU in structure text?
Sorry for the beginners questions
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The text isn't ST-code, it should be a idea for you, to find your own way to program this.
Yes, you can create a function like your stopwatch in ST and call it from your PLC_PRG.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I try to make a game that works on time, for now it works but i want to make some adjustments.
I would like to make the array with the fastest times.
I created a function in visualization where you have to enter your name, the time played must be linked to the name entered and sorted in the array.
I have a start and stop sensor for detecting the played time.
Is there sombody who can help me in the right direction?
See:
https://www.google.com/amp/s/www.geeksf ... -sort/amp/
Sent from my Moto G (5S) Plus using Tapatalk
I would do it like this:
Create a structure with string (for the players name) and time
Declare f.eg. TopTen : Array [1..10] of struct xxxxx
do in a loop:
if Gespeelde_Tijd is higher than the time in Array10 do nothing and exit loop.
if Gespeelde_Tijd is lower than the time in Array10 and higher than Array9 replace Array10 with Gespeelde_Tijd and name and exit loop.
if Gespeelde_Tijd is lower than the time in Array9 then copy Array9 to Array10 and go to next loop.
in the next loop cycle:
if Gespeelde_Tijd is lower than the time in Array8 then
copy Array8 to Array9 and got to next loop cycle
else store Gespeelde_Tijd and name of the player in Array9 and exit loop
and so on.
Hope you can understand my english explanations, my native language is german
and i'm rigth, you are dutch?
Hello, and thank you for your replay.
I'm from Holland indeed.
I appreciate your help.
Can you axplain create a structure with string (for the players name) and time?
Do i have to that in a DUT?
Declare f.eg. TopTen : Array [1..10] of struct xxxxx
I do this in the PLC_PRG?
Do i also have to make the loop in the PLC_PRG?
I program in funtion blocks how do i add the text?
if Gespeelde_Tijd is higher than the time in Array10 do nothing and exit loop.
if Gespeelde_Tijd is lower than the time in Array10 and higher than Array9 replace Array10 with Gespeelde_Tijd and name and exit loop.
if Gespeelde_Tijd is lower than the time in Array9 then copy Array9 to Array10 and go to next loop.
Or can i make a POU in structure text?
Sorry for the beginners questions
rtfm: read the f.... manual to learn more about codesys
https://help.codesys.com/webapp/_cds_tu ... n=3.5.14.0
https://help.codesys.com/webapp/_cds_st ... n=3.5.14.0
https://help.codesys.com/webapp/_cds_da ... n=3.5.14.0
The text isn't ST-code, it should be a idea for you, to find your own way to program this.
Yes, you can create a function like your stopwatch in ST and call it from your PLC_PRG.