if not CLIENT then return false end -- Clientside only :)

--[[
made by:
 ____ _______                    _
|  __|__   __|_  _ __   ____  __| |
 \ \    | |/ _ \| '_ \ / __ )/ _` |
 _\ \   | | (_) | | | | (___| (_| |
|____|  |_|\___/|_| |_|\__,_)\__,_|

]]

LuaRun = {}

local x = ScrW()
local y = ScrH()

function LuaRun.Panel()
	local panel = vgui.Create("DFrame")
		panel:SetPos(x/2-210,y/2-210)
		panel:SetSize(425,400)
		panel:SetTitle("LuaRun - Made by Stoned")
		panel:SetVisible(true)
		panel:SetDraggable(true)
		panel:ShowCloseButton(true)
		panel:SetBackgroundBlur(false)
		panel:SetFont("BudgetLabel")
		panel:MakePopup()
	
	local datainput = vgui.Create("DTextEntry")
		datainput:SetParent(panel)
		datainput:SetMultiline(1)
		datainput:SetText(tostring(LuaRun.datasave))
		datainput:SetPos(0,40)
		datainput:SetTall(panel:GetTall()-40)
		datainput:SetWide(panel:GetWide())
	
	if (file.Exists("lua_run.txt")) then
		LuaRun.datasave = file.Read("lua_run.txt")
	else
		LuaRun.datasave = "print('lolololol') -- this is an example"
		file.Write("lua_run.txt","print('lolololol') -- this is an example")
	end

	local saverun = vgui.Create("DButton")
	saverun:SetParent(panel)
	saverun:SetText("===> Click here to Save | Run <===")
	saverun:SetWide(panel:GetWide())
	saverun:SetTall(20)
	saverun:SetPos(0,22)
	saverun.DoClick = function()
		local savemenu = DermaMenu()
    	savemenu:AddOption("Run It!",function()
		LuaRun.datasave = datainput:GetValue()
		RunString(datainput:GetValue())
		file.Write("lua_run.txt", LuaRun.datasave)
		end)
		savemenu:AddOption("Undo Changes",function()
		datainput:SetText(LuaRun.datasave)
		end)
		savemenu:Open()
	end
end
concommand.Add("lua_run_panel",LuaRun.Panel)