Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- sides={"top","bottom","back","front","left","right"}
- typeEffectiv= {{1,2,1,1,0.5,0.5,0.5,0.5,2,1,1,1,0.5,2,1,0.5,1},{1,0.5,1,1,0.5,1,1,2,1,1,1,1,1,2,1,0.5,1},{1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,0.5,1},{1,1,0.5,0.5,1,1,2,1,0.5,0,1,1,1,1,1,1,2},{0.5,2,1,1,1,1,0.5,0,1,1,2,2,0.5,0.5,2,2,1},{2,1,0.5,1,1,0.5,1,1,2,1,2,1,1,1,0.5,2,0.5},{2,1,1,0.5,2,1,1,1,2,1,1,1,1,1,0.5,0.5,1},{1,0.5,1,1,1,1,1,2,1,1,1,0,1,2,1,0.5,1},{0.5,1,0.5,1,1,0.5,0.5,1,0.5,2,1,1,0.5,1,2,0.5,2},{0.5,1,1,2,1,2,0,1,0.5,1,1,1,2,1,2,2,1},{1,1,2,1,1,0.5,2,1,2,2,0.5,1,1,1,1,0.5,0.5},{1,1,1,1,1,1,1,0,1,1,1,1,1,1,0.5,0.5,1},{1,1,1,1,1,1,1,0.5,2,0.5,1,1,0.5,1,0.5,0,1},{1,0,1,1,2,1,1,1,1,1,1,1,2,0.5,1,0.5,1},{2,1,1,1,0.5,2,2,1,1,0.5,2,1,1,1,1,0.5,1},{1,1,1,0.5,1,0.5,1,1,1,1,2,1,1,1,2,0.5,0.5},{1,1,0.5,1,1,2,1,1,0.5,2,1,1,1,1,2,1,0.5}}
- pokeData={}
- battle={}
- for i=1,6 do if peripheral.getType(sides[i]) == "modem" then w=peripheral.wrap(sides[i]) end end
- for i=1,6 do if peripheral.getType(sides[i]) == "chat" then c=peripheral.wrap(sides[i]) end end
- function fileToTable(file)
- if fs.exists(file)~=true then
- print("file"..file.." not found")
- return(false)
- end
- fp=fs.open(file,"r")
- line={}
- i=1
- line[i]=fp.readLine()
- if line[i]==nil then return(false) end
- while line[i]~=nil do
- i=i+1
- line[i]=fp.readLine()
- end
- return(line)
- end
- function resetPokemon()
- shell.run("rm myPokemon")
- shell.run("rm pokeList")
- shell.run("pastebin get 4c40MLFT pokeList")
- term.clear()
- term.setCursorPos(1,1)
- print("avarible Pokemon:")
- pokeBase=fileToTable("pokeList")
- i=1
- while pokeBase[i]~=nil do
- print(tostring((i+14)/15).." "..pokeBase[i])
- i=i+15
- end
- fp=fs.open("myPokemon","w")
- i=io.read()
- i=tonumber((i)-1)*15
- pokeData["name"]=pokeBase[i+1]
- pokeData["type1"]=pokeBase[i+2]
- pokeData["type2"]=pokeBase[i+3]
- pokeData["attack1"]=pokeBase[i+4]
- pokeData["attack2"]=pokeBase[i+5]
- pokeData["attack3"]=pokeBase[i+6]
- pokeData["attack4"]=pokeBase[i+7]
- pokeData["hpMax"]=tonumber(pokeBase[i+8])
- pokeData["hpBase"]=tonumber(pokeBase[i+9])
- pokeData["attack"]=tonumber(pokeBase[i+10])
- pokeData["defence"]=tonumber(pokeBase[i+11])
- pokeData["speed"]=tonumber(pokeBase[i+12])
- pokeData["owner"]=pokeBase[i+13]
- pokeData["level"]=tonumber(pokeBase[i+14])
- pokeData["exp"]=tonumber(pokeBase[i+15])
- fp.writeLine(textutils.serialize(pokeData))
- fp.close()
- end
- function printStats()
- term.clear()
- term.setCursorPos(1,1)
- print("Name: "..pokeData["name"])
- print("Type: "..pokeData["type1"].."/"..pokeData["type2"])
- print("HP: "..math.floor(100/pokeData["hpMax"]*pokeData["hpBase"]).."%/100% "..pokeData["hpBase"].."HP/"..pokeData["hpMax"].."HP")
- print("Level: "..pokeData["level"])
- print("Taste Drücken zum fortfahren")
- os.pullEvent("key")
- end
- function getData()
- fp=fs.open("myPokemon","r")
- pokeData=textutils.unserialize(fp.readLine())
- fp.close()
- end
- function saveData()
- fp=fs.open("myPokemon","w")
- fp.writeLine(textutils.serialize(pokeData))
- fp.close()
- end
- if fs.exists("myPokemon")==false then
- resetPokemon()
- end
- if fs.exists("attacks")==false then
- shell.run("pastebin get cmPKgDsi attacks")
- end
- shell.run("rm attacks")
- shell.run("pastebin get cmPKgDsi attacks")
- shell.run("attacks")
- function attack()
- term.clear()
- term.setCursorPos(1,1) term.write(battle["pokeData1"]["name"].." "..math.floor(100/battle["pokeData1"]["hpMax"]*battle["pokeData1"]["hpBase"]).."%/100% HP")
- term.setCursorPos(1,2) term.write(battle["pokeData2"]["name"].." "..math.floor(100/battle["pokeData2"]["hpMax"]*battle["pokeData2"]["hpBase"]).."%/100% HP")
- term.setCursorPos(1,3) term.write("1 "..pokeData["attack1"])
- term.setCursorPos(1,4) term.write("2 "..pokeData["attack2"])
- term.setCursorPos(1,5) term.write("3 "..pokeData["attack3"])
- term.setCursorPos(1,6) term.write("4 "..pokeData["attack4"])
- term.setCursorPos(1,7)
- action=read()
- if action=="1" then battle["attack"..tostring(battleId)]=pokeData["attack1"] end
- if action=="2" then battle["attack"..tostring(battleId)]=pokeData["attack2"] end
- if action=="3" then battle["attack"..tostring(battleId)]=pokeData["attack3"] end
- if action=="4" then battle["attack"..tostring(battleId)]=pokeData["attack4"] end
- end
- function setStats()
- if battle["pokeData1"]["speed"]>=battle["pokeData1"]["speed"] then
- attacks[battle["attack1"]]()
- pokeDataMem=pokeData1
- pokeData1=pokeData0
- pokeData0=pokeDataMem
- attacks[battle["attack0"]]()
- pokeDataMem=pokeData1
- pokeData1=pokeData0
- pokeData0=pokeDataMem
- else
- end
- end
- function fight()
- print("Bitte warten")
- rednet.broadcast(textutils.serialize(battle))
- id, message = rednet.receive()
- if textutils.unserialize(message)~=nil then
- battle=textutils.unserialize(message)
- if battleId==1 then attack() setStats() end
- if battleId==0 then attack() end
- end
- end
- function sendRequest()
- term.clear()
- print("Warte auf Annahme")
- battle["pokeData1"]=pokeData
- battleId=1
- while true do
- fight()
- end
- end
- function waitForRequest()
- term.clear()
- print("Warte auf Anfrage")
- battleId=0
- id, message = rednet.receive()
- if textutils.unserialize(message)~=nil then
- battle=textutils.unserialize(message)
- battle["pokeData2"]=pokeData
- if battleId==1 then attack() setStats() end
- if battleId==0 then attack() end
- end
- while true do
- fight()
- end
- end
- getData()
- function menu()
- term.clear()
- term.setCursorPos(1,3) term.write("1 Kampanfrage senden")
- term.setCursorPos(1,4) term.write("2 Auf Kampf anfrage warten")
- term.setCursorPos(1,5) term.write("3 Resette Pokemon")
- term.setCursorPos(1,6) term.write("4 Pokemon Info")
- term.setCursorPos(1,7)
- action=read()
- if action=="1" then sendRequest() end
- if action=="2" then waitForRequest() end
- if action=="3" then resetPokemon() end
- if action=="4" then printStats() end
- end
- while true do
- menu()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement