Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --functions that make coding easier
- function reset ()
- term.clear()
- term.setCursorPos(1,1)
- end
- function printColor (x,y)
- term.setTextColor(y)
- print(x)
- term.setTextColor(colors.white)
- end
- function line ()
- print("")
- end
- function tableCheck (inp,tab)
- n = table.maxn(tab)
- while n > 0 do
- if inp == tab[n] then return n end
- n = n-1
- end
- return false
- end
- --item variables
- item = {}
- itemDmg = {}
- itemDmgType = {}
- itemEquip = {}
- itemEquipDef = {}
- itemQuest = {}
- itemDesc = {}
- --item functions
- function itemRegister (name)
- item[table.maxn(item)+1] = name
- return
- end
- function itemRegisterId (name,id)
- item[id] = name
- return
- end
- function itemSetDmg (name,dmg)
- itemDmg[tableCheck(name,item)] = dmg
- return
- end
- function itemSetDmgType (name,dmgtype)
- itemDmgType[tableCheck(name,item)] = dmg
- return
- end
- function itemEquipable (name)
- itemEquip[tableCheck(name,item)] = true
- return
- end
- function itemQuest (name)
- itemQuest[tableCheck(name,item)] = true
- return
- end
- function itemSetDesc (name,desc)
- itemDesc[tableCheck(name,item)] = desc
- return
- end
- --world functions
- function worldGen (size)
- line()
- print("Generating world terrain...")
- local n = 100
- while n > 0 do
- worldBiome[n] = 0
- n = n-1
- end
- print("Adding snow...")
- snowside = math.random(1,2)
- if snowside == 1 then local start = 15 else local start = 75 end
- local n = 25
- while n > 0 do
- worldBiome[start+n] = 1
- n = n-1
- end
- print("Adding sand...")
- local xx = math.random(1,2)
- if xx == 1 then local start = 30 else start = 60 end
- local n = 10
- while n > 0 do
- worldBiome[n+start] = 2
- n = n-1
- end
- print("Generating hills...")
- local n = 100
- while n > 0 do
- local xx = math.random(1,6)
- if xx == 1 then worldHill[n] = 1 else worldHill[n] = 0 end
- n = n-1
- end
- print("Placing rocks in the dirt...")
- local n = 100
- while n > 0 do
- local xx = math.random(1,2)
- if worldBiome[n] == 1 and xx == 1 then worldIce[n] = 1 elseif xx == 2 then worldIce[n] = 0 end
- if worldBiome[n] ~= 2 and worldBiome[n] ~= 3 and worldBiome[n] ~= 4 and worldBiome[n] ~= 8 and worldBiome[n] ~= 9 and worldBiome[n] ~= 11 and worldBiome[n] ~= 13 and worldBiome[n] ~= 14 and worldBiome[n] ~= 15 then worldStone[n] = 1 elseif xx == 2 then worldStone[n] = 0 end
- n = n-1
- end
- print("Adding clay...")
- local n = 100
- while n > 0 do
- local xx = math.random(1,3)
- if worldBiome[n] == 0 or worldBiome == 12 then
- if xx == 1 then worldClay[n] = 1 else worldClay[n] = 0 end
- end
- n = n-1
- end
- print("Generating caves...")
- local n = 100
- while n > 0 do
- local xx = math.random(1,6)
- if worldBiome[n] == 4 or worldBiome[n] == 6 then
- if xx == 1 or xx == 2 then worldCave[n] = 1 else worldCave[n] = 0 end
- else
- if xx == 1 then worldCave[n] = 1 else worldCave[n] = 0 end
- end
- n = n-1
- end
- print("Generating jungle...")
- if snowside == 2 then local start = 10 else start = 70 end
- local n = 20
- while n > 0 do
- worldBiome[start+1] = 12
- n = n-1
- end
- print("Adding shinies...")
- local n = 100
- while n > 0 do
- local xx = math.random(1,3)
- if xx == 1 then
- if worldBiome[n] == 0 then worldCopper[n] = 1 end
- elseif xx == 2 then
- worldCopper[n] = 0
- end
- n = n-1
- end
- print("Creating dungeon...")
- local xx = math.random(1,2)
- if xx == 1 then
- local n = 100
- while n > 0 do
- if n == 8 then
- worldDungeon[n] = 1
- else
- worldDungeon[n] = 0
- end
- end
- elseif xx == 2 then
- local n = 100
- while n > 0 do
- if n == 92 then
- worldDungeon[n] = 1
- else
- worldDungeon[n] = 0
- end
- end
- end
- print("Making the world evil...")
- local xx = math.random(1,2)
- if snowside == 1 then local start = 10 else start = 70 end
- local n = 25
- while n > 0 do
- if xx == 1 then
- if worldBiome[start+n] == 1 then
- worldBiome[start+n] = 6
- elseif worldBiome[start+n] == 2 then
- worldBiome[start+n] = 8
- else
- worldBiome[start+n] = 3
- end
- elseif xx == 2 then
- if xx == 1 then
- if worldBiome[start+n] == 1 then
- worldBiome[start+n] = 7
- elseif worldBiome[start+n] == 2 then
- worldBiome[start+n] = 9
- else
- worldBiome[start+n] = 4
- end
- end
- end
- n = n-1
- end
- print("Growing cacti...")
- local n = 100
- while n > 0 do
- if worldBiome[n] == 2 or worldBiome[n] == 8 or worldBiome[n] == 9 then
- worldCacti[n] = 1
- else
- worldCacti[n] = 0
- end
- n = n-1
- end
- print("Planting trees...")
- local n = 100
- while n > 0 do
- if worldBiome[n] == 0 or worldBiome[n] == 1 or worldBiome[n] == 3 or worldBiome[n] == 4 or worldBiome[n] == 12 or worldBiome[n] == 13 then
- worldTrees[n] = 1
- else
- worldTrees[n] = 0
- end
- n = n-1
- end
- return
- end
- --world variables
- worldBiome = {}
- worldHill = {}
- worldStone = {}
- worldIce = {}
- worldClay = {}
- worldCave = {}
- worldCopper = {}
- worldDungeon = {}
- worldCacti = {}
- worldTrees = {}
- worldGrass = {}
- worldChest = {}
- playerLoc = 50
- --inventory variables
- inv = {}
- --inventory functions
- function invAdd (name,amount)
- inv[tableCheck(name,item)] = inv[tableCheck(name,item)]+amount
- return
- end
- function invTake (name,amount)
- if inv[tableCheck(name,item)] < amount then return false
- else
- inv[tableCheck(name,item)] = inv[tableCheck(name,item)]-amount
- return true
- end
- end
- function invGetAmout (name)
- return inv[tableCheck(name,item)]
- end
- --game
- function menu ()
- local cnf = 0
- reset()
- print("Choose a world size.")
- line()
- print("[1] Small")
- print("[2] Medium")
- print("[3] Large")
- line()
- term.setTextColor(colors.yellow)
- term.write("? ")
- term.setTextColor(colors.white)
- local input = read()
- if input == "1" or input == "2" or input == "3" then worldGen(input-1) game() end
- end
- function game ()
- while true do
- playerLoc = 50
- print(worldBiome[50])
- end
- end
- menu()
Advertisement
Add Comment
Please, Sign In to add comment