在 Lua 中制作脚本 [关闭]

问题描述 投票:0回答:0

我正在尝试制作一个游戏,它给你一个数字,你必须说出下一个数字是更大还是更小,我遇到了 5 个错误。这是它所说的所有错误的代码和图片

    MyVar = 1
    print("High score: "..tostring(score))
    print "say play or exit"
input = io.read()
if(input == "play") then
repeat
    Ran = Random(1,9)
    Ran2 = Random(1,9)
if(Ran == Ran2) then
Ran2 = Random(1,9)
    end
    print("ok your number is"..Ran "do you think the other number is greater or less")
    input2 = io.read()
    if(Ran > Ran2 ) then
        if(input2 == "greater") then
            print"correct you got 1 point"
            score = (score + 1)
        else
            print"WRONG nice try"
            function saveHighScore(score)
local file,err = io.open("high_score.txt",'w')
                if file then
                   file:write(tostring(score))
                 file:close()
                 score = 0
                else
                print("error:", err)
                end
                if(Ran < Ran2 ) then
                    if(input2 == "greater") then
                        print"correct you got 1 point"
                        score = (score + 1)
                    else
                        print"WRONG nice try"
                        function saveHighScore(score)
            local file,err = io.open("high_score.txt",'w')
                            if file then
                               file:write(tostring(score))
                             file:close()
                             score = 0
                            else
                            print("error:", err)
                            end
                        until(MyVar == 2)
         end
     end

我尝试添加更多的结尾擦除观看视频的结尾,但都没有帮助。code errors

lua helper
© www.soinside.com 2019 - 2024. All rights reserved.