-- 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 -- Buttons Array local Buttons = {} local Cursor = nil function survival_inventory_init(e) -- 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 = 15, 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 = 15, 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 = 4, h = 4, 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" )) 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 --menu text plants TextColor(8,20,1,"Fibers "..math.floor(g_fiberscollected),10,255,10) TextColor(20,20,1,"Tubers "..math.floor(g_tuberscollected),10,255,10) TextColor(32,20,1,"Berries "..math.floor(g_berriescollected),10,255,10) TextColor(42,20,1,"Shrooms "..math.floor(g_mushroomscollected),10,255,10) --menu text water TextColor(8,28,1,"Water "..math.floor(g_watercollected),10,255,10) -- menu text minerals TextColor(20,36,1,"Iron "..math.floor(g_ironscollected),10,255,10) TextColor(8,36,1,"Flint "..math.floor(g_flintcollected),10,255,10) TextColor(32,36,1,"Copper "..math.floor(g_copperscollected),10,255,10) TextColor(43,36,1,"Lead "..math.floor(g_leadcollected),10,255,10) -- menu text Chems TextColor(8,52,1,"Sulphur "..math.floor(g_sulphurcollected),10,255,10) TextColor(20,52,1,"Saltpeter "..math.floor(g_saltpetercollected),10,255,10) TextColor(32,52,1,"Carbon "..math.floor(g_carboncollected),10,255,10) -- menu text wood TextColor(8,44,1,"Wood "..math.floor(g_woodcollected),10,255,10) TextColor(20,44,1,"Planks "..math.floor(g_planks_made),10,255,10) TextColor(32,44,1,"Logs "..math.floor(g_logs_made),10,255,10) -- menu text meat TextColor(20,28,1,"Meat "..math.floor(g_meatcollected),10,255,10) -- menu text Skins TextColor(32,28,1,"Hides "..math.floor(g_hidecollected),10,255,10) -- menu text tools TextColor(57,20,1,"Hammers Crafted "..math.floor(g_fhammer),10,255,10) TextColor(81,20,1,"Axe's Crafted "..math.floor(g_faxe),10,255,10) --menu text weapons and ammo TextColor(57,30,1,"Daggers Crafted "..math.floor(g_fdagger),10,255,10) TextColor(81,30,1,"Bows Crafted "..math.floor(g_ibow),10,255,10) TextColor(81,34,1,"Arrows Crafted "..math.floor(g_arrow),10,255,10) --menu text housing TextColor(57,45,1,"Shelters Crafted "..math.floor(g_shelter),10,255,10) TextColor(81,43,1,"Stove Crafted "..math.floor(g_cooker),10,255,10) TextColor(81,47,1,"Workbench Crafted "..math.floor(g_workbench),10,255,10) TextColor(57,51,1,"Furnace Crafted "..math.floor(g_furnace),10,255,10) TextColor(57,39,1,"Lathe Crafted "..math.floor(g_lathe),10,255,10) -- menu text food TextColor(57,57,1,"Berry pies crafted "..math.floor(g_berry_pie),10,255,10) TextColor(81,57,1,"Berry soup crafted "..math.floor(g_berry_soup),10,255,10) TextColor(57,61,1,"Meat Pies crafted "..math.floor(g_meat_pie),10,255,10) TextColor(81,61,1,"Meat soup crafted "..math.floor(g_meat_soup),10,255,10) -- menu text ingots TextColor(8,61,1,"Iron(i) "..math.floor(g_iingot),10,255,10) TextColor(19,61,1,"Lead(i) "..math.floor(g_lingot),10,255,10) TextColor(32,61,1,"Copper(i) "..math.floor(g_cingot),10,255,10) TextColor(43,61,1,"Steel(i) "..math.floor(g_singot),10,255,10) -- Advanced Weapons TextColor(64,75,1,"Pistols "..math.floor(g_pistol),10,255,10) TextColor(64,83,1,"Rifles "..math.floor(g_rifle),10,255,10) TextColor(82,75,1,"Pistol Ammo "..math.floor(g_pistol_ammo),10,255,10) TextColor(82,83,1,"Rifle Ammo "..math.floor(g_rifle_ammo),10,255,10) --menu text experience TextColor(95,5,1,""..math.floor(g_exp),10,255,10) -- Meds TextColor(10,75,1,"Bandages "..math.floor(g_bandages),10,255,10) TextColor(10,83,1,"Medipacks "..math.floor(g_medipack),10,255,10) TextColor(30,75,1,"Antidote "..math.floor(g_antidote),10,255,10) TextColor(30,83,1,"Boosters "..math.floor(g_booster),10,255,10) 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