function calculateGainOverHrs(dronenum, hrs)
local yypx = 0
for hrs=hrs,0,-1
do
yypx = yypx + calculateGainHour(dronenum)
end
return yypx
end
나는 광산 시설에서 확보하고 얼마나 많은 돈을 계산하는 프로그램을 만들려고 해요 (물론, 게임을 (.))에 대한 루아의 최소값 근처 기대했다. 위의 함수를 사용하여 특정 시간 동안의 이득을 계산했습니다. 그러나 그것을 실행하면이 오류가 발생합니다 -'<name>은'루프
\LUAPrograms\miningalgoluaport.lua:29: '<name>' expected near '0'
이 질문의 특수성으로 인해 검색 할 수 없습니다. 나는 수정이 있다고 확신하지만, hrs 인수를 함수에 넣기 만하면된다. 내가 도대체 뭘 잘못하고있는 겁니까?
편집 : 스크립트는 다음과 같습니다 -
-- Ores --
Cop = 5
Iro = 10
Sil = 150
Gol = 250
Pla = 400
Dia = 1000
Aeg = 1300
Cer = 1700
Rub = 2300
Ura = 1300
Plu = 2100
Sol = 4000
-- Ores --
drones = nil
totalpx = 0
math.randomseed(os.time * 42420451 * 425714 * 0.23)
math.randomseed(math.random(1,29214757862396238564328976))
function calculateGainOverDays(dronenum, days)
yyypxyyy = calculateGainOverHrs(dronenum, 24) * days
return yyypxyyy
end
function calculateGainOverHrs(dronenum, hrs)
local yypx = 0
for hrs,0,-1
do
yypx = yypx + calculateGainHour(dronenum)
end
return yypx
end
function calculateGainHour(dronenum)
local ypx = 0
orenum = math.random(1,30)
for orenum,0,-1
do
ore = randint(1, 100)
if (ore >= 1 and ore <= 5)
px += Cop * dronenum
end
else if (ore >= 6 and ore <= 30)
px += Iro * dronenum
end
else if (ore >= 31 and ore <= 52)
px += Sil * dronenum
end
else if (ore >= 53 and ore <= 62)
px += Gol * dronenum
end
else if (ore >= 63 and ore <= 70)
px += Pla * dronenum
end
else if (ore >= 71 and ore <= 77)
px += Dia * dronenum
end
else if (ore >= 78 and ore <= 87)
px += Aeg * dronenum
end
else if (ore >= 88 and ore <= 90)
px += Cer * dronenum
end
else if (ore == 91)
px += Rub * dronenum
end
else if (ore >= 92 and ore <= 97)
px += Plu * dronenum
end
else if (ore >= 98 and ore <= 100)
px += Sol * dronenum
end
end
return px
end
function menuDisplay()
print
(
"1 - Calculate Ore Gain\n"..
"2 - Change Drone Number\n"..
"Total Pixels this Session: " .. tostring(totalpx)
end
)
if (io.read = 1)
print
(
"1 - Over Days \n"..
"2 - Over Hours \n"..
"3 - Over an Hour"
)
if (io.read() = 1)
io.write("How many days?")
local tempI = nil
local tempII = io.read
tempI = calculateGainOverDays(drones,tempII)
print("The facility generated " .. tempI .. "px over" .. tempII .. "days.")
totalpx = totalpx + tempI
menuDisplay()
end
else if (io.read() = 2)
io.write("How many hours?")
local tempI = nil
local tempII = io.read
tempI = calculateGainOverHrs(drones,tempII)
print("The facility generated " .. tempI .. "px over" .. tempII .. "hours.")
totalpx = totalpx + tempI
menuDisplay()
end
else if (io.read() = 3)
local tempI = calculateGainHour(drones)
print("In one hour, the facility generated " .. temp1 .. "px."
totalpx = totalpx + tempI
menuDisplay()
end
else if (io.read = 2)
io.write("New Dronenum:")
drones = io.read
menuDisplay()
end
end
--!CORE!--
--!CORE!--
--!CORE!--
--!CORE!--
--!CORE!--
print("Vernet Industries Ore Calculator - Created by Maurice Vernet")
print("Initializing...")
io.write("Enter Number of Drones:")
drones = io.read()
menuDisplay()
@PaulKulchenko와의 계약에 따라 코드는 5.1 및 5.2 모두에서 작동합니다. 그 코드가 관련 됐는지 확신합니까? –
코드 조각'calculateGainOverHrs'와 전체'calculateGainOverHrs' 함수를 비교하면 코드 조각에서 변경 한 내용이 나타나 문제를 해결할 수 있습니다. –
IDE (예 : [Koneki] (http://www.eclipse.org/koneki/ldt/))는 입력하는 동안 오류를 발견하는 데 도움이 될 수 있습니다. 그런 다음 특정 질문을 할 수 있습니다. –