-- LUA Script - precede every function and global member with lowercase name of script + '_main' g_foraged = g_foraged or {} local U = require "scriptbank\\utillib" -- added the other material items here if needed local equipttomake = 1 local equiptnames = { "a Bandage", "a Medipack", "an Antidote", "a Booster"} local fibersneeded = { 4, 6, 0, 0 } -- ingredients used to craft each item listed downwards local resinneeded = { 1, 1, 1, 1 } local mushroomsneeded = { 0, 0, 0, 2 } local carbonneeded = { 0, 1, 1, 1 } local waterneeded = { 0, 1, 1, 1 } function chemical_bench_init(e) Include( "utillib.lua" ) end local pressed = false function chemical_bench_main(e) --check player is near the funace if U.PlayerLookingNear( e, 100, 110 ) then U.SetList( g_foraged ) --show shop text TextCenterOnX( 50, 59, 1, "Press 1 ~ " .. #equiptnames .. " to select the Equiptment to craft" ) TextCenterOnX( 50, 62, 1, "Press E to Craft " .. equiptnames[ equipttomake ] ) --show how much player has in inventory TextCenterOnX( 50, 65, 1, "No of Fibers = " .. U.HaveAmount( 'Fibers' ) .. " No of Resin = " .. U.HaveAmount( 'Resin' ) .. " No of Mushrooms = " .. U.HaveAmount( 'Shrooms' ) .. " No of Carbon = " .. U.HaveAmount( 'Carbon' ) .. " No of Water = " .. U.HaveAmount( 'Water') ) --check player presses a number key and it corresponds to our items above local key = g_Scancode - 1 -- scancode for key '1' is 2 -- handle number pad, note this probably doesn't work on all keyboards if key > 77 then key = key - 77 elseif key > 73 then key = key - 73 + 4 elseif key > 69 then key = key - 69 + 7 end if key > 0 and key <= #equiptnames then equipttomake = key end --find out if player has enough of each material seperately local havefibers = U.HaveEnough( 'Fibers', fibersneeded[ equipttomake ] ) local haveresin = U.HaveEnough( 'Resin', resinneeded[ equipttomake ] ) local havemushrooms = U.HaveEnough( 'Shrooms', mushroomsneeded[ equipttomake ] ) local havecarbon = U.HaveEnough( 'Carbon', carbonneeded[ equipttomake ] ) local havewater = U.HaveEnough( 'Water', waterneeded[ equipttomake ] ) --now we will show number in red if player doesn't have enough if havefibers then TextCenterOnX( 50, 68, 1, fibersneeded[ equipttomake ] ) else TextCenterOnXColor( 50, 68, 1, fibersneeded[ equipttomake ], 255, 0, 0) end TextCenterOnX(50, 71, 1, "Fibers required") if haveresin then TextCenterOnX( 50, 74, 1, resinneeded[ equipttomake ] ) else TextCenterOnXColor( 50, 74, 1, resinneeded[ equipttomake ], 255, 0, 0 ) end TextCenterOnX( 50, 77, 1, "Resin required" ) if havemushrooms then TextCenterOnX( 50, 80, 1, mushroomsneeded[ equipttomake ] ) else TextCenterOnXColor( 50, 80, 1, mushroomsneeded[ equipttomake ], 255, 0, 0 ) end TextCenterOnX( 50, 83, 1, "Mushrooms required" ) if havecarbon then TextCenterOnX( 50, 86, 1, carbonneeded[ equipttomake ] ) else TextCenterOnXColor( 50, 86, 1, carbonneeded[ equipttomake ], 255, 0, 0 ) end TextCenterOnX( 50, 89, 1, "Carbon required" ) if havewater then TextCenterOnX( 50, 92, 1, waterneeded[ equipttomake ] ) else TextCenterOnXColor( 50, 92, 1, waterneeded[ equipttomake ], 255, 0, 0 ) end TextCenterOnX( 50, 95, 1, "Water required" ) --if player presses E to craft if g_KeyPressE == 1 then if not pressed then pressed = true --not enough materials if havesplate and havesulphur and havesaltpeter and havecarbon then PlaySound( e, 1 ) U.ChangeAmount( 'Fiber', -fibersneeded[ equipttomake ] ) U.ChangeAmount( 'Resin', -resinneeded[ equipttomake ] ) U.ChangeAmount( 'Shrooms', -mushroomsneeded[ equipttomake ] ) U.ChangeAmount( 'Carbon', -carbonneeded[ equipttomake ] ) U.ChangeAmount( 'Water', -waterneeded[ equipttomake ] ) local equiptName = equiptnames[ equipttomake ] PromptDuration( "You Crafted a " .. equiptName, 2000 ) if equiptName == "a Bandage" then U.ChangeAmount( 'Bandages', 1 ) g_exp = g_exp + 200 elseif equiptName == "a Medipack" then U.ChangeAmount( 'Medipacks', 1 ) g_exp = g_exp + 400 elseif equiptName == "an Antidote" then U.ChangeAmount( 'Antidote', 1 ) g_exp = g_exp + 300 elseif equiptName == "a Booster" then U.ChangeAmount( 'Boosters', 1 ) g_exp = g_exp + 300 end else PromptDuration( "You do not have enough Items to craft " .. equiptnames[ equipttomake ], 2000 ) end end else pressed = false end end end