Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Gamer Update 1
Browse files Browse the repository at this point in the history
- Adjusted and repaired the gamer.lua
- Function call works now, functions for all values are existent
- Renamed soundtrack folder for better structure
  • Loading branch information
creyD committed May 3, 2017
1 parent d7c6b89 commit ef71c0a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions lua_testbay/gamer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,59 @@ require "peasant"

-- Start of the gamer.lua program
gpower = 0 gawe = 0 gworship = 0 glove = 0 gfear = 0 ghatred = 0
playerstats = {gawe, gworship, glove, gfear, ghatred} -- Create array for some cases of storage of the variables/ Idea for storage

-- Functions to calculate the global stats
function calc_gawe(civilisation) -- This function adds up the awe of the civilisation
for i, peasant in ipairs(civilisation) do
gawe = peasant.awe + gawe
end
return gawe
end

function calc_glove(...) -- NO not glove! g love. That´s what the function calcs.
for peasant in arg do
glove = arg[peasant] + glove
function calc_gworship(civilisation) -- This function adds up the worship of the civilisation
for i, peasant in ipairs(civilisation) do
gworship = peasant.worship + gworship
end
return gworship
end

function calc_glove(civilisation) -- NO not glove! g love. That´s what the function calcs.
for i, peasant in ipairs(civilisation) do
glove = peasant.love + glove
end
return glove
end

function calc_gfear(civilisation) -- This function adds up the fear of the civilisation
for i, peasant in ipairs(civilisation) do
gfear = peasant.fear + gfear
end
return gfear
end

function calc_ghatred(civilisation) -- This function adds up the fear of the civilisation
for i, peasant in ipairs(civilisation) do
ghatred = peasant.hatred + ghatred
end
return ghatred
end

function calc_all(civilisation) -- This function adds up all the values for one civilisation
for i, peasant in ipairs(civilisation) do
gawe = peasant.awe + gawe
gworship = peasant.worship + gworship
glove = peasant.love + glove
gfear = peasant.fear + gfear
ghatred = peasant.hatred + ghatred
end
return -- No value jet
end

-- Testing area:

peasant1 = birth(peasant1)
change_love(peasant1, 50)
change_love(peasant1, 20)
print(peasant1.name)

peasant2 = birth(peasant2)
Expand All @@ -33,13 +72,13 @@ peasant3 = birth(peasant3)
change_love(peasant3, 130)
print(peasant3.name)

civilisation = {peasant1.love, peasant2.love, peasant3.love}
civilisation = {peasant1, peasant2, peasant3}
calc_glove(civilisation)
print(glove)

--[[
Notes:
Known errors:
Problem with the function call (variable arguments)
No variable for calc_all function
]]--
File renamed without changes.
File renamed without changes.

0 comments on commit ef71c0a

Please sign in to comment.