-- spawnable items shelter etc --entity_number1 = 45 --shelter --entity_number2 = 30 --workbench --entity_number3 = 30 --stove -- globals --Level one g_berriescollected=0 -- Add any new global items to this list g_tuberscollected=0 g_mushroomscollected=0 g_woodcollected=0 g_flintcollected=0 g_featherscollected=0 g_fiberscollected=0 g_watercollected=0 g_berry_pie=0 g_berry_soup=0 g_fdagger=0 g_faxe=0 g_fhammer=0 g_ibow=0 g_arrow=0 g_meatcollected=0 g_hidecollected=0 g_meat_pie=0 g_meat_soup=0 g_camp_fire=0 g_shelter=0 g_workbench=0 g_cooker=0 g_ironscollected=0 g_copperscollected=0 g_leadcollected=0 g_exp=0 g_planks_made=0 g_logs_made=0 g_sulphurcollected=0 g_saltpetercollected=0 g_carboncollected=0 g_furnace=0 g_lathe=0 g_iingot=0 --iron ingots g_lingot=0 --lead ingots g_cingot=0 -- copper ingots g_singot=0 -- steel ingot g_pistol=0 g_rifle=0 g_rifle_ammo=0 g_pistol_ammo=0 g_bandages=0 g_medipack=0 g_antidote=0 g_booster=0 local tSize = 2 -- Buttons Array local Buttons = {} local Cursor = nil function survival_inventory_init(e) if GetDeviceWidth() > 1600 then tSize = 1 end if GetDeviceWidth() > 2200 then tSize = 3 end -- Option Buttons as Button 1 - whatever local use = LoadImage( "scriptbank\\ss1\\use.png" ) Buttons = {['opt1'] = { x = 3, y = 59, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option1.png" )) }, ['opt2'] = { x = 14, y = 59, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option2.png" )) }, ['opt3'] = { x = 26, y = 59, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option3.png" )) }, ['exit'] = { x = 47, y = 69, w = 6, h = 15, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_ok.png" )) }, ['lathe'] = { x = 70, y = 38, w = 4, h = 2, s = CreateSprite( use ) }, ['furnace'] = { x = 70, y = 50, w = 4, h = 2, s = CreateSprite( use ) }, ['opt7'] = { x = 80, y = 3, w = 12, h = 5, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option7.png" )) }, -- Menu icons ['opt8'] = { x = 52, y = 18, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option8.png" )) }, ['opt9'] = { x = 52, y = 30, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option9.png" )) }, ['opt10'] = { x = 52, y = 43, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option10.png" )) }, ['opt11'] = { x = 52, y = 57, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option11.png" )) }, ['opt12'] = { x = 3, y = 18, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option12.png" )) }, ['opt13'] = { x = 3, y = 26, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option13.png" )) }, ['opt14'] = { x = 3, y = 34, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option14.png" )) }, ['wood'] = { x = 3, y = 42, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option15.png" )) }, ['opt16'] = { x = 14, y = 26, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option16.png" )) }, ['opt17'] = { x = 27, y = 26, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\b_option17.png" )) }, -- Menu icons end -- Use Buttons ['hammer'] = { x = 70, y = 19, w = 4, h = 2, s = CreateSprite( use ) }, ['axe'] = { x = 92, y = 19, w = 4, h = 2, s = CreateSprite( use ) }, ['dagger'] = { x = 70, y = 29, w = 4, h = 2, s = CreateSprite( use ) }, ['bow'] = { x = 92, y = 29, w = 4, h = 2, s = CreateSprite( use ) }, ['arrow'] = { x = 92, y = 33, w = 4, h = 2, s = CreateSprite( use ) }, ['byPie'] = { x = 70, y = 56, w = 4, h = 2, s = CreateSprite( use ) }, ['bySoup'] = { x = 92, y = 56, w = 4, h = 2, s = CreateSprite( use ) }, ['mtPie'] = { x = 70, y = 60, w = 4, h = 2, s = CreateSprite( use ) }, ['mtSoup'] = { x = 92, y = 60, w = 4, h = 2, s = CreateSprite( use ) }, ['shelter'] = { x = 70, y = 44, w = 4, h = 2, s = CreateSprite( use ) }, ['stove'] = { x = 92, y = 42, w = 4, h = 2, s = CreateSprite( use ) }, ['wkbench'] = { x = 92, y = 46, w = 4, h = 2, s = CreateSprite( use ) }, ['tubers'] = { x = 14, y = 18, w = 3, h = 3, s = CreateSprite( LoadImage( "scriptbank\\ss1\\tubers.png" )) }, ['berries'] = { x = 26, y = 18, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\berries.png" )) }, ['iron'] = { x = 14, y = 34, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\iron.png" )) }, ['copper'] = { x = 26, y = 34, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\copper.png" )) }, ['lead'] = { x = 37, y = 34, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\lead.png" )) }, ['planks'] = { x = 14, y = 42, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\planks.png" )) }, ['logs'] = { x = 26, y = 42, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\logs.png" )) }, ['chems'] = { x = 3, y = 50, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\chems.png" )) }, ['chems2'] = { x = 14, y = 50, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\chems2.png" )) }, ['chems3'] = { x = 26, y = 50, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\chems3.png" )) }, ['steel'] = { x = 37, y = 59, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\isteel.png" )) }, ['hndgun'] = { x = 57, y = 73, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\pistol.png" )) }, ['lnggun'] = { x = 57, y = 80, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\rifle.png" )) }, ['ammo1'] = { x = 77, y = 73, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\ammo.png" )) }, ['ammo2'] = { x = 77, y = 80, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\ammo.png" )) }, ['pistol'] = { x = 70, y = 74, w = 4, h = 2, s = CreateSprite( use ) }, ['pAmmo'] = { x = 92, y = 74, w = 4, h = 2, s = CreateSprite( use ) }, ['rifle'] = { x = 70, y = 82, w = 4, h = 2, s = CreateSprite( use ) }, ['rAmmo'] = { x = 92, y = 82, w = 4, h = 2, s = CreateSprite( use ) }, ['title'] = { x = 38, y = 0, w = 20, h = 10, s = CreateSprite( LoadImage( "scriptbank\\ss1\\title.png" )) }, ['shrooms'] = { x = 37, y = 18, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\mushroom.png" )) }, ['bandage'] = { x = 5, y = 73, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\dressing.png" )) }, ['medkit'] = { x = 5, y = 80, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\medikit.png" )) }, ['pill1'] = { x = 25, y = 73, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\pill1.png" )) }, ['pill2'] = { x = 25, y = 80, w = 4, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\pill2.png" )) }, ['dressing'] = { x = 18, y = 74, w = 4, h = 2, s = CreateSprite( use ) }, ['mediKit'] = { x = 18, y = 82, w = 4, h = 2, s = CreateSprite( use ) }, ['antidote'] = { x = 37, y = 74, w = 4, h = 2, s = CreateSprite( use ) }, ['booster'] = { x = 37, y = 82, w = 4, h = 2, s = CreateSprite( use ) }, ['recipes'] = { x = 4, y = 3, w = 13, h = 4, s = CreateSprite( LoadImage( "scriptbank\\ss1\\recipies.png" )) } } -- MouseCursor Cursor = CreateSprite( LoadImage ( "scriptbank\\ss1\\cursor.png" )) SetSpriteSize ( Cursor, 3 , -1 ) SetSpritePosition( Cursor, 200, 200 ) for _, v in pairs( Buttons ) do SetSpriteSize ( v.s, v.w , v.h ) SetSpritePosition ( v.s, 200, 200 ) end end local MouseActive = false local pressed = false local MouseDown = false local function ShowMouseCoords() -- for if you need to know them Prompt ("X :"..g_MouseX.." Y:"..g_MouseY) end local function MouseActivated() for _, v in pairs( Buttons ) do SetSpritePosition ( v.s, v.x, v.y ) end end local function MouseDeactivated() DeactivateMouse() MouseActive = false SetSpritePosition( Cursor, 200, 200 ) for _, v in pairs( Buttons ) do SetSpritePosition ( v.s, 200, 200 ) end end function survival_inventory_main( e ) if GetInKey() == "i" then if not pressed then pressed = true if MouseActive then MouseActive = false MouseDeactivated() else MouseActive = true ActivateMouse() MouseActivated() end end else pressed = false end if MouseActive then SetSpritePosition ( Cursor , g_MouseX ,g_MouseY ) if g_MouseClick == 1 then if not MouseDown then MouseDown = true MouseClicked( e ) end else MouseDown = false end Panel( 0, 0, 100, 88) --background Panel( 37, 1, 61, 10) --Top Panel( 1, 13, 49.5, 68) -- left Panel( 49.5, 13, 99, 68) -- right Panel( 55, 69, 99, 86) -- right bottom Panel( 1, 69, 45, 86) -- left bottom Panel( 78, 1, 98, 10) -- survival exp Panel( 1, 1, 21, 10)-- survival exp local function doText(x, y, name, value) TextColor( x, y, tSize, name .. " " .. math.floor( value ), 10, 255, 10 ) end --menu text plants doText( 8, 20, "Fibers", g_fiberscollected ) doText( 20, 20, "Tubers", g_tuberscollected ) doText( 32, 20, "Berries", g_berriescollected ) doText( 42, 20, "Shrooms", g_mushroomscollected ) --menu text water doText( 8, 28, "Water", g_watercollected ) -- menu text minerals doText( 20, 36, "Iron", g_ironscollected ) doText( 8, 36, "Flint", g_flintcollected ) doText( 32, 36, "Copper", g_copperscollected ) doText( 43, 36, "Lead", g_leadcollected ) -- menu text Chems doText( 8, 52, "Sulphur", g_sulphurcollected ) doText( 20, 52, "Saltpeter", g_saltpetercollected ) doText( 32, 52, "Carbon", g_carboncollected ) -- menu text wood doText( 8, 44, "Wood", g_woodcollected ) doText( 20, 44, "Planks", g_planks_made ) doText( 32, 44, "Logs", g_logs_made ) -- menu text meat doText( 20, 28, "Meat", g_meatcollected ) -- menu text Skins doText( 32, 28, "Hides", g_hidecollected ) -- menu text tools doText( 57, 20, "Hammers Crafted", g_fhammer ) doText( 81, 20, "Axe's Crafted", g_faxe ) --menu text weapons and ammo doText( 57, 30, "Daggers Crafted", g_fdagger ) doText( 81, 30, "Bows Crafted", g_ibow ) doText( 81, 34, "Arrows Crafted", g_arrow ) --menu text housing doText( 57, 45, "Shelters Crafted", g_shelter ) doText( 81, 43, "Stove Crafted", g_cooker ) doText( 81, 47, "Workbench Crafted", g_workbench ) doText( 57, 51, "Furnace Crafted", g_furnace ) doText( 57, 39, "Lathe Crafted", g_lathe ) -- menu text food doText( 57, 57, "Berry pies crafted", g_berry_pie ) doText( 81, 57, "Berry soup crafted", g_berry_soup ) doText( 57, 61, "Meat Pies crafted", g_meat_pie ) doText( 81, 61, "Meat soup crafted", g_meat_soup ) -- menu text ingots doText( 8, 61, "Iron(i)", g_iingot ) doText( 20, 61, "Lead(i)", g_lingot ) doText( 32, 61, "Copper(i)", g_cingot ) doText( 43, 61, "Steel(i)", g_singot ) -- Advanced Weapons doText( 64, 75, "Pistols", g_pistol ) doText( 64, 83, "Rifles", g_rifle ) doText( 82, 75, "Pistol Ammo", g_pistol_ammo ) doText( 82, 83, "Rifle Ammo", g_rifle_ammo ) --menu text experience doText( 95, 5, '', g_exp ) -- Meds doText( 10, 75, "Bandages", g_bandages ) doText( 10, 83, "Medipacks", g_medipack ) doText( 30, 75, "Antidote", g_antidote ) doText( 30, 83, "Boosters", g_booster ) else DeactivateMouse() end end function MouseClicked( e ) -- if GetTimer(e) > 999 then -- StartTimer(e) -- secs = secs + 1 -- if secs > 59 then -- mins = mins+1 -- secs = 0 -- if mins > 59 then -- hours = hours + 1 -- mins = 0 -- if hours > 23 then -- hours = 0 -- Text(50,10,3,hours..":"..mins..":"..secs) -- end -- end -- end -- end -- Handle Your mouse click events here local bt_clicked = 'none' for k, v in pairs( Buttons ) do if g_MouseX > v.x and g_MouseX < v.x + v.w and g_MouseY > v.y and g_MouseY < v.y + v.h then bt_clicked = k break end end if bt_clicked == 'none' then return end -- Handle your bt_clicked events here: bt_clicked option chosen if bt_clicked == 'opt1' then -- Button 1 clicked PromptDuration ("Menu 1",3000) elseif bt_clicked == 'opt2' then PromptDuration ("Menu 2",3000) elseif bt_clicked == 'opt3' then PromptDuration ("Menu 3",3000) elseif bt_clicked == 'exit' then MouseDeactivated() elseif bt_clicked == 'lathe' then PromptDuration ("Lathe",3000) elseif bt_clicked == 'furnace' then PromptDuration ("Furnace",3000) elseif bt_clicked == 'opt7' then PromptDuration ("Menu 6",3000) -- lines below are to tell GG what to actually do when the buttons are pressed e.g copy and paste a section and edit to suit -- use buttons elseif bt_clicked == 'hammer' and g_woodcollected >=1 and g_fiberscollected >=1 and g_flintcollected >=1 then AddPlayerWeapon(51) -- number of the Hammer entity goes here g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_flintcollected = g_flintcollected -2 --take items from inventory g_fhammer = g_fhammer + 1 -- adds crafted item to inventory for exp g_exp = g_exp + 10 --adds exp N.B you can change this to what you want depending on the complexity of each item PromptDuration ("You Crafted a Hammer",3000) elseif bt_clicked == 'axe' and g_woodcollected >=1 and g_fiberscollected >=1 and g_flintcollected >=1 then AddPlayerWeapon(48) -- number of the Axe entity goes here g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_flintcollected = g_flintcollected -2 --take items from inventory g_faxe = g_faxe + 1-- adds crafted item to inventory for exp g_exp = g_exp + 10 --adds exp PromptDuration ("You Crafted an Axe",3000) elseif bt_clicked == 'dagger' and g_woodcollected >=1 and g_fiberscollected >=1 and g_flintcollected >=1 then AddPlayerWeapon(47) -- number of the Dagger entity goes here g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_flintcollected = g_flintcollected -2 --take items from inventory g_fdagger = g_fdagger + 1-- adds crafted item to inventory for exp g_exp = g_exp + 10 --adds exp PromptDuration ("You Crafted a Dagger",3000) elseif bt_clicked == 'bow' and g_woodcollected >=1 and g_fiberscollected >=1 and g_flintcollected >=1 then AddPlayerWeapon(49) -- number of the Bow entity goes here g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_flintcollected = g_flintcollected -2 --take items from inventory g_ibow = g_ibow + 1-- adds crafted item to inventory for exp g_exp = g_exp + 10 --adds exp PromptDuration ("You Crafted a Bow",3000) elseif bt_clicked == 'arrow' and g_woodcollected >=1 and g_fiberscollected >=1 and g_flintcollected >=1 then AddPlayerAmmo(50) -- number of the Arrows entity goes here g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_flintcollected = g_flintcollected -2 --take items from inventory g_arrow = g_arrow + 1-- adds crafted item to inventory for exp g_exp = g_exp + 10 --adds exp PromptDuration ("You Crafted 10 Arrows",3000) elseif bt_clicked == 'byPie' and g_berriescollected >=1 and g_watercollected >=1 and g_tuberscollected >=1 then g_berriescollected = g_berriescollected - 2 -- subtract berries from inventory g_watercollected = g_watercollected -2 -- subtract water from inventory g_berry_pie = g_berry_pie +1 -- add amount of pies made to the inventory SetPlayerHealth(g_PlayerHealth+21)AddPlayerHealth (40) g_exp = g_exp + 10 --adds exp PromptDuration ("Eat Berry Pie",3000) -- Button 24 clicked =berry soup elseif bt_clicked == 'bySoup' and g_berriescollected >=1 and g_watercollected >=1 then g_berriescollected = g_berriescollected - 2 -- subtract berries from inventory g_watercollected = g_watercollected -2 -- subtract water from inventory g_berry_soup = g_berry_soup + 1 SetPlayerHealth(g_PlayerHealth+11)AddPlayerHealth (40) g_exp = g_exp + 10 --adds exp PromptDuration ("You eat some Berry Soup",3000) elseif bt_clicked == 'mtPie' and g_berriescollected >=1 and g_watercollected >=1 and g_tuberscollected >=1 and g_meatcollected >=1 then g_berriescollected = g_berriescollected - 2 -- subtract berries from inventory g_watercollected = g_watercollected -2 -- subtract water from inventory g_meatcollected = g_meatcollected -2 -- subtract meat from inventory SetPlayerHealth(g_PlayerHealth+41)AddPlayerHealth (40) g_exp = g_exp + 10 --adds exp PromptDuration ("You Eat Meat & Berry Pie",3000) elseif bt_clicked == 'mtSoup' and g_watercollected >=1 and g_meatcollected >=1 then g_watercollected = g_watercollected -2 -- subtract water from inventory g_meatcollected = g_meatcollected -2 -- subtract meat from inventory SetPlayerHealth(g_PlayerHealth+31)AddPlayerHealth (40) g_exp = g_exp + 10 --adds exp PromptDuration ("you eat Meat Soup",3000) elseif bt_clicked == 'shelter' and g_woodcollected >=1 and g_fiberscollected >=1 then g_woodcollected = g_woodcollected - 2 --take items from inventory g_fiberscollected = g_fiberscollected - 2 --take items from inventory g_shelter = g_shelter + 1 --add shelter to inventory g_exp = g_exp + 50 --adds exp PromptDuration ("You have crafted a shelter",3000) elseif bt_clicked == 'stove' and g_woodcollected >=1 and g_flintcollected >=1 then g_woodcollected = g_woodcollected - 2 --take items from inventory g_flintcollected = g_flintcollected - 2 --take items from inventory g_camp_fire = g_camp_fire + 1 -- add fire to inventory g_exp = g_exp + 50 --adds exp PromptDuration ("You have crafted a camp Fire ",3000) -- Button 29 clicked =workbench elseif bt_clicked == 'wkbench' and g_woodcollected >=1 and g_flintcollected >=1 and g_ironscollected >=1 then g_woodcollected = g_woodcollected - 2 --take items from inventory g_flintcollected = g_flintcollected - 2 --take items from inventory g_ironscollected = g_ironscollected - 4 --take items from inventory g_workbench = g_workbench + 1 g_exp = g_exp + 100 --adds exp PromptDuration ("You have crafted a Workbench",3000) elseif bt_clicked == 'pistol' then PromptDuration ("Pistol Used",3000) elseif bt_clicked == 'pAmmo' then PromptDuration ("Pistol Ammo Used",3000) elseif bt_clicked == 'rifle' then PromptDuration ("Rifle Used",3000) elseif bt_clicked == 'rAmmo' then PromptDuration ("Rifle Ammo Used",3000) elseif bt_clicked == 'dressing' then PromptDuration ("Dressing Used",3000) elseif bt_clicked == 'mediKit' then PromptDuration ("Medikit Used",3000) elseif bt_clicked == 'antidote' then PromptDuration ("Antidote Used",3000) elseif bt_clicked == 'booster' then PromptDuration ("Booster Used",3000) elseif bt_clicked == 'recipes' then PromptDuration ("Recipes",3000) end end