Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Bolodefchoco
- --2016
- data = {
- formats = {
- plants = "<N>Level required <G>: <VP>%s\n<N>Type <G>: <VP>%s\n\n<N>Harvest Time <G>: <VP>%s\n\n<N>Price <G>: <VP>$%s\n<N>Resale <G>: <VP>$%s",
- items = "<N>Level required <G>: <VP>%s\n<N>Type <G>: <VP>%s\n\n<N>Uses <G>: <VP>%s\n<N>Health <G>: <VP>-%s\n\n<N>Price <G>: <VP>$%s",
- expansions = "<N>Level required <G>: <VP>%s\n\n<N>Size <G>: <VP>+%spx\n<N>Gaps <G>: <VP>+%s\n\n<N>Price <G>: <VP>$%s",
- },
- types = {"Flowers","Fruits","Vegetables","Water pots","Rakes","Pesticides","Fertilizers","Bugs"},
- plants = {
- [1] = {
- --[[ Name ]] [1] = "Banana",
- --[[ Level ]] [2] = 25,
- --[[ Type ]] [3] = 2,
- --[[ Harvest Time ]] [4] = 4500,
- --[[ Price ]] [5] = 10,
- --[[ Resale ]] [6] = 15,
- --[[ Image ]] [7] = {"",400,60},
- },
- [2] = {
- [1] = "Grape",
- [2] = 35,
- [3] = 2,
- [4] = 1000,
- [5] = 15,
- [6] = 18,
- [7] = {"",400,60},
- },
- },
- items = {
- [1] = {
- --[[ Name ]] [1] = "Simple hoe",
- --[[ Level ]] [2] = 2,
- --[[ Type ]] [3] = 5,
- --[[ Uses ]] [4] = "Infinity",
- --[[ Health ]] [5] = 0,
- --[[ Price ]] [6] = 10,
- --[[ Image ]] [7] = {"",400,60},
- },
- [2] = {
- [1] = "Toxic Pesticide",
- [2] = 5,
- [3] = 6,
- [4] = 2,
- [5] = 5,
- [6] = 8,
- [7] = {"",400,60},
- },
- },
- expansions = {
- [1] = {
- --[[ Name ]] [1] = "Full size",
- --[[ Level ]] [2] = 35,
- --[[ Size ]] [3] = 800,
- --[[ Gaps ]] [4] = 6,
- --[[ Price ]] [5] = 80,
- --[[ Images ]] [7] = {"",400,60},
- },
- },
- }
- mice={}
- eventNewPlayer=function(n)
- if not mice[n] then
- mice[n] = {
- plants = {
- [1] = {"id","quantity","health"},
- },
- area = 800, -- u can buy + space
- planted = {
- [1] = {"id","speed","health","position"},
- }, -- Plants planteds
- coins = 25,
- water = 5, -- Grow up faster
- fertilizer = 3, -- Grow up faster x2
- hoe = 10, -- Clean an already used gap/earth
- pesticide = 0, -- Removes 50% of health but removes the bugs
- ladybug = 0, -- + expensive than pesticide, remove bugs, but keep healthy
- level = 0,
- sold = 0,
- shop_page = 1,
- shop_cat = "plants",
- image = "",
- }
- end
- system.bindMouse(n,true)
- system.bindKeyboard(n,79,true,true) -- O
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- getTime=function(time)
- if type(time)~="number" then return "?" end
- local second = time%60
- local minutes = time/60
- local minute = minutes%60
- local hours = minutes/60
- local hour = hours%24
- local day = hours/24
- return ("%dd %dh %dm %ds"):format(day,hour,minute,second)
- end
- ui.shop=function(n)
- tfm.exec.removeImage(mice[n].image)
- local where = data[mice[n].shop_cat][mice[n].shop_page]
- local formats = mice[n].shop_cat == "plants" and {where[2],where[3],getTime(where[4]),where[5],where[6]} or mice[n].shop_cat == "items" and {where[2],where[3],where[4],where[5],where[6]} or {where[2],where[3],where[4],where[5]}
- mice[n].image = tfm.exec.addImage(where[7][1],"!0",where[7][2],where[7][3],n)
- ui.addTextArea(0,"",n,155,45,490,330,0xDAFF,0xDAFF,1,true)
- ui.addTextArea(1,"",n,157,47,486,326,0x223040,0x223040,1,true)
- ui.addTextArea(2,"",n,160,50,480,320,0x1a2433,0x1a2433,1,true)
- ui.addTextArea(3,"",n,430,60,200,300,0x213147,0x213147,1,true)--Image
- ui.addTextArea(4,"<font size='13' letterSpacing='1'>"..data.formats[mice[n].shop_cat]:format(table.unpack(formats)),n,172,200,240,123,0x213147,0x213147,1,true)
- ui.addTextArea(5,"<p align='center'><B><BV><a href='event:close_shop'>Close</a>",n,170,340,240,20,0x213147,0x213147,1,true)
- ui.addTextArea(6,("<p align='center'><font size='12'><B><a href='event:shop_left'><BV><<</BV></a> <font size='15'>%s</font> <a href='event:shop_right'><BV>>></BV></a>"):format(where[1]),n,170,87,240,25,0x213147,0x213147,1,true)
- ui.addTextArea(7,("<font size='12'><N>Coins <G>: <V>$%s\n<N>Area <G>: <V>%spx\n<N>Level <G>: <V>%s"):format(mice[n].coins,mice[n].area,mice[n].level),n,170,130,240,52,0x213147,0x213147,1,true)
- ui.addTextArea(8,"",n,171,56,240,15,0x334b6c,0x334b6c,1,true)
- ui.addTextArea(9,("<p align='center'><font size='13'>%s<a href='event:plants'>Plants</a> <BL>- %s<a href='event:items'>Items</a> <BL>- %s<a href='event:expansions'>Expansions"):format(mice[n].shop_cat=="plants" and "<J>" or "<N>",mice[n].shop_cat=="items" and "<J>" or "<N>",mice[n].shop_cat=="expansions" and "<J>" or "<N>"),n,170,53,240,25,1,1,0,true)
- end
- eventKeyboard=function(n,k)
- if k == 79 then
- ui.shop(n)
- end
- end
- eventTextAreaCallback=function(i,n,c)
- local p = {};for v in c:gmatch("[^_]+") do p[#p+1]=v end
- if p[1] == "close" then
- if p[2] == "shop" then
- tfm.exec.removeImage(mice[n].image)
- mice[n].shop_cat = "plants"
- mice[n].shop_page = 1
- for i = 0,9 do
- ui.removeTextArea(i,n)
- end
- end
- end
- if p[1] == "plants" or p[1] == "items" or p[1] == "expansions" then
- mice[n].shop_cat = p[1]
- mice[n].shop_page = 1
- ui.shop(n)
- end
- if p[1] == "shop" then
- if p[2] == "left" or p[2] == "right" then
- mice[n].shop_page = (p[2]=="left" and (mice[n].shop_page>1 and mice[n].shop_page-1 or #data[mice[n].shop_cat]) or (mice[n].shop_page<#data[mice[n].shop_cat] and mice[n].shop_page+1 or 1))
- ui.shop(n)
- end
- end
- end
Add Comment
Please, Sign In to add comment