Advertisement
NeonJ

Candybox inspired Minecraft-esque World THING

May 10th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 44.52 KB | None | 0 0
  1. --[[
  2.  
  3.   LogBox, a Candy Box-inspired game creatified by NeonJ
  4.  
  5.   There are [10] game ticks per second!
  6.  
  7.   This is starting to shape up!
  8.   Using Advanced Computers for mouse compatability and COLOUR
  9.  
  10.                               ____________    |      
  11.   <\       /\     _________  /|  Log   | |\   T      
  12.     \_ O  /\/\   /_________\  |   Box  | |   \O/
  13.       /> /\/\/\   | '' '' |   |¯¯¯¯¯¯¯¯  |    T
  14.      / >   ||     | [] '' |   | [] ' ' ' |   / \
  15.  
  16.   Ideas for the rightern GUI screen
  17.     - Shop        - Player can purchase items to use on his adventure and for his kingdom.
  18.     - Quests      - Player can bring his army on quests for glory and stuff. Mostly stuff.
  19.     - Stocks      - Shows the player's item stocks. Sorted by type. Undiscovered items are not displayed.
  20.     - Message Log - Gives a log of the player's recent events.
  21.     - World Map   - Player can explore towns and a world map itself.
  22.     -
  23.     -
  24.     -
  25.     -
  26.     -
  27.  
  28.   The World Map plan for the Rightern GUI (if it happens)
  29.     - When the player starts, he will be visible on the map and can click around to walk.
  30.        O       /___\
  31.       <|>      |...|       |
  32.       / \      | ; |    
  33.       [_] - - - [_] - - - [_]
  34.     - Destinations will become available as the player explores more of the map.
  35.     - To leave the town, the player must amass an army, as there are battles ahead.
  36.     - In the town: Town Hall   [Management & Options]
  37.                    Lumber Mill [Wood Stocks]
  38.                    Mine        [Stone and Metal Stocks]
  39.                    Farm        [Plant Stocks]
  40.                    Ranch       [Animal Stocks]
  41.                    Barracks    [Army Stocks]
  42.                    Blacksmith  [Tool Stocks]
  43.                    Market      [Buy / Sell Items]
  44.                    Town Gate   [Exit - Go on Quests!]
  45.                    
  46.                    
  47.  
  48.   - - Version History - -
  49.   a0.0.1: Nothing works yet it's still just a shell shut up
  50.   a0.0.2: Well, I finished the main doGameTick stuff, and there's now a lot of variables! All are used. Awesome.
  51.  
  52. ]]
  53.  
  54. -- Main Variables
  55. local main = {}
  56. local usr = {}
  57. local shop = {}
  58. local msg = {}
  59.  
  60. main["running"] = true
  61. main["timer"] = os.startTimer(0)
  62. main["lastTick"] = main["timer"]
  63.  
  64. -- Saved Variables
  65. usr["farm_tree"]       = 128      -- Max is <building_treeFarm> * 128
  66. usr["farm_wheatSeed"]  = 0        -- For food - High seed output, low food output, medium growth
  67. usr["farm_wheatCrop"]  = 0        -- Crop versions can be harvested.
  68. usr["farm_potatoSeed"] = 0        -- For food - High food output, slow growth, high seed output
  69. usr["farm_potatoCrop"] = 0        -- Crop versions can be harvested.
  70. usr["farm_carrotSeed"] = 0        -- For food - Medium food output, medium growth, medium seed output
  71. usr["farm_carrotCrop"] = 0        -- Crop versions can be harvested.
  72. usr["farm_melonSeed"]  = 0        -- For food - High seed output, low food output, fast growth
  73. usr["farm_melonCrop"]  = 0        -- Crop versions can be harvested.
  74. usr["farm_chicken"]    = 0        -- Provides feathers and food          - Requires 1 wheatSeed (or melonSeed) per 10000 ticks per chicken.
  75. usr["farm_cow"]        = 0        -- Provides leather and food           - Requires 1 wheatCrop per 14000 ticks per cow.
  76. usr["farm_pig"]        = 0        -- Just provides food, but high output - Requires 1 carrot per 8000 ticks per pig.
  77. usr["farm_sheep"]      = 0        -- Provides cloth and food             - Requires 1 wheatCrop per 16000 ticks per sheep.
  78.  
  79. usr["building_treeFarm"]   = 1    -- Each tree farm can hold 128 trees, and 16 workers.
  80. usr["building_stoneMine"]  = 0    -- Each stone mine can hold 16 workers.
  81. usr["building_cropFarm"]   = 0    -- Each crop farm can hold 128 crops in TOTAL, and 16 workers.
  82. usr["building_animalFarm"] = 0    -- Each animal farm can hold 128 "animal value". Cow is 8, Pig is 6 and Chicken is 4. Also holds 16 workers.
  83.  
  84. usr["resource_food"]        = 512  -- If you run out of food your workers will start to quit
  85. usr["resource_money"]       = 512  -- Bit of starter money
  86. usr["resource_log"]         = 0    -- Logs are originally used for money and basic crafting
  87. usr["resource_sapling"]     = 0    -- Saplings are used to plant more trees
  88. usr["resource_stone"]       = 0    -- Stone is a bit useless but it sells for a little bit, and is an infinite resource. Used for earlygame equipment.
  89. usr["resource_coal"]        = 0    -- Used to create alloys
  90. usr["resource_copper"]      = 0    -- Used to create bronze alloy. Also used for mechanisms
  91. usr["resource_tin"]         = 0    -- Used to create bronze alloy
  92. usr["resource_bronze"]      = 0    -- Alloy from coal, copper and tin
  93. usr["resource_iron"]        = 0    -- Used to craft weapons and armour
  94. usr["resource_steel"]       = 0    -- Alloy made from iron and coal. Stronger than iron. Used to craft weapons and armour
  95. usr["resource_mithril"]     = 0    -- Found on adventured. Stronger than steel. Used to craft weapons and armour.
  96. usr["resource_gold"]        = 0    -- Used for advanced creations, or sells for loads
  97. usr["resource_sapphire"]    = 0    -- Sells for loads. May have other uses.
  98. usr["resource_emerald"]     = 0    -- Sells for loads. May have other uses.
  99. usr["resource_ruby"]        = 0    -- Sells for loads. May have other uses.
  100. usr["resource_mithril"]     = 0    -- Raw mithril. Makes the best stuff.
  101. usr["resource_wheatSeed"]   = 0    -- Plant more wheat! Used to feed chickens.
  102. usr["resource_wheatCrop"]   = 0    -- Converted to 6 Food. Used to feed cows and sheep. (6 Food per 6000 ticks.)
  103. usr["resource_potato"]      = 0    -- Converted to 4 Food, or plant more Potatoes. (4-12 Food per 8000 ticks)
  104. usr["resource_carrot"]      = 0    -- Converted to 3 Food, or plant more Carrots. Used to feed pigs. (3-9 Food per 6000 ticks)
  105. usr["resource_melonCrop"]   = 0    -- Converted to 1 Food or melonSeed. (3-6 Food per 4000 ticks)
  106. usr["resource_melonSeed"]   = 0    -- Plant more melons! Used to feed chickens.
  107. usr["resource_leather"]     = 0    -- Gathered from cows. Used for basic armour.
  108. usr["resource_feather"]     = 0    -- Gathered from chickens. Used for crafting.
  109. usr["resource_wool"]        = 0    -- Gathered from sheep. Used to make bandages for your army.
  110. usr["resource_meatCow"]     = 0    -- Gathered from cows. Converts to 8 Food.
  111. usr["resource_meatPig"]     = 0    -- Gathered from pigs. Converts to 8 Food.
  112. usr["resource_meatChicken"] = 0    -- Gathered from chickens. Converts to 6 Food.
  113. usr["resource_meatSheep"]   = 0    -- Gathered from sheep. Converts to 6 Food.
  114. usr["resource_milk"]        = 0    -- Gathered from cows. Used to make medicine.
  115.  
  116. usr["tool_axeStone"]       = 1    -- Woodcutting: 50% speed   [2 Pt]
  117. usr["tool_axeBronze"]      = 0    -- Woodcutting: 75% speed   [3 Pt]
  118. usr["tool_axeIron"]        = 0    -- Woodcutting: 100% speed  [4 Pt]
  119. usr["tool_axeSteel"]       = 0    -- Woodcutting: 125% speed  [5 Pt]
  120. usr["tool_axeMithril"]     = 0    -- Woodcutting: 150% speed  [6 Pt]
  121. usr["tool_pickaxeStone"]   = 0    -- Mining: 50% speed   [2 Pt]
  122. usr["tool_pickaxeBronze"]  = 0    -- Mining: 75% speed   [3 Pt]
  123. usr["tool_pickaxeIron"]    = 0    -- Mining: 100% speed  [4 Pt]
  124. usr["tool_pickaxeSteel"]   = 0    -- Mining: 125% speed  [5 Pt]
  125. usr["tool_pickaxeMithril"] = 0    -- Mining: 150% speed  [6 Pt]
  126. usr["tool_hoeStone"]       = 0    -- Harvesting: 50% speed   [2 Pt]
  127. usr["tool_hoeBronze"]      = 0    -- Harvesting: 75% speed   [3 Pt]
  128. usr["tool_hoeIron"]        = 0    -- Harvesting: 100% speed  [4 Pt]
  129. usr["tool_hoeSteel"]       = 0    -- Harvesting: 125% speed  [5 Pt]
  130. usr["tool_hoeMithril"]     = 0    -- Harvesting: 150% speed  [6 Pt]
  131. usr["tool_swordStone"]     = 0    -- 2 DMG
  132. usr["tool_swordBronze"]    = 0    -- 4 DMG
  133. usr["tool_swordIron"]      = 0    -- 6 DMG
  134. usr["tool_swordSteel"]     = 0    -- 8 DMG
  135. usr["tool_swordMithril"]   = 0    -- 12 DMG
  136. -- Stone armour does not exist.   -- 0 DEF
  137. usr["tool_armourBronze"]   = 0    -- +4 DEF
  138. usr["tool_armourIron"]     = 0    -- +8 DEF
  139. usr["tool_armourSteel"]    = 0    -- +12 DEF
  140. usr["tool_armourMithril"]  = 0    -- +20 DEF
  141.  
  142. -- If a player has workers which have to use different kinds of tools, it'll be a mix of both
  143. -- ie: 5 stone axes, 10 iron axes, 12 workers
  144. -- Harvest Power will be 10x iron, 2x stone -> 10(4) + 2(2) = 44 Points of Harvest Power
  145. -- No work can be done if a tool is not supplied
  146.  
  147. usr["worker_logger"]   = 1        -- Logger chops 1 log per minute - more loggers mean faster resource gathering.
  148. usr["worker_farmer"]   = 0        -- Plants and harvests crops and saplings - more farmers mean faster action completing.
  149. usr["worker_rancher"]  = 0        -- Manages animals in a farm - more ranchers mean faster action completing.
  150. usr["worker_miner"]    = 0        -- Mines resources. Random chance to produce high-quality iron. Stone is infinite. More miners mean faster resource gathering.
  151. usr["worker_army"]     = 0        -- Goes on quests and finds treasure. The player leads them to battle. More soldiers mean more HP for your army.
  152. usr["worker_villager"] = 0        -- Regular villagers are without a job. I allow the player to reassign workers as they wish.
  153. usr["worker_total"]    = 1        -- Total workers. Used to make hunger-based calculations easier.
  154.  
  155. usr["hidden_logTick"] = 0         -- Every tick, this is increased by ["worker_logger"], as soon as it hits 6000 or more, a log is chopped
  156. usr["hidden_stoneTick"] = 0       -- Every tick, this is increased by ["worker_miner"], as soon as it hits 6000 or more, stone is mined
  157. usr["hidden_wheatTick"] = 0       -- Every tick, this is increased by ["farm_wheatSeed"], as soon as it hits 6000 or more, wheat can be harvested
  158. usr["hidden_melonTick"] = 0       -- Every tick, this is increased by ["farm_melonSeed"], as soon as it hits 4000 or more, melons can be harvested
  159. usr["hidden_potatoTick"] = 0      -- Every tick, this is increased by ["farm_potatoSeed"], as soon as it hits 8000 or more, potatoes can be harvested
  160. usr["hidden_carrotTick"] = 0      -- Every tick, this is increased by ["farm_carrotSeed"], as soon as it hits 6000 or more, carrots can be harvested
  161. usr["hidden_harvestTick"] = 0     -- Every tick, this is increased by ["worker_farmer"] when harvestables are available. After hitting 500, a random crop is harvested.
  162. usr["hidden_cowBreedTick"] = 0         -- Cooldown for cows to breed       - No slaughtering until time is up
  163. usr["hidden_chickenBreedTick"] = 0     -- Cooldown for chickens to breed   - No slaughtering until time is up
  164. usr["hidden_pigBreedTick"] = 0         -- Cooldown for pigs to breed       - No slaughtering until time is up
  165. usr["hidden_sheepBreedTick"] = 0       -- Cooldown for sheep to breed
  166. usr["hidden_cowFeedTick"] = 0          -- Every tick, this is increased by ["farm_cow"], as soon as it hits ???? or more, a wheatCrop is consumed.
  167. usr["hidden_chickenFeedTick"] = 0      -- Every tick, this is increased by ["farm_chicken"], as soon as it hits ???? or more, a wheatSeed or melonSeed is consumed.
  168. usr["hidden_pigFeedTick"] = 0          -- Every tick, this is increased by ["farm_pig"], as soon as it hits ???? or more, a carrot is consumed.
  169. usr["hidden_sheepFeedTick"] = 0        -- Every tick, this is increased by ["farm_sheep"], as soon as it hits ???? or more, a wheatCrop is consumed.
  170. usr["hidden_sheepResourceTick"] = 0    -- Every tick, this is increased by ["farm_sheep"], as soon as it hits 8000 or  more, a wool can be gathered.
  171. usr["hidden_cowResourceTick"] = 0      -- Every tick, this is increased by ["farm_cow"], as soon as it hits 16000 or more, a milk can be gathered.
  172. usr["hidden_rancherHarvestTick"] = 0   -- Every tick, this is increased by ["worker_rancher"], as soon as it hits 4000 or more, the rancher harvests something.
  173. usr["hidden_saplingTick"] = 0     -- Every tick, this is increased by (farmers / 30000), as soon as it hits 1 or more, a sapling is gathered
  174. usr["hidden_armyCooldown"] = 0    -- Cooldown for your army to recover from a quest. Less HP = More recovery time.
  175. usr["hidden_lastTree"] = 0        -- Increases by 1 every log. Has 1/4 chance to reset to 0 and -1 tree when value between 4-10. Instantly resets when it hits 10
  176. usr["hidden_eatTick"] = 0         -- Every tick, this is increased by (total workers / 1500), as soon as it hits 1 or more, food is depleted
  177.  
  178. -- Config Variables
  179. usr["setting_gameSpeed"]         = 1.0
  180. usr["setting_autoReplantWheat"]  = 1    -- Automatically replant crops, but do not plant more than what was initially planted.
  181. usr["setting_autoReplantMelon"]  = 1
  182. usr["setting_autoReplantPotato"] = 1
  183. usr["setting_autoReplantCarrot"] = 1
  184.  
  185. usr["main_leftGUIID"] = "Forest" -- Which display is used on the left status screen.
  186. usr["main_rightGUIID"] = "Main"  -- Which display is used on the right main screen.
  187.  
  188. -- Message Logs
  189. usr["log_01"] = "The player starts his career."
  190. usr["log_02"] = ""
  191. usr["log_03"] = ""
  192. usr["log_04"] = ""
  193. usr["log_05"] = ""
  194. usr["log_06"] = ""
  195. usr["log_07"] = ""
  196. usr["log_08"] = ""
  197. usr["log_09"] = ""
  198. usr["log_10"] = ""
  199. usr["log_11"] = ""
  200. usr["log_12"] = ""
  201. usr["log_13"] = ""
  202. usr["log_14"] = ""
  203. usr["log_15"] = ""
  204. usr["log_16"] = ""
  205.  
  206. -- Shop Variables (prices, basically) Buy price = 100%, sell price = 20% (So basically numbers have to be dividable by 5)
  207. shop["sell_multiplier"]  = 0.2
  208. shop["resource_log"]     = 20    --
  209. shop["resource_stone"]   = 5     -- Sell stone for 1 coin each, basically.
  210. shop["resource_sapling"] = 20    -- Buy sapling for 20, sell logs for 4 each (5 for 20), should equal to an average profit.
  211. shop["resource_meatPig"] = 10    -- In case of emergencies, the player can buy food. Hopefully overpriced food.
  212. -- I need to try and find the balance between "don't make buying the player's main choice" and "don't make this a money farm by selling it" :T
  213.  
  214. msg["quitVillager"]  = "A villager has left"
  215. msg["quitLogger"]    = "A woodcutter has left"
  216. msg["quitMiner"]     = "A miner has left"
  217. msg["quitFarmer"]    = "A farmer has left"
  218. msg["quitRancher"]   = "A rancher has left"
  219. msg["quitArmy"]      = "A swordsman has left"
  220. msg["slainVillager"] = "A villager was slain"
  221. msg["slainLogger"]   = "A logger was slain"
  222. msg["slainMiner"]    = "A miner was slain"
  223. msg["slainFarmer"]   = "A farmer was slain"
  224. msg["slainRancher"]  = "A rancher was slain"
  225. msg["slainArmy"]     = "A swordsman was slain"
  226. msg["escapedAnimal"] = "Some animals have escaped"
  227. msg["deadCow"]       = "A cow has died"
  228. msg["deadSheep"]     = "A sheep has died"
  229. msg["deadChicken"]   = "A chicken has died"
  230. msg["deadPig"]       = "A pig has died"
  231.  
  232. msg["reasonHunger"]     = " due to lack of food."
  233. msg["reasonRaid"]       = " due to a raid."
  234. msg["reasonFoodPoison"] = " due to food poisoning"
  235. msg["reasonNoRanchers"] = " due to overworked ranchers"
  236.  
  237.  
  238. if term.isColor() == false then
  239.     print("Sorry, this program is only for use on Advanced Computers.")
  240.     print("Please consider upgrading!")
  241.     main["running"] = false
  242. end
  243.  
  244. local function loadGame()    -- TEXTY used as a base
  245.     local path = addSlashIfNeeded(shell.resolve(""))
  246.     if fs.exists(path.."LogBox.sav") then
  247.         h = fs.open(path.."LogBox.sav", "r")
  248.         while true do
  249.             data = h.readLine()
  250.             if data == nil then break end
  251.             usr = textutils.unserialize(h.readAll())
  252.         end
  253.         h.close()
  254.     -- Else, there is no save file.
  255.     -- Perhaps I should make the floppy disks the save items?
  256.     end
  257. end
  258.  
  259. local function writeFormatText(message) -- This will print text of a specific format onto the screen, making it easier for me to do colour things and such.
  260.  
  261.     --[[
  262.         SYNTAX IDEA II
  263.     "Welcome to the $5$&5&GRAND THING OF AWESOME$af$&af&!"
  264.     $af$ - Change background colour. "AF" will be combined into one colour.
  265.     &af& - Change text colour. "AF" will be combined into one colour.
  266.     Colour combinations support up to four colours currently.
  267.     ]]--
  268.  
  269.     local stringLength = string.len(message)
  270.     for i = 1, stringLength do
  271.         local char = string.sub(message, i, i)
  272.         if char == "&" then
  273.             local foundOtherSymbol = 0
  274.             local myColours = {}
  275.             local myIncrease = 0
  276.             myColours[1] = 0
  277.             myColours[2] = 0
  278.             myColours[3] = 0
  279.             myColours[4] = 0
  280.             while foundOtherSymbol == 0 do
  281.                 i = i + 1
  282.                 myIncrease = myIncrease + 1
  283.                 local char2 = string.sub(message, i, i)
  284.                 if char2 == "&" then
  285.                     foundOtherSymbol = 1
  286.                 elseif char2 == "0" then                        -- These are NOT the default colour codes, but CC's own colour codes!
  287.                     myColours[myIncrease] = colours.white
  288.                 elseif char2 == "1" then
  289.                     myColours[myIncrease] = colours.orange
  290.                 elseif char2 == "2" then
  291.                     myColours[myIncrease] = colours.magenta
  292.                 elseif char2 == "3" then
  293.                     myColours[myIncrease] = colours.lightBlue
  294.                 elseif char2 == "4" then
  295.                     myColours[myIncrease] = colours.yellow
  296.                 elseif char2 == "5" then
  297.                     myColours[myIncrease] = colours.lime
  298.                 elseif char2 == "6" then
  299.                     myColours[myIncrease] = colours.pink
  300.                 elseif char2 == "7" then
  301.                     myColours[myIncrease] = colours.grey
  302.                 elseif char2 == "8" then
  303.                     myColours[myIncrease] = colours.lightGrey
  304.                 elseif char2 == "9" then
  305.                     myColours[myIncrease] = colours.cyan
  306.                 elseif char2 == "a" then
  307.                     myColours[myIncrease] = colours.purple
  308.                 elseif char2 == "b" then
  309.                     myColours[myIncrease] = colours.blue
  310.                 elseif char2 == "c" then
  311.                     myColours[myIncrease] = colours.brown
  312.                 elseif char2 == "d" then
  313.                     myColours[myIncrease] = colours.green
  314.                 elseif char2 == "e" then
  315.                     myColours[myIncrease] = colours.red
  316.                 elseif char2 == "f" then
  317.                     myColours[myIncrease] = colours.black
  318.                 -- Else syntax be bork'd
  319.                 end
  320.             end
  321.             term.setFontColor(colours.combine(myColours[1] + myColours[2] + myColours[3] + myColours[4]) -- It only supports four
  322.         elseif char == "$" then
  323.             local foundOtherSymbol = 0
  324.             local myColours = {}
  325.             local myIncrease = 0
  326.             myColours[1] = 0
  327.             myColours[2] = 0
  328.             myColours[3] = 0
  329.             myColours[4] = 0
  330.             while foundOtherSymbol == 0 do
  331.                 i = i + 1
  332.                 myIncrease = myIncrease + 1
  333.                 local char2 = string.sub(message, i, i)
  334.                 if char2 == "&" then
  335.                     foundOtherSymbol = 1
  336.                 elseif char2 == "0" then                        -- These are NOT the default colour codes, but CC's own colour codes!
  337.                     myColours[myIncrease] = colours.white
  338.                 elseif char2 == "1" then
  339.                     myColours[myIncrease] = colours.orange
  340.                 elseif char2 == "2" then
  341.                     myColours[myIncrease] = colours.magenta
  342.                 elseif char2 == "3" then
  343.                     myColours[myIncrease] = colours.lightBlue
  344.                 elseif char2 == "4" then
  345.                     myColours[myIncrease] = colours.yellow
  346.                 elseif char2 == "5" then
  347.                     myColours[myIncrease] = colours.lime
  348.                 elseif char2 == "6" then
  349.                     myColours[myIncrease] = colours.pink
  350.                 elseif char2 == "7" then
  351.                     myColours[myIncrease] = colours.grey
  352.                 elseif char2 == "8" then
  353.                     myColours[myIncrease] = colours.lightGrey
  354.                 elseif char2 == "9" then
  355.                     myColours[myIncrease] = colours.cyan
  356.                 elseif char2 == "a" then
  357.                     myColours[myIncrease] = colours.purple
  358.                 elseif char2 == "b" then
  359.                     myColours[myIncrease] = colours.blue
  360.                 elseif char2 == "c" then
  361.                     myColours[myIncrease] = colours.brown
  362.                 elseif char2 == "d" then
  363.                     myColours[myIncrease] = colours.green
  364.                 elseif char2 == "e" then
  365.                     myColours[myIncrease] = colours.red
  366.                 elseif char2 == "f" then
  367.                     myColours[myIncrease] = colours.black
  368.                 -- Else syntax be bork'd
  369.                 end
  370.             end
  371.             term.setBackgroundColor(colours.combine(myColours[1] + myColours[2] + myColours[3] + myColours[4]) -- It only supports four
  372.         else
  373.             write(char)
  374.         end
  375.     end
  376. end
  377.  
  378. local function saveGame()    -- TEXTY used as a base here too
  379.     local path = addSlashIfNeeded(shell.resolve(""))
  380.     h = fs.open(path.."LogBox.sav")
  381.     h.writeLine(textutils.serialize(usr))
  382.     h.close()
  383. end
  384.  
  385. local function logAction(message) -- These support formatted text
  386.     usr["log_16"] = usr["log_15"]
  387.     usr["log_15"] = usr["log_14"]
  388.     usr["log_14"] = usr["log_13"]
  389.     usr["log_13"] = usr["log_12"]
  390.     usr["log_12"] = usr["log_11"]
  391.     usr["log_11"] = usr["log_10"]
  392.     usr["log_10"] = usr["log_09"]
  393.     usr["log_09"] = usr["log_08"]
  394.     usr["log_08"] = usr["log_07"]
  395.     usr["log_07"] = usr["log_06"]
  396.     usr["log_06"] = usr["log_05"]
  397.     usr["log_05"] = usr["log_04"]
  398.     usr["log_04"] = usr["log_03"]
  399.     usr["log_03"] = usr["log_02"]
  400.     usr["log_02"] = usr["log_01"]
  401.     usr["log_01"] = message
  402. end
  403.  
  404. local function determinePower(worker, type)         -- Plus side: This is all one function now
  405.     local_workersLeft = usr["worker_" .. worker]    -- Bad side: Now everything has a 2-3-4-5-6 power system.
  406.     local toolPower = 0                             -- Probably easy to fix, though.
  407.     if usr["tool_" .. type .. "Mythril"] >= workersLeft then
  408.         toolPower = toolPower + (6 * workersLeft)
  409.         workersLeft = 0
  410.         return choppingPower
  411.     else
  412.         toolPower = toolPower + (6 * usr["tool_" .. type .. "Mythril"])
  413.         workersLeft = workersLeft - usr["tool_" .. type .. "Mythril"])
  414.     end
  415.     if usr["tool_" .. type .. "Steel"] >= workersLeft then
  416.         toolPower = toolPower + (5 * workersLeft)
  417.         workersLeft = 0
  418.         return choppingPower
  419.     else
  420.         toolPower = toolPower + (5 * usr["tool_" .. type .. "Steel"])
  421.         workersLeft = workersLeft - usr["tool_" .. type .. "Steel"])
  422.     end
  423.     if usr["tool_" .. type .. "Iron"] >= workersLeft then
  424.         toolPower = toolPower + (4 * workersLeft)
  425.         workersLeft = 0
  426.         return choppingPower
  427.     else
  428.         toolPower = toolPower + (4 * usr["tool_" .. type .. "Iron"])
  429.         workersLeft = workersLeft - usr["tool_" .. type .. "Iron"])
  430.     end
  431.     if usr["tool_" .. type .. "Bronze"] >= workersLeft then
  432.         toolPower = toolPower + (3 * workersLeft)
  433.         workersLeft = 0
  434.         return choppingPower
  435.     else
  436.         toolPower = toolPower + (3 * usr["tool_" .. type .. "Bronze"])
  437.         workersLeft = workersLeft - usr["tool_" .. type .. "Bronze"])
  438.     end
  439.     if usr["tool_" .. type .. "Stone"] >= workersLeft then
  440.         toolPower = toolPower + (2 * workersLeft)
  441.         workersLeft = 0
  442.         return choppingPower
  443.     else
  444.         toolPower = toolPower + (2 * usr["tool_" .. type .. "Stone"])
  445.         workersLeft = workersLeft - usr["tool_" .. type .. "Stone"])
  446.     end
  447.  
  448. -- YEP THEY'RE CALL CALLED CHOPPINGPOWER
  449. -- TOTALLY NOT A COPY/PASTE OF THE FIRST WOODCUTTING ONE
  450.  
  451. local function doGameTick()                     -- Do an action every tick
  452.     if usr["building_treeFarm"] > 0 then        -- No point doing the thing if there's nothing there, is there?
  453.         if usr["farm_tree"] > 0 then            -- Do log chopping
  454.  
  455.             usr["hidden_logTick"] = usr["hidden_logTick"] + determinePower("logger", "axe")
  456.             while usr["hidden_logTick"] >= 24000 do
  457.                 usr["resource_log"] = usr["resource_log"] + 1
  458.                 usr["hidden_lastTree"] = usr["hidden_lastTree"] + 1
  459.                 usr["hidden_logTick"] = usr["hidden_logTick"] - 24000
  460.                 if usr["hidden_lastTree"] > 10 then
  461.                     usr["farm_tree"] = usr["farm_tree"] - 1
  462.                     usr["hidden_lastTree"] = 0
  463.                 elseif usr["hidden_lastTree"] > 4 then
  464.                     local randomVar = math.random(1,4)
  465.                     if randomVar == 1 then
  466.                         usr["farm_tree"] = usr["farm_tree"] - 1
  467.                         usr["hidden_lastTree"] = 0
  468.                     end
  469.                 end
  470.             end
  471.             -- Do sapling gathering. This is managed by farmers.
  472.             usr["hidden_saplingTick"] = usr["hidden_saplingTick"] + usr["worker_farmer"]
  473.             while usr["hidden_saplingTick"] >= 30000 do
  474.                 usr["resource_sapling"] = usr["resource_sapling"] + 1
  475.                 usr["hidden_saplingTick"] = usr["hidden_saplingTick"] - 30000
  476.             end
  477.         end
  478.     end
  479.     if usr["building_stoneMine"] > 0 then
  480.         usr["hidden_stoneTick"] = usr["hidden_stoneTick"] + determinePower("miner", "pickaxe")
  481.         while usr["hidden_stoneTick"] >= 24000 do
  482.             usr["hidden_stoneTick"] = usr["hidden_stoneTick"] - 24000
  483.             local rand = random(1,10)
  484.             if rand < 9 then -- Stone
  485.                 usr["resource_stone"] = usr["resource_stone"] + 1
  486.             else -- Rare Ores!
  487.                 local rand2 = random(1,100)
  488.                 if rand2 < 30  then    -- Coal
  489.                     local veinSize = random(1,6)
  490.                     usr["resource_coal"] = usr["resource_coal"] + veinSize
  491.                 elseif rand2 < 50 then -- Copper
  492.                     local veinSize = random(1,4)
  493.                     usr["resource_copper"] = usr["resource_copper"] + veinSize
  494.                 elseif rand2 < 70 then -- Tin
  495.                     local veinSize = random(1,4)
  496.                     usr["resource_tin"] = usr["resource_tin"] + veinSize
  497.                 elseif rand2 < 85 then -- Iron
  498.                     local veinSize = random(1,4)
  499.                     usr["resource_iron"] = usr["resource_iron"] + veinSize
  500.                 elseif rand2 < 94 then -- Gold
  501.                     local veinSize = random(1,2)
  502.                     usr["resource_gold"] = usr["resource_gold"] + veinSize
  503.                 elseif rand2 < 96 then -- Sapphire
  504.                     usr["resource_sapphire"] = usr["resource_sapphire"] + 1  -- For sapphires, emeralds and rubies, you only ever get one per mine.
  505.                 elseif rand2 < 98 then -- Emerald
  506.                     usr["resource_emerald"] = usr["resource_emerald"] + 1    -- They're rare and worth a lot of gold!
  507.                 else                   -- Ruby
  508.                     usr["resource_ruby"] = usr["resource_ruby"] + 1          -- They may also have other uses.
  509.                 end
  510.             end
  511.         end
  512.     end
  513.     if usr["building_cropFarm"] > 0 then
  514.         if usr["farm_wheatSeed"] > 0 then
  515.             usr["hidden_wheatTick"] = usr["hidden_wheatTick"] + usr["farm_wheatSeed"]
  516.             while usr["hidden_wheatTick"] > 6000 do
  517.                 usr["farm_wheatSeed"] = usr["farm_wheatSeed"] - 1
  518.                 usr["farm_wheatCrop"] = usr["farm_wheatCrop"] + 1
  519.                 usr["hidden_wheatTick"] = usr["hidden_wheatTick"] - 6000
  520.             end
  521.         end
  522.         if usr["farm_melonSeed"] > 0 then
  523.             usr["hidden_melonTick"] = usr["hidden_melonTick"] + usr["farm_melonSeed"]
  524.             while usr["hidden_melonTick"] > 4000 do
  525.                 usr["farm_melonSeed"] = usr["farm_melonSeed"] - 1
  526.                 usr["farm_melonCrop"] = usr["farm_melonCrop"] + 1 -- Melon multi-drops will be managed on HARVEST
  527.                 usr["hidden_melonTick"] = usr["hidden_melonTick"] - 4000
  528.             end
  529.         end
  530.         if usr["farm_potatoSeed"] > 0 then
  531.             usr["hidden_potatotTick"] = usr["hidden_potatoTick"] + usr["farm_potatoSeed"]
  532.             while usr["hidden_potatoTick"] > 8000 do
  533.                 usr["farm_potatoSeed"] = usr["farm_potatoSeed"] - 1
  534.                 usr["farm_potatoCrop"] = usr["farm_potatoCrop"] + 1
  535.                 usr["hidden_potatoTick"] = usr["hidden_potatoTick"] - 8000
  536.             end
  537.         end
  538.         if usr["farm_carrotSeed"] > 0 then
  539.             usr["hidden_carrotTick"] = usr["hidden_carrotTick"] + usr["farm_carrotSeed"]
  540.             while usr["hidden_carrotTick"] > 6000 do
  541.                 usr["farm_carrotSeed"] = usr["farm_carrotSeed"] - 1
  542.                 usr["farm_carrotCrop"] = usr["farm_carrotCrop"] + 1
  543.                 usr["hidden_carrotTick"] = usr["hidden_carrotTick"] - 6000
  544.             end
  545.         end
  546.         if usr["farm_cowTick"] > 0 then
  547.             usr["farm_cowTick"] = usr["farm_cowTick"] - 1  -- Most of the animalTick stuff is managed elsewhere
  548.         end
  549.         if usr["farm_pigTick"] > 0 then
  550.             usr["farm_pigTick"] = usr["farm_pigTick"] - 1
  551.         end
  552.         if usr["farm_chickenTick"] > 0 then
  553.             usr["farm_chickenTick"] = usr["farm_chickenTick"] - 1
  554.         end
  555.         if usr["farm_sheepTick"] > 0 then
  556.             usr["farm_sheepTick"] = usr["farm_sheepTick"] - 1
  557.         end
  558.         if usr["worker_farmer"] > 0 then
  559.             if usr["farm_wheatCrop"] > 0 or usr["farm_melonCrop"] > 0 or usr["farm_potatoCrop"] > 0 or usr["farm_carrotCrop"] > 0 then
  560.                 usr["hidden_harvestTick"] = usr["hidden_harvestTick"] + determinePower("farmer", "hoe")
  561.                 while usr["hidden_harvestTick"] > 2000 do
  562.                     usr["hidden_harvestTick"] = usr["hidden_harvestTick"] - 2000
  563.                     local randomize = random(0, usr["farm_wheatCrop"] + usr["farm_melonCrop"] + usr["farm_potatoCrop"] + usr["farm_carrotCrop"])
  564.                     if randomize < usr["farm_wheatCrop"] then
  565.                         -- Harvest wheat
  566.                         usr["farm_wheatCrop"] = usr["farm_wheatCrop"] - 1
  567.                         local randomize = random(1,10)
  568.                         if randomize < 7 then  -- 1, 2, 3, 4, 5, 6
  569.                             usr["resource_wheatSeed"] = usr["resource_wheatSeed"] + 2
  570.                         elseif randomize < 10 then  -- 7, 8, 9
  571.                             usr["resource_wheatSeed"] = usr["resource_wheatSeed"] + 1
  572.                         end  -- Else, no seeds on 10.
  573.                         -- End result: 150% seed output, with 10% chance of no seeds. I like THIS system much better.
  574.                         -- Starting off with wheat might be tough though, so I need to make it worth it.
  575.                         usr["resource_wheatCrop"] = usr["resource_wheatCrop"] + 1
  576.                         if usr["setting_autoReplantWheat"] == 1 and usr["resource_wheatSeed"] > 0 then -- Can't auto replant if there's no seeds!
  577.                             usr["resource_wheatSeed"] = usr["resource_wheatSeed"] - 1
  578.                             usr["farm_wheatSeed"] = usr["farm_wheatSeed"] + 1
  579.                         end
  580.                     elseif randomize < usr["farm_wheatCrop"] + usr["farm_melonCrop"] then
  581.                         -- Harvest melons
  582.                         usr["farm_melonCrop"] = usr["farm_melonCrop"] - 1
  583.                         usr["resource_melonCrop"] = usr["resource_melonCrop"] + random(3,6)    -- Change this if balance happens
  584.                         if usr["setting_autoReplantMelon"] == 1 then
  585.                             if usr["resource_melonSeed"] > 0 then                              -- Seeds get used first
  586.                                 usr["resource_melonSeed"] = usr["resource_melonSeed"] - 1
  587.                                 usr["farm_melonSeed"] = usr["farm_melonSeed"] + 1
  588.                             else
  589.                                 usr["resource_melonCrop"] = usr["resource_melonCrop"] - 1      -- Melon crops can be turned into seeds
  590.                                 usr["farm_melonSeed"] = usr["farm_melonSeed"] + 1              -- Melon crop will never be below 3 here, so it works without an "if"
  591.                             end
  592.                         end
  593.                     elseif randomize < usr["farm_wheatCrop"] + usr["farm_melonCrop"] + usr["farm_potatoCrop"] then
  594.                         -- Harvest potatoes
  595.                         usr["farm_potatoCrop"] = usr["farm_potatoCrop"] - 1
  596.                         usr["resource_potato"] = usr["resource_potato"] + random(1,3)
  597.                         if usr["setting_autoReplantPotato"] == 1 then    -- Auto replant per crop type? May be useful.
  598.                             usr["resource_potato"] =  usr["resource_potato"] - 1
  599.                             usr["farm_potatoSeed"] = usr["farm_potatoSeed"] + 1
  600.                         end
  601.                     else
  602.                         -- Harvest carrots, basically works identical to potatoes
  603.                         usr["farm_carrotCrop"] = usr["farm_carrotCrop"] - 1
  604.                         usr["resource_carrot"] = usr["resource_carrot"] + random(1,3)
  605.                         if usr["setting_autoReplantCarrot"] == 1 then
  606.                             usr["resource_carrot"] =  usr["resource_carrot"] - 1
  607.                             usr["farm_carrotSeed"] = usr["farm_carrotSeed"] + 1
  608.                         end
  609.                     end
  610.                     -- Carrots and potatoes are much easier to manage than the other two so I might have to balance it or something
  611.                 end
  612.             end
  613.         end
  614.     end
  615.     if usr["building_animalFarm"] > 0 then
  616.         -- Is it me or can everything be done with only one rancher
  617.         -- Perhaps ranchers will determine the maximum allowed animals too or something.
  618.         if usr["farm_cow"] > 0 then
  619.             usr["hidden_cowFeedTick"] = usr["hidden_cowFeedTick"] + usr["farm_cow"]
  620.             while usr["hidden_cowFeedTick"] > 10000 do    -- 10,000 is a tentative amount.
  621.                 if usr["resource_wheatCrop"] > 0 then
  622.                     usr["resource_wheatCrop"] = usr["resource_wheatCrop"] - 1
  623.                 else
  624.                     logAction(msg["deadCow"] .. msg["reasonHunger"])
  625.                     usr["farm_cow"] = usr["farm_cow"] - 1
  626.                 end
  627.                 usr["hidden_cowFeedTick"] = usr["hidden_cowFeedTick"] - 10000
  628.             end
  629.             if usr["hidden_cowResourceTick"] < 16000 then  -- Cows do not produce milk when full. That makes no sense, but whatever~
  630.                 usr["hidden_cowResourceTick"] = usr["hidden_cowResourceTick"] + usr["farm_sheep"]
  631.             end
  632.         end
  633.         if usr["farm_pig"] > 0 then
  634.             usr["hidden_pigFeedTick"] = usr["hidden_pigFeedTick"] + usr["farm_pig"]
  635.             while usr["hidden_pigFeedTick"] > 10000 do    -- 10,000 is a tentative amount.
  636.                 if usr["resource_carrot"] > 0 then
  637.                     usr["resource_carrot"] = usr["resource_carrot"] - 1
  638.                 else
  639.                     logAction(msg["deadPig"] .. msg["reasonHunger"])
  640.                     usr["farm_pig"] = usr["farm_pig"] - 1
  641.                 end
  642.                 usr["hidden_pigFeedTick"] = usr["hidden_pigFeedTick"] - 10000
  643.             end
  644.         end
  645.         if usr["farm_chicken"] > 0 then
  646.             usr["hidden_chickenFeedTick"] = usr["hidden_chickenFeedTick"] + usr["farm_chicken"]
  647.             while usr["hidden_chickenFeedTick"] > 10000 do    -- 10,000 is a tentative amount.
  648.                 if usr["resource_melonSeed"] > 0 then
  649.                     usr["resource_melonSeed"] = usr["resource_melonSeed"] - 1
  650.                 elseif usr["resource_wheatSeed"] > 0 then
  651.                     usr["resource_wheatSeed"] = usr["resource_wheatSeed"] - 1
  652.                 else
  653.                     logAction(msg["deadChicken"] .. msg["reasonHunger"])
  654.                     usr["farm_chicken"] = usr["farm_chicken"] - 1
  655.                 end
  656.                 usr["hidden_chickenFeedTick"] = usr["hidden_chickenFeedTick"] - 10000
  657.             end
  658.         end
  659.         if usr["farm_sheep"] > 0 then
  660.             usr["hidden_sheepFeedTick"] = usr["hidden_sheepFeedTick"] + usr["farm_sheep"]
  661.             while usr["hidden_sheepFeedTick"] > 10000 do    -- 10,000 is a tentative amount.
  662.                 if usr["resource_wheatCrop"] > 0 then
  663.                     usr["resource_wheatCrop"] = usr["resource_wheatCrop"] - 1
  664.                 else
  665.                     logAction(msg["deadSheep"] .. msg["reasonHunger"])
  666.                     usr["farm_sheep"] = usr["farm_sheep"] - 1
  667.                 end
  668.                 usr["hidden_sheepFeedTick"] = usr["hidden_sheepFeedTick"] - 10000
  669.             end
  670.             if usr["hidden_sheepResourceTick"] < 8000 then  -- Sheep do not regrow wool when they already have wool
  671.                  usr["hidden_sheepResourceTick"] = usr["hidden_sheepResourceTick"] + usr["farm_sheep"]
  672.             end
  673.         end
  674.         if usr["worker_rancher"] > 0 then    -- This one can probably be done much better, in it's current state it only supports two animal resources!
  675.             if usr["hidden_sheepResourceTick"] >= 8000 or usr["hidden_cowResourceTick"] >= 16000 then   -- If there's something to harvest...
  676.                 usr["hidden_rancherHarvestTick"] = usr["hidden_rancherHarvestTick"] + usr["worker_rancher"]
  677.                 while usr["hidden_rancherHarvestTick"] > 4000 do
  678.                     usr["hidden_rancherHarvestTick"] = usr["hidden_rancherHarvestTick"] - 4000
  679.                     local randomize = random(0, usr["hidden_sheepResourceTick"] + usr["hidden_cowResourceTick"]) -- Yeah, this means cows get priority but whatever.
  680.                     if randomize < usr["hidden_sheepResourceTick"] then
  681.                         -- Harvest sheep
  682.                         if usr["hidden_sheepResourceTick"] >= 8000 then
  683.                             usr["hidden_sheepResourceTick"] = usr["hidden_sheepResourceTick"] - 8000
  684.                             usr["resource_wool"] = usr["resource_wool"] + random(1,3)
  685.                         else
  686.                             usr["hidden_cowResourceTick"] = usr["hidden_cowResourceTick"] - 16000
  687.                             usr["resource_milk"] = usr["resource_milk"] + 1
  688.                         end
  689.  
  690.                     else
  691.                         if usr["hidden_cowResourceTick"] >= 16000 then
  692.                             usr["hidden_cowResourceTick"] = usr["hidden_cowResourceTick"] - 16000
  693.                             usr["resource_milk"] = usr["resource_milk"] + 1
  694.                         else
  695.                             usr["hidden_sheepResourceTick"] = usr["hidden_sheepResourceTick"] - 8000
  696.                             usr["resource_wool"] = usr["resource_wool"] + random(1,3)
  697.                         end
  698.                     end
  699.                 end
  700.             end
  701.         end
  702.     end
  703.  
  704.  
  705.     -- Army stuff, once the army system finally gets finished.
  706.  
  707.  
  708.     if usr["worker_total"] > 0 then
  709.         usr["hidden_eatTick"] = usr["hidden_eatTick"] + usr["worker_total"]
  710.         while usr["hidden_eatTick"] > 1500 do -- 1 worker eats every 150 seconds.
  711.             if usr["resource_food"] > 0 then
  712.                 usr["resource_food"] = usr["resource_food"] - 1
  713.             else
  714.                 -- A random worker will quit
  715.                 local randomize = random(1, usr["worker_total"])
  716.                 if randomize < usr["worker_miner"] then
  717.                     usr["worker_miner"] = usr["worker_miner"] - 1
  718.                     usr["worker_total"] = usr["worker_total"] - 1
  719.                     logAction(msg["quitMiner"] + msg["reasonHunger"])
  720.                 elseif randomize < usr["worker_miner"] + usr["worker_farmer"] then
  721.                     usr["worker_farmer"] = usr["worker_farmer"] - 1
  722.                     usr["worker_total"] = usr["worker_total"] - 1
  723.                     logAction(msg["quitFarmer"] + msg["reasonHunger"])              
  724.                 elseif randomize < usr["worker_miner"] + usr["worker_farmer"] + usr["worker_rancher"] then
  725.                     usr["worker_rancher"] = usr["worker_rancher"] - 1
  726.                     usr["worker_total"] = usr["worker_total"] - 1
  727.                     logAction(msg["quitRancher"] + msg["reasonHunger"])
  728.                 elseif randomize < usr["worker_miner"] + usr["worker_farmer"] + usr["worker_rancher"] + usr["worker_logger"] then
  729.                     usr["worker_logger"] = usr["worker_logger"] - 1
  730.                     usr["worker_total"] = usr["worker_total"] - 1
  731.                     logAction(msg["quitLogger"] + msg["reasonHunger"])
  732.                 elseif randomize < usr["worker_villager"] + usr["worker_miner"] + usr["worker_farmer"] + usr["worker_rancher"] + usr["worker_logger"] then
  733.                     usr["worker_villager"] = usr["worker_villager"] - 1
  734.                     usr["worker_total"] = usr["worker_total"] - 1
  735.                     logAction(msg["quitVillager"] + msg["reasonHunger"])
  736.                 else
  737.                     usr["worker_army"] = usr["worker_army"] - 1
  738.                     usr["worker_total"] = usr["worker_total"] - 1
  739.                     logAction(msg["quitArmy"] + msg["reasonHunger"])
  740.                 end
  741.                 local escapedAnimal = 0
  742.                 while (usr["farm_pig"] + usr["farm_sheep"] + usr["farm_cow"] + usr["farm_chicken"]) / usr["worker_rancher"] > 1 do
  743.                     local randomize = random(1,usr["farm_pig"] + usr["farm_sheep"] + usr["farm_cow"] + usr["farm_sheep"])
  744.                     if randomize < usr["farm_pig"] then
  745.                         escapedAnimal = 1
  746.                         usr["farm_pig"] = usr["farm_pig"] - 1
  747.                     elseif randomize < usr["farm_sheep"] + usr["farm_pig"] then
  748.                         escapedAnimal = 1
  749.                         usr["farm_sheep"] = usr["farm_sheep"] - 1
  750.                     elseif randomize < usr["farm_cow"] + usr["farm_sheep"] + usr["farm_pig"] then
  751.                         escapedAnimal = 1
  752.                         usr["farm_cow"] = usr["farm_cow"] - 1
  753.                     else
  754.                         escapedAnimal = 1
  755.                         usr["farm_chicken"] = usr["farm_chicken"] - 1
  756.                     end
  757.                 end
  758.                 if escapedAnimal = 1
  759.                     logAction(msg["animalsEscaped"] .. msg["reasonNoRanchers"])
  760.                 end
  761.                 -- Check if this doesn't mess anything up after.
  762.             end
  763.             usr["hidden_eatTick"] = usr["hidden_eatTick"] - 1500
  764.         end
  765.     end
  766.     updateCounters()
  767. end
  768.  
  769. local function updateScreen()         -- Basically when the entire screen changes, make it visible and stuff.
  770. end
  771. local function updateCounters()       -- Pointless updating the entire screen when just a bunch of counters change.
  772. end
  773.  
  774. while main["running"] == true do
  775.     local event, param1, param2, param3 = os.pullEvent()
  776.     if event == "mouse_click" then
  777.         if param1 == 0 then                                         -- Left mouse button
  778.             if param2 >= 0 and param2 <= 1 and param3 == 0 then     -- (0-1, 0) - Left button for the Leftern GUI
  779.                 if usr["main_leftGUIID"] == "Forest" then             -- Forest > Mine > Farm > Ranch > Barracks
  780.                     usr["main_leftGUIID"] = "Barracks"
  781.                 elseif usr["main_leftGUIID"] == "Mine" then
  782.                     usr["main_leftGUIID"] = "Forest"
  783.                 elseif usr["main_leftGUIID"] == "Farm" then
  784.                     usr["main_leftGUIID"] = "Mine"
  785.                 elseif usr["main_leftGUIID"] == "Ranch" then
  786.                     usr["main_leftGUIID"] = "Farm"
  787.                 elseif usr["main_leftGUIID"] == "Barracks" then
  788.                     usr["main_leftGUIID"] = "Ranch"
  789.                 end
  790.                 updateScreen()
  791.             elseif param2 >= 7 and param2 <= 8 and param3 == 0 then -- (7-8, 0) - Right button for the Leftern GUI
  792.                 if usr["main_leftGUIID"] == "Forest" then             -- Forest > Mine > Farm > Ranch > Barracks
  793.                     usr["main_leftGUIID"] = "Mine"
  794.                 elseif usr["main_leftGUIID"] == "Mine" then
  795.                     usr["main_leftGUIID"] = "Farm"
  796.                 elseif usr["main_leftGUIID"] == "Farm" then
  797.                     usr["main_leftGUIID"] = "Ranch"
  798.                 elseif usr["main_leftGUIID"] == "Ranch" then
  799.                     usr["main_leftGUIID"] = "Barracks"
  800.                 elseif usr["main_leftGUIID"] == "Barracks" then
  801.                     usr["main_leftGUIID"] = "Forest"
  802.                 end
  803.                 updateScreen()
  804.             end
  805.         elseif param1 == 1 then       -- Right mouse button "Cancel"
  806.             -- stuff
  807.         end
  808.     elseif event == "timer" and param1 == main["timer"] then
  809.         -- Handle per-tick happenings
  810.         doGameTick()
  811.         updateCounters()
  812.         main["timer"] = os.startTimer(0.1)
  813.     end
  814. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement