-
Notifications
You must be signed in to change notification settings - Fork 9
Mod example: a simple button
AUTOMATIC1111 edited this page Mar 19, 2018
·
1 revision
This mod draws a button with text "Click me!" in the upper left corner of new game screen. When user clicks the button, it disappears.
Download: https://drive.google.com/open?id=1LtOLIM8YwhvxJ_s5Kox0kS0IHVy4B-ds
Here is the entire source code the mod:
local function init(self)
local visible = true
local x = 10
local y = 10
local clickme=sdl.surface(self.resourcePath.."clickme.png")
local hangarGraphic=sdl.surface(self.resourcePath.."hangar_main.png")
AUTO_HOOK_Draw_Hangar = sdl.drawHook(function(screen)
if hangarGraphic:wasDrawn() and visible then
screen:blit(clickme,nil,x,y)
end
end)
AUTO_HOOK_Event_Hangar = sdl.eventHook(function(event)
if event:type() == sdl.events.mousebuttondown then
if visible and sdl.mouse.x() >= x and sdl.mouse.y() >= y and sdl.mouse.x() < x + clickme:w() and sdl.mouse.y() < y + clickme:h() then
visible = false
return true
end
return false
end
end)
end
local function load(self,options,version)
end
return {
id = "C_ASimpleButton",
name = "A Simple Button",
version = "1.0.0",
requirements = {},
init = init,
load = load,
}