다섯 가지 특성을 가져 와서 저장하는 간단한 캐릭터 디자인 프로그램을 작성해야하는 과제가 있습니다. 캐릭터 생성이 끝나면 프로그램은 사용자가 캐릭터를 보거나 편집하거나 생성하기를 원하는지 물어볼 필요가 있습니다.LUA의 캐릭터 작성 프로그램
이제 데이터 구조와 문자 저장 및로드 기능을 만들어야하는데 많은 도움이 필요합니다. 프로그래밍에 대한 지식이 거의 없습니다.
-- Default Character Class
Character = {power = 0, speed = 0, defense = 0, intelligence = 0, stamina = 0}
function Character:create (n)
n = n or {}
setmetatable(n, self)
self.__index = self
return n
end
-- Function to take user input
function input()
print "please enter the power level:"
local Power = io.read()
print "please enter the speed level:"
local Speed = io.read()
print "please enter the defense level:"
local Defense = io.read()
print "please enter the intellegence level:"
local intelligence = io.read()
print "please enter the Stamina level:"
local Stamina = io.read()
end
-- main loop
function MainMenu()
selection = {"1", "2", "3" or "4"}
while selection ~= "1","2", "3" or "4"
print "1. would you like to edit your character?"
print "2. would you like to create a new character?"
print "3. would you like to view a character? "
print "4. would you like to exit the screen?"
if selection == "1" then -- I was uncertain on how to call an already made character or data so I used this method to just recreate a character
print (character:input)
elseif selection == "2" then
print (character:input)
elseif selection == "3" then
print (last.character, input()) -- was also unsure on how to code this portion as well.
elseif selection == "4" then
io.exit()
else selection is ~= selection()
print "please select from the number below 1-4"
end
end
end
update()
menu()
'0'은 루아에서 거짓이 아닙니다. – greatwolf
그래서 그것은 보인다. 나는 그 소식을 바로 잡았다. – StephenS
나는 내가 언어에 익숙하지 않고 혼자서 공부할 시간이 거의 없기 때문에 나는이 과정을 통해 나를 도울 누군가를 진실되게 찾고 있다는 것을 알게 된 것을 사과한다. 그러나 모든 도움에 감사드립니다. 대단히 감사합니다. –