Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tamagotchi v2.0 by Eshkation. Bugs or Ideias? Comment on topic!
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.newGame("@5087869")
- moveTime = os.time()
- username = "Eshkation" -- Put your name here!
- clickToHatch = 0
- clickToClear = 0
- level = 1
- petInfo = {mood = 100, hungry = 100, sleep = 100}
- petName = ""
- petResponses = {" looks quizically at you..."," starts hopping around!"," smiles slyly."," looks suspiciously at you.."," runs around really fast."," looks shocked!"," is not sure what to say.."," looks hungry. Uh..."," turns away dramatically!"," whispers a secret in your ear!"," stares blankly back."," considers what you said.."," doesn't reply."," yawns in response."," doesn't like the tone of your voice!"," smiles eagerly!"," paws at you playfully."," puts their paw on your shoulder and looks worried."," looks proud!"," electric shocks you!"," regrets what has been done..."," seems to beckon for you."," stares at you ominously."," whistles a cute tune!"," teaches you a trick!"," tells you you're their favorite!"," wonders what you're thinking about..."," cannot possibly consider that!"," spins in a circle!"," doesn't wish to reply at this time"," looks wistfully out the window."," shouts at the top of their lungs!"," rolls over."," just sits there and looks cute."," contemplates life."," wags their tail!"," whimpers in response."," rolls their eyes."," frowns thoughtfully."," giggles at what you said!"," laughs heartily!"," understands what you mean."," replies insightfully."," copies what you said!"," looks like they want to be petted!"," agrees wholeheartedly!"," disagrees somewhat..."}
- chat = {""}
- chatCount = 0
- defaultColor = 0
- removePetInfo = false
- sleep = false
- timing = {}
- actions = {clearPet = false}
- grow = 0
- poop = false
- system.bindMouse(username)
- Tamagotchis = {
- [1] = { -- Egg
- X = {365, 375, 385, 395, 405, 415, 355, 345, 425, 425, 335, 335, 435, 435, 435, 435, 325, 325, 325, 325, 335, 345, 425, 415, 355, 365, 375, 385, 395, 405, 405, 395, 385, 375, 375, 365, 365, 355, 355, 345, 335, 415, 405, 385, 395, 375, 365, 355, 345, 335, 425, 415, 405, 425, 415, 405, 395, 405, 395, 385, 395, 385, 375, 385, 375, 365};
- Y = {145, 145, 145, 145, 155, 165, 155, 165, 175, 185, 175, 185, 195, 205, 215, 225, 195, 205, 215, 225, 235, 245, 235, 245, 255, 255, 255, 255, 255, 255, 165, 165, 165, 165, 175, 175, 185, 185, 195, 195, 205, 175, 175, 175, 175, 185, 195, 205, 205, 215, 205, 205, 205, 215, 215, 215, 215, 225, 225, 225, 235, 235, 235, 245, 245, 245};
- body = {type = 12, color = 0x6B6B6B}
- };
- [2] = {
- X = {365, 395, 355, 405, 395, 385, 375, 365, 355, 355, 405, 405, 395, 385, 375, 365, 375, 385, 345, 355, 365, 415, 405, 395, 345, 355, 365, 375, 385, 395, 405, 415};
- Y = {145, 145, 155, 155, 155, 155, 155, 155, 165, 175, 165, 175, 175, 175, 175, 175, 165, 165, 185, 185, 185, 185, 185, 185, 195, 195, 195, 195, 195, 195, 195, 195};
- body = {type = 12, color = 0x404199};
- name = "Bubbly"
- };
- [2.1] = {
- X = {305, 315, 325, 335, 345, 355, 365, 295, 305, 375, 365, 355, 315, 315, 305, 295, 295, 295, 305, 315, 325, 335, 375, 345, 345, 345, 345, 385, 395, 405, 415, 425, 435, 435, 435, 445, 445, 435, 425, 415, 425, 445, 445, 435, 425, 415, 405, 395, 385, 375, 365, 355, 345, 335, 325, 315, 305, 295, 295, 405, 395, 385, 375, 365, 355, 375, 375, 415, 415};
- Y = {135, 135, 135, 145, 135, 135, 135, 145, 155, 145, 155, 165, 165, 175, 185, 195, 205, 215, 225, 225, 215, 215, 155, 175, 185, 195, 205, 155, 155, 155, 155, 165, 175, 185, 195, 205, 215, 225, 225, 225, 235, 235, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 235, 215, 225, 225, 225, 215, 235, 185, 195, 185, 195};
- body = {type = 12, color = 0x404199};
- name = "Dewgeel"
- };
- [3] = {
- X = {365, 375, 385, 395, 355, 355, 355, 375, 375, 365, 395, 395, 385, 365, 365, 385, 375, 385, 395, 395, 405, 405, 405, 415, 405, 415, 425};
- Y = {155, 155, 155, 155, 165, 175, 185, 165, 175, 175, 165, 175, 175, 185, 195, 185, 195, 195, 185, 195, 165, 175, 185, 185, 195, 195, 195};
- body = {type = 12, color = 0x1F8F38};
- name = "Squirm"
- };
- [3.1] = {
- X = {315, 325, 335, 345, 355, 365, 365, 365, 305, 305, 305, 335, 335, 355, 355, 325, 325, 375, 385, 385, 385, 375, 365, 365, 375, 355, 375, 365, 355, 345, 335, 335, 325, 315, 305, 295, 285, 275, 295, 295, 285, 275, 275, 265, 255, 255, 255, 245, 245, 245, 285, 275, 265, 255, 375, 365, 355, 335, 345, 325, 315, 315, 315, 325};
- Y = {105, 105, 115, 105, 105, 115, 125, 135, 115, 125, 135, 125, 135, 135, 145, 135, 145, 145, 155, 165, 175, 185, 195, 205, 215, 215, 225, 225, 225, 215, 215, 225, 225, 225, 225, 215, 205, 205, 135, 145, 145, 155, 165, 165, 175, 185, 195, 205, 215, 225, 225, 225, 225, 225, 175, 175, 175, 175, 175, 175, 185, 195, 205, 205};
- body = {type = 12, color = 0x1F8F38};
- name = "Froaklet"
- };
- [4] = {
- X = {335, 345, 355, 325, 335, 345, 365, 375, 385, 375, 365, 355, 345, 355, 365, 375, 385, 385, 335, 335, 345, 355, 365, 375, 345, 365};
- Y ={165, 165, 175, 175, 185, 185, 165, 165, 175, 185, 185, 195, 205, 205, 205, 205, 215, 225, 215, 225, 225, 225, 225, 225, 215, 215};
- body = {type = 12, color = 0xAFA800};
- name = "Sprout"
- };
- [4.1] = {
- X = {345, 335, 355, 365, 375, 385, 395, 405, 325, 315, 305, 295, 285, 285, 285, 405, 405, 295, 305, 315, 325, 325, 315, 375, 365, 365, 375, 385, 395, 395, 385, 295, 305, 355, 355, 335, 335, 355, 335, 365, 375, 325, 315, 335, 345, 355, 385, 305, 395, 395, 395, 395, 395, 295, 295, 295, 295, 295, 305, 385, 405, 405, 285, 285, 325, 325, 375, 375, 355, 395, 385, 375, 375, 365, 365, 355, 345, 335, 335, 325, 315, 305, 295};
- Y = {125, 125, 125, 115, 115, 125, 125, 115, 115, 115, 125, 125, 115, 125, 135, 125, 135, 135, 135, 135, 135, 125, 125, 125, 125, 135, 135, 135, 135, 145, 145, 145, 145, 135, 145, 135, 145, 155, 155, 165, 165, 165, 165, 175, 175, 175, 175, 175, 185, 195, 205, 215, 225, 185, 195, 205, 215, 225, 225, 225, 235, 245, 235, 245, 195, 205, 195, 205, 215, 245, 245, 235, 245, 245, 235, 235, 235, 235, 245, 245, 245, 245, 245};
- body = {type = 12, color = 0xAFA800};
- name = "Leafer"
- };
- [5] = {
- X = {355, 365, 375, 385, 395, 395, 395, 395, 395, 385, 375, 375, 365, 365, 355, 345, 345, 345, 345, 345, 385, 375, 375, 365, 355, 365, 355, 365, 375, 385};
- Y = {135, 135, 135, 135, 145, 155, 165, 175, 185, 175, 175, 185, 185, 175, 175, 175, 185, 145, 155, 165, 155, 155, 145, 145, 145, 155, 165, 165, 165, 165};
- body = {type = 12, color = 0x000642};
- name = "Glob"
- };
- [5.1] = {
- X = {315, 325, 335, 345, 355, 365, 375, 305, 295, 285, 285, 385, 395, 405, 405, 395, 385, 375, 375, 365, 355, 345, 335, 325, 315, 355, 335, 305, 295, 275, 275, 295, 285, 295, 265, 265, 265, 275, 285, 295, 305, 315, 325, 315, 325, 335, 345, 355, 345, 385, 375, 375, 365, 355, 385, 395, 405, 405, 395, 385, 375, 365, 385, 375, 365, 355, 345, 335, 325, 315, 305, 325, 315, 315, 305, 305, 315, 325, 335, 335, 345, 345, 345, 335, 355, 355, 365, 365, 375};
- Y = {125, 125, 125, 125, 125, 125, 125, 135, 145, 155, 165, 135, 135, 145, 155, 155, 155, 155, 145, 155, 155, 155, 155, 155, 155, 145, 145, 165, 175, 175, 185, 185, 195, 195, 185, 195, 205, 215, 215, 225, 225, 215, 205, 225, 225, 225, 225, 205, 215, 205, 215, 225, 225, 225, 225, 215, 205, 195, 195, 185, 175, 165, 195, 195, 195, 195, 195, 195, 195, 195, 195, 165, 165, 175, 175, 185, 185, 175, 175, 165, 165, 175, 185, 185, 165, 175, 175, 185, 185};
- body = {type = 12, color = 0x000642};
- name = "Clamshul"
- }}
- objects = {
- [1] = { -- poop
- X = {535, 535, 535, 545, 555, 545, 525, 525, 535, 545, 525, 515, 515, 555, 555, 555, 565, 565, 555, 555, 515, 515, 505, 505, 515, 515};
- Y = {215, 205, 195, 205, 215, 215, 205, 215, 225, 225, 225, 215, 225, 225, 175, 165, 155, 145, 135, 125, 165, 155, 145, 135, 125, 115};
- body = {type = 12, color = 0x231000}
- };
- [2] = { -- sleep
- X = {525, 535, 545, 555, 565, 555, 545, 535, 525, 535, 545, 555, 565, 495, 505, 515, 515, 505, 495, 505, 515};
- Y = {65, 65, 65, 65, 65, 75, 85, 95, 105, 105, 105, 105, 105, 125, 125, 125, 135, 145, 155, 155, 155};
- body = {type = 12, color = 0xB4B4B4}
- }}
- function getResponse(player,answer)
- table.insert(chat,1,string.format("%s<V>%s said:<N> %s\n",chat[1],player,answer))
- message = petResponses[math.random(#petResponses)]
- message = string.format("<V>%s<N>%s",petName,message)
- table.insert(chat,1,chat[1]..message.."\n")
- ui.addTextArea(2, "<P align ='center'> <font face='Soopafresh'> CHAT!</font> <P align ='left'> \n"..chat[1], nil, 590, 77, 200, nil, 0x324650, 0x000000, 1);
- chatCount = chatCount +1
- if player ~= "INFO" then
- setPetInfo("mood",-5)
- elseif chatCount == 8 then
- chat = {""}
- chatCound = 0
- end
- end
- function selectType(player)
- clearPath()
- if level == 1 then level = level+math.random(1,4) end
- petname = Tamagotchis[level].name
- if level == 2 or 3 or 4 or 5 then
- ui.addPopup(1, 2, string.format("A %s just hatched from the egg! \nWhat would you like to name your new %s?",petname,petname),player,300,200,200,200,true)
- timing = {poop = os.time(), sleep = os.time(), growUp = os.time(), delay = os.time()}
- end
- end
- function sendUI()
- ui.addTextArea(1, string.format("<P align='center'>| <A href ='event:Pokepet'>Poke</A> | <A href ='event:TalkWithPet'>Say something </A>| <A href ='event:releasePet'>Release pet</A> | <A href ='event:actions'>Actions</A> | <A href ='event:petInfo'>%s info</A> |",petName), nil, 5, 20, 790, nil, 0x324650, 0x000000, 1);
- end
- function setPetInfo(info,number)
- if petInfo[info] <= 100 and petInfo[info] > 0 then
- petInfo[info] = petInfo[info]-number
- end
- if petInfo[info] > 100 then petInfo[info] = 100 end
- end
- function eventTextAreaCallback(id, player, callback)
- ui.removeTextArea(4)
- if callback == "TalkWithPet" then
- ui.addPopup(2, 2, string.format("%s, talk with %s!",player,petName),player,300,200,200,200,true)
- elseif callback == "Pokepet" then
- mood = {0xAE0300,0x313DB6}
- ID = math.random(#mood)
- defaultColor = Tamagotchis[level].body.color
- Tamagotchis[level].body.color = mood[ID]
- if ID == 1 then setPetInfo("mood",10) end
- drawTamagotchi(Tamagotchis[level])
- Tamagotchis[level].body.color = defaultColor
- elseif callback == "releasePet" then
- ui.addPopup(3, 1, string.format("Do you want to release %s? %s will live freely in the wild for the rest of their years! Are you sure you want to release %s?",petName,petName,petName),player,300,200,200,nil,true)
- elseif callback == "actions" then
- ui.addTextArea(4, "<P align='center'><font face='Soopafresh'>Actions</font>\n<A href='event:clearPet'>Clear Tamagotchi!</A>\n-------------------\n<A href='event:petSleep'>Time to bed!</A>\n-------------------\n<A href='event:petFood'>Feed Tamagotchi!</A>", player, 7, 128, 100, nil, 0x324650, 0x000001, 1);
- elseif callback == "clearPet" and sleep == false then
- actions.clearPet = true
- elseif callback == "petFood" and sleep == false then
- setPetInfo("hungry",-20)
- elseif callback == "petSleep" and poop == false then
- sleep = true
- timing.sleep = os.time()
- drawObject(objects[2])
- elseif callback == "petInfo" then
- ui.addTextArea(3, string.format("<P align='center'><font face='Soopafresh'>Pet Info!</font><P aling='left'>\n• Happy: %s\n• Sleep: %s \n• Food: %s",petInfo.mood.."%", petInfo.hungry.."%", petInfo.sleep.."%"), nil, 7, 128, 100, nil, 0x324650, 0x000001, 1);
- removePetInfo = true
- end
- end
- function eventPopupAnswer(id,player,answer)
- if id == 1 then
- petName = answer
- sendUI()
- elseif id == 2 then
- getResponse(player,answer)
- elseif id == 3 then
- if answer == "yes" then
- ui.addPopup(4, 0, string.format("Goodbye forever %s! %s has gone off to forest with other %s!",petName,petName,Tamagotchis[level].name),player,300,200,200,nil,true)
- newTamagotchi()
- end
- end
- end
- function eventMouse(player,pX,pY)
- if pX > 100 and pX < 400 and pY > 100 and pY < 300 then
- if level == 1 then
- tfm.exec.displayParticle(5,pX,pY,math.random(-5,5),math.random(-5,5),0,0)
- clickToHatch = clickToHatch+1
- if clickToHatch == 20 then
- selectType(player)
- clickToHatch = 0
- end
- elseif actions.clearPet == true then
- for x = 4,1,-1 do tfm.exec.displayParticle(3,pX,pY,math.random(-5,5),math.random(-5,5),0,0) end
- clickToClear = clickToClear+1
- if clickToClear == 20 then
- clickToClear = 0
- clearObject()
- timing.poop = os.time()
- poop = false
- actions.clearPet = false
- end
- end
- end
- end
- function eventNewPlayer(player)
- sendUI()
- end
- function drawTamagotchi(pet)
- pos = math.random(-10,10)
- for id = #pet.X,1,-1 do
- tfm.exec.addPhysicObject(id, pet.X[id]+pos, pet.Y[id], pet.body)
- end
- end
- function drawObject(obj)
- for id = #obj.X,1,-1 do
- tfm.exec.addPhysicObject(id*100, obj.X[id], obj.Y[id], obj.body)
- end
- end
- function clearPath()
- for id = 300,1,-1 do
- tfm.exec.removePhysicObject(id)
- ui.removeTextArea(id)
- end
- end
- function clearObject()
- for id = 300,1,-1 do
- tfm.exec.removePhysicObject(id*100)
- end
- end
- function growPet()
- grow = grow+1
- if grow <= 1 then
- level = level+0.1
- ui.addPopup(4, 0, string.format("<P align='center'>%s is beginning to change! \n...\n......\n..........\n%s evolved into %s!",petName,petName,Tamagotchis[level].name),nil,300,200,200,nil,true)
- timing.growUp = os.time()
- else
- setBaby()
- end
- end
- function setBaby()
- ui.addPopup(4, 0, string.format("<P align='center'>%s has had a good life. But it's time for them to pass on. \n...\n......\n..........\n%s has changed back into an egg!",petName,petName),nil,300,200,200,nil,true)
- newTamagotchi()
- end
- function eventLoop()
- if moveTime < os.time()-5000 then
- drawTamagotchi(Tamagotchis[level])
- moveTime = os.time()
- if removePetInfo == true then ui.removeTextArea(3) end
- elseif level > 1 then
- if timing.poop < os.time()-120000 and poop == false then
- drawObject(objects[1])
- poop = true
- timing.poop = os.time()
- elseif timing.sleep < os.time()-30000 and sleep == true then
- sleep = false
- clearObject()
- print("<N>Hey! you pet is now awake!")
- setPetInfo("sleep",25)
- elseif timing.delay < os.time()-8000 then
- timing.delay = os.time()
- for info,id in pairs(petInfo) do
- setPetInfo(info,math.random(-10,10))
- end
- elseif timing.growUp < os.time()-300000 then
- growPet()
- end
- end
- end
- function newTamagotchi()
- clearPath()
- clearObject()
- level = 1
- grow = 0
- sleep = false
- drawTamagotchi(Tamagotchis[level])
- chat = {""}
- print("<N>Hey! This is an egg! Why don't you try click on it?")
- end
- newTamagotchi()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement