I have an assignment that requires me to create a simple character design program that takes in five characteristics and stores them. At the end of the character creation the program needs to ask if the user wants to view, edit, or create a character.
And now I have to create a data structure and the ability to save and load a character and I need a lot of help. I have very little knowledge in programming.
-- 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()