Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.unloadAPI("buttons")
- os.unloadAPI("gundata")
- os.loadAPI("buttons")
- os.loadAPI("gundata")
- log = fs.open("log", "w")
- gun_buttons = {}
- gun = nil
- ammo_buttons = {}
- ammo = nil
- print_button = nil
- function updatePrintButton()
- if (gun ~= nil and ammo ~= nil) then
- buttons.setColor(print_button, colors.white, colors.green)
- end
- end
- function pickGun(string)
- log.writeLine("Set gun " .. string)
- if gun ~= nil then
- buttons.setColor(gun_buttons[string], colors.white, colors.black)
- end
- gun = string
- buttons.setColor(gun_buttons[string], colors.white, colors.green)
- updatePrintButton()
- end
- function pickAmmo(string)
- log.writeLine("Set ammo "..string)
- if ammo ~= nil then
- buttons.setColor(ammo_buttons[string], colors.white, colors.black)
- end
- ammo = string
- buttons.setColor(ammo_buttons[string], colors.white, colors.green)
- updatePrintButton()
- end
- x = 3
- y = 2
- for gun in pairs(gundata.guns) do
- f = function()
- --log.writeLine("f was called")
- pickGun(gun)
- end
- gun_buttons[gun] = buttons.register(x, y, 10, 1, colors.white, colors.black, gun, f)
- y = y + 2
- end
- x = x + 13
- y = 2
- for ammo in pairs(gundata.ammo) do
- f = function()
- pickAmmo(ammo)
- end
- ammo_buttons[ammo] = buttons.register(x, y, 10, 1, colors.white, colors.black, ammo, f)
- y = y + 1
- end
- printGun = function()
- ok, result = commands.exec("give @p " .. gundata.guns[gun] .. " 1 0 ".. "{ammo:[0:{id:" .. gundata.ammo[ammo] .."s,Count:1b,Damage:0s}]}")
- if ok == false then
- log.writeLine("Print gun result: " .. result)
- end
- end
- x = x + 13
- y = 4
- print_button = buttons.register(x, y, 10, 3, colors.white, colors.red, "Make gun!", printGun)
- while true do
- buttons.draw()
- eventTable = {os.pullEvent()}
- buttons.event(eventTable)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement