[Lua] Lotto - der Zufallsgerator

CHDK-Skripte, CHDK-Entwicklung, PC-Zusatzprogramme, Informationen für Tüftler

the shake edition

Beitragvon msl » 13.11.2008, 21:10

Extra für PhyrePhox, der Lottogerator - the shake edition :D

Zum Würfeln der Zahlen die Kamera eimal nach links, dann nach rechts drehen und wieder gerade( 270 Grad - 90 Grad - 0 Grad).

Nur für Kameras mit Orientierungssensor!

Syntax: [ Download ] [ Verstecken ]
Benutze Lua Syntax Highlighting
--[[

@title lotto demo

@param n how many

@default n 6

@param r max

@default r 49

@param s min

@default s 1

@param e exclusive 1=on

@default e 1

@param o sort

@default o 1

@param z sound 1=on

@default z 1

]]




function shake()

    repeat

    until get_orientation_sensor() == 270

    repeat

    until get_orientation_sensor() == 90

    repeat

    until get_orientation_sensor() == 0

    if sound == 1 then play_sound(4) end

end



--start script



count     = n

min       = s

max       = r

exclusive = e

order     = o

sound     = z



if (min >= max) then

    print("Wrong params, dumbass!;-)")

    wait_click(0)

    else

    if ((exclusive == 1) and ((max - min + 1)<count)) then

        print("Wrong params, dumbass!;-)")

        wait_click(0)

        else

        repeat

          result= {}                                

            if exclusive == 1 then                    

                array = {}                              

                for i = min, max do                    

                    array[i] = i

                end

                for i = min, max do                    

                    rnd = math.random(min, max)          

                    buffer = array[i]                    

                    array[i] = array[rnd]

                    array[rnd] = buffer

                end

                for c=1, count do                      

                    result[c] = array[c]

                end

            else

                for i = min, max do                    

                    result[i] = math.random(min, max)    

                end

            end

            if order == 1 then table.sort(result) end

            output = table.concat(result,", ")

            cls()

            print("-----[shake the cam]-----")

            print()

            print(output)

            shake()

        until false

end                                            

end
Erstellt in 0.016 Sekunden, mit GeSHi 1.0.8.9
Dateianhänge
lotto_02.lua
Lottogenerator - the shake edition
(1.58 KiB) 849-mal heruntergeladen
Benutzeravatar
msl
Super-Mod
Super-Mod
 
Beiträge: 4567
Bilder: 271
Registriert: 22.02.2008, 11:47
Wohnort: Leipzig
Kamera(s): A720 1.00c
SX220 1.01a

Vorherige

Zurück zu Code-Ecke

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 15 Gäste