Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2014 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/6c275cbea55444ac5866 to your computer and use it in GitHub Desktop.
Save anonymous/6c275cbea55444ac5866 to your computer and use it in GitHub Desktop.
-- Waypoint Buttons by Hezeth & Peas
init start
-- #Buttons
local Buttons = {
{text = "Walk", id = -1, action = function() addwaypoint('walk', $posx, $posy, $posz) end},
{text = "Action", id = -1, action = function() addwaypoint('action', $posx, $posy, $posz) end},
{text = "Stand", id = -1, action = function() addwaypoint('stand', $posx, $posy, $posz) end},
{text = "Node", id = -1, action = function() addwaypoint('node', $posx, $posy, $posz) end},
{text = "Shovel", id = -1, action = function() addwaypoint('shovel', $posx, $posy, $posz) end},
{text = "Rope", id = -1, action = function() addwaypoint('rope', $posx, $posy, $posz) end},
{text = "Machete", id = -1, action = function() addwaypoint('machete', $posx, $posy, $posz) end},
{text = "Ladder", id = -1, action = function() addwaypoint('ladder', $posx, $posy, $posz) end},
{text = "Use", id = -1, action = function() addwaypoint('use', $posx, $posy, $posz) end},
{text = "Lure", id = -1, action = function() addwaypoint('lure', $posx, $posy, $posz) end},
}
local Directions = {
{text = "North", id = -1, action = function() addwaypoint('stand', $posx, $posy-1, $posz) end},
{text = "South", id = -1, action = function() addwaypoint('stand', $posx, $posy+1, $posz) end},
{text = "East", id = -1, action = function() addwaypoint('stand', $posx+1, $posy, $posz) end},
{text = "West", id = -1, action = function() addwaypoint('stand', $posx-1, $posy, $posz) end},
{text = "NW", id = -1, action = function() addwaypoint('stand', $posx-1, $posy-1, $posz) end},
{text = "NE", id = -1, action = function() addwaypoint('stand', $posx+1, $posy-1, $posz) end},
{text = "SW", id = -1, action = function() addwaypoint('stand', $posx-1, $posy+1, $posz) end},
{text = "SE", id = -1, action = function() addwaypoint('stand', $posx+1, $posy+1, $posz) end},
}
local lastPressed = {id = -1, time = $timems}
local rectHeight, rectWidth = 20 + (#Buttons * 25), 100
local rectHeight, rectWidth = 60 + (#Directions * 25), 100
setposition(300,400)
setfontstyle('Razer Header Regular',fontsize, 99, 0xE9D332, 1, 0)
setfontcolor(color(255, 250, 250))
setfontsize(8)
filterinput(false, true, true, false)
local Moving, Temp, Moved = false, {0, 0}, {0, 0}
function inputevents(e)
if (e.type == IEVENT_LMOUSEDOWN) then
for _, button in ipairs(Buttons) do
if (e.elementid == button.id) then
lastPressed = {id = button.id, time = $timems}
button.action()
end
end
for _, direction in ipairs(Directions) do
if (e.elementid == direction.id) then
lastPressed = {id = direction.id, time = $timems}
direction.action()
end
end
end
if (e.type == IEVENT_RMOUSEDOWN) then
Moving, Temp = true, {$cursor.x - Moved[1], $cursor.y - Moved[2]}
end
if (e.type == IEVENT_RMOUSEUP) then
Moving = false
if math.abs(Moved[1]) <= 15 then
Moved[1] = 0
end
if math.abs(Moved[2]) <= 15 then
Moved[2] = 0
elseif math.abs(($worldwin.bottom-20) - Moved[2]) <= 15 then
Moved[2] = $worldwin.bottom-20
end
end
end
init end
if (Moving) then
auto(10)
Moved = {$cursor.x - Temp[1], $cursor.y - Temp[2]}
end
setposition($clientwin.left-1 + Moved[1], $clientwin.top + Moved[2])
local spacing = 0
for i = 1, #Buttons do
setfillstyle('gradient', 'linear', 2, 0, 0, 0, 25)
if Buttons[i].id ~= lastPressed.id then
addgradcolors(0, color(193, 205, 205), 1.0, color(131, 139, 139))
else
addgradcolors(0, color(0, 0, 0), 0.1,color(0, 0, 0))
end
Buttons[i].id = drawroundrect(10, 10 + spacing, rectWidth-20, 20)
local w,h = measurestring(Buttons[i].text)
drawtext(Buttons[i].text, (rectWidth/2) - (w/2), 20 + spacing - (h/2))
spacing = spacing + 25
end
for i = 1, #Directions do
setfillstyle('gradient', 'linear', 2, 0, 0, 0, 25)
if Directions[i].id ~= lastPressed.id then
addgradcolors(0, color(139, 0, 0), 0.8, color(139, 35, 65))
else
addgradcolors(0, color(255, 255, 255), 1.0,color(255, 255, 255))
end
if Directions[i].text == "North" then Directions[i].id = drawroundrect(150, 20 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "South" then Directions[i].id = drawroundrect(150, 45 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "West" then Directions[i].id = drawroundrect(97, -30 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "East" then Directions[i].id = drawroundrect(203, -5 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "NW" then Directions[i].id = drawroundrect(97, -80 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "NE" then Directions[i].id = drawroundrect(203, -105 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "SW" then Directions[i].id = drawroundrect(97, -80 +spacing - rectHeight, rectWidth - 50, 20) end
if Directions[i].text == "SE" then Directions[i].id = drawroundrect(203, -105 +spacing - rectHeight, rectWidth - 50, 20) end
local w,h = measurestring(Directions[i].text)
if Directions[i].text == "East" then drawtext(Directions[i].text, 230 - (w/2), 6 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "West" then drawtext(Directions[i].text, 123 - (w/2), -18 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "North" then drawtext(Directions[i].text, 175 - (w/2), 30 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "South" then drawtext(Directions[i].text, 175 - (w/2), 55 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "NW" then drawtext(Directions[i].text, 123 - (w/2), -70 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "NE" then drawtext(Directions[i].text, 230 - (w/2), -95 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "SW" then drawtext(Directions[i].text, 123 - (w/2), -70 + spacing -rectHeight - (h/2)) end
if Directions[i].text == "SE" then drawtext(Directions[i].text, 230 - (w/2), -95 + spacing -rectHeight - (h/2)) end
local w,h = measurestring(Directions[i].text)
spacing = spacing + 25
end
if $timems - lastPressed.time > 100 then
lastPressed.id = -1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment