Need help rewriting/fixing a very old addon

I’m trying to fix an old ODST drop pod addon that was released sometime in 2010. Right now i’m just trying to see if it has to be rewritten or it could be salvaged. Any pointers would greatly help. If i’m violating some rule, tell me and i’ll delete the post. Anyway, here’s the autorun code:
[lua] if (SERVER) then
AddCSLuaFile(“autorun/odst_pod.lua”)

odstrtime = 30
odstcrtime = 3

local function odstchangeremovetime (player,command,args)
	if player:IsAdmin() then
		if args[1] == nil then return end
		if odstcrtime <= tonumber( args[1] ) then
			odstrtime = tonumber( args[1] )
			player:ChatPrint("ODST Pod remove time changed to " ..odstrtime)
		else
			player:ChatPrint("ODST Pod remove time must be higher than the chute remove time")
		end
	end
end

local function odstchangechuteremovetime (player,command,args)
	if player:IsAdmin() then
		if args[1] == nil then return end
		if odstrtime >= tonumber( args[1] ) then
			odstcrtime = tonumber( args[1] )
			player:ChatPrint("ODST Pod Chute remove time changed to " ..odstrtime)
		else
			player:ChatPrint("ODST Pod Chute remove time must be lower than the pod remove time")
		end
	end
end

concommand.Add("odst_chuteremovetime",odstchangechuteremovetime)
concommand.Add("odst_removetime",odstchangeremovetime)

end

----hooks

hook.Add( “CanTool”, “odstpodgibs_noremove”,
function( pl, tr, toolmode )
if (SERVER) then
local hitentity = tr.Entity
if hitentity:IsValid() then
if !pl:IsAdmin() then
local hitentityent = hitentity:GetClass()
if ( hitentityent == “odst_pod_chute” || hitentityent == “odst_pod_door” || hitentityent == “odst_drop_pod” || hitentityent == “odst_drop_l” || hitentityent == “odst_drop_r” ) then
return false
end
end
end
end
end)

hook.Add( “PhysgunPickup”, “odstpodgibs_nopickup”,
function( ply, ent )
if (SERVER) then
if ent:IsValid() then
if !ply:IsAdmin() then
local hitentityent = ent:GetClass()
if ( hitentityent == “odst_pod_chute” || hitentityent == “odst_pod_door” || hitentityent == “odst_drop_pod” || hitentityent == “odst_drop_l” || hitentityent == “odst_drop_r” ) then
return false
end
end
end
end
end)

hook.Add( “HUDPaint”, “odstpodhud”,
function()
local client = LocalPlayer()
if client:GetNetworkedBool( “odstisinpod” ) == true then

	if GetViewEntity() ~= client then
		return
	end

	local pod = client:GetNetworkedEntity( "odstpodin" )

	surface.SetTexture( stattex )
	surface.DrawTexturedRectRotated( ScrW() * 0.86, ScrH() * 0.15 , ScrH() * 0.18, ScrH() * 0.18, 45 )

	surface.SetDrawColor( 255, 255, 255, 100 )
	local fuel1 = client:GetNetworkedInt( "odstpodf1" ) * 0.01
	local fuel2 = client:GetNetworkedInt( "odstpodf2" ) * 0.01

	local bartex = surface.GetTextureID("odstpods_bar")
	surface.SetTexture( bartex )

	surface.DrawTexturedRect( ScrW() * 0.29, ScrH() * 0.05 , ScrW() * 0.42, ScrH() * 0.05 )
	surface.DrawTexturedRect( ScrW() * (0.5 - (0.19 * fuel1)), ScrH() * 0.06 , ScrW() * 0.38 * fuel1, ScrH() * 0.03 )

	surface.DrawTexturedRect( ScrW() * 0.29, ScrH() * 0.11 , ScrW() * 0.42, ScrH() * 0.05 )
	surface.DrawTexturedRect( ScrW() * (0.5 - (0.19 * fuel2)), ScrH() * 0.12 , ScrW() * 0.38 * fuel2, ScrH() * 0.03 )

	surface.SetFont( "ChatFont" )
	surface.SetTextColor( 255, 255, 255, 180 )
	surface.SetTextPos( ScrW() * 0.32, ScrH() * 0.06 ) 
	surface.DrawText( "Thruster Fuel" ) 
	surface.SetTextPos( ScrW() * 0.32, ScrH() * 0.125 ) 
	surface.DrawText( "Manuver Fuel" )

	local podvel = tostring( math.Round( pod:GetVelocity().z ) * -1 )
	local poddist = nil

	local selfpos = pod:GetPos()
	local pos5 = selfpos + Vector(0, 0, -10)
	local pos25 = selfpos + Vector(0, 0, -7000)
	local tracedata = {}
	tracedata.start = pos5
	tracedata.endpos = pos25
	tracedata.filter = pod
	local trace = util.TraceLine(tracedata)
	if trace.Hit == true then
		poddist = tostring( math.Round( 7000 * trace.Fraction ) )
	else
		poddist = ">7000"
	end

	surface.SetDrawColor( 255, 255, 255, 225 )

	local paneltex = surface.GetTextureID("odstpods_panel")
	surface.SetTexture( paneltex )
	surface.DrawTexturedRect( ScrW() * 0.01, ScrH() * 0.01 , ScrH() * 0.35, ScrH() * 0.15 )

-------indicator 1
local intex1 = surface.GetTextureID(“odstpods_light_green”)
if pod:GetNetworkedInt( “odstpodstat” ) == 1 then
intex1 = surface.GetTextureID(“odstpods_light_unlit”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 2 then
intex1 = surface.GetTextureID(“odstpods_light_red”)
end

	surface.SetTexture( intex1 )
	surface.DrawTexturedRect( ScrW() * 0.033, ScrH() * 0.085 , ScrH() * 0.1, ScrH() * 0.1 )

-------indicator 2
local intex2 = surface.GetTextureID(“odstpods_light_green”)
if pod:GetNetworkedInt( “odstpodstat” ) == 1 then
intex2 = surface.GetTextureID(“odstpods_light_unlit”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 2 then
intex2 = surface.GetTextureID(“odstpods_light_red”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 3 then
intex2 = surface.GetTextureID(“odstpods_light_red”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 4 then
if pod:GetNetworkedBool( “odstpodman” ) && !client:KeyDown( IN_SPEED ) then
intex2 = surface.GetTextureID(“odstpods_light_yellow”)
else
intex2 = surface.GetTextureID(“odstpods_light_green”)
end
end

	surface.SetTexture( intex2 )
	surface.DrawTexturedRect( ScrW() * 0.1, ScrH() * 0.085 , ScrH() * 0.1, ScrH() * 0.1 )

-------indicator 3
local intex3 = surface.GetTextureID(“odstpods_light_green”)
if pod:GetNetworkedInt( “odstpodstat” ) == 1 then
intex3 = surface.GetTextureID(“odstpods_light_unlit”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 2 then
intex3 = surface.GetTextureID(“odstpods_light_red”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 3 then
intex3 = surface.GetTextureID(“odstpods_light_red”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 4 then
intex3 = surface.GetTextureID(“odstpods_light_red”)
elseif pod:GetNetworkedInt( “odstpodstat” ) == 5 then
intex3 = surface.GetTextureID(“odstpods_light_green”)
end

	surface.SetTexture( intex3 )
	surface.DrawTexturedRect( ScrW() * 0.167, ScrH() * 0.085 , ScrH() * 0.1, ScrH() * 0.1 )

	local vitaltex = surface.GetTextureID("odstpods_vitals")
	surface.SetTexture( vitaltex )
	surface.DrawTexturedRect( ScrW() * 0.75, ScrH() * 0.02 , ScrH() * 0.27, ScrH() * 0.13 )

	local hlth = tostring( client:Health() )
	draw.DrawText(  hlth, "HUDNumber5",  ScrW() * 0.775,  ScrH() * 0.06,  Color(255, 255, 255, 180), 0 )

	local autotex = surface.GetTextureID("odstpods_indicator_man")
	if pod:GetNetworkedBool( "odstpodman" ) == true then
		autotex = surface.GetTextureID("odstpods_indicator_man")
	elseif pod:GetNetworkedBool( "odstpodman" )  == false then
		autotex = surface.GetTextureID("odstpods_indicator_auto")
	end

	surface.SetTexture( autotex )
	surface.DrawTexturedRect( ScrW() * 0.87, ScrH() * 0.035 , ScrH() * 0.10, ScrH() * 0.10 )

	draw.DrawText(  podvel, "ChatFont",  ScrW() * 0.12,  ScrH() * 0.04,  Color(255, 255, 255, 180), 0 )
	draw.DrawText(  poddist, "ChatFont",  ScrW() * 0.12,  ScrH() * 0.07,  Color(255, 255, 255, 180), 0 )
end

end) [/lua]

Any help would be greatly appreciated.

Here’s a link to the download:https://garrysmods.org/download/2618/odst-drop-pod-v12a

I was also thinking about this today ._.

Too bad though, you’ll need an old google doc which was the changelog for when Garry made GM12 into GM13. It can’t be accessed anymore because the file is gone (I think). Maybe try asking if somebody has a copy of it?

Actually it isn’t a lot of code to update but the major points are: ValidEntity( x ) / x:ValidEntity( ) / x:IsValid( ) becomes IsValid( x ), creating fonts has changed ( but a good error message shows up now instead of spamming error w in console ), and there are new hooks and old ones may not exist. I’d suggest looking the data up on the Wiki…

Change Get/SetNetworked to Get/SetNW

Make sure you reference materials outside of draw hooks, ie initialize once and reference many times

I’d recommend against using protected variables / libraries / etc… as local variable names such as player, table, etc…

Try taking a crack at it and show us how far you get with what I wrote; there shouldn’t be much that needs to be changed although I’d end up rewriting most of it to simplify it ( and end up making it more complex at the same time ). Show us what you come up with and if there are any errors and we’ll help you with the conversion. To learn how to convert them doesn’t take long!

Wow, I was thinking about this addon just yesterday.

If you guys were wondering, I didn’t rewrite the addon (I’m a lazy fucker), but I fixed a couple of lines that had to do with the sound, and for some reason only admins were allowed to spawn the drop pod. It could probably be rewritten in a better way, but if it ain’t broke, don’t fix it, you know?

Here’s the link to the addon if anyone is interested: http://steamcommunity.com/sharedfiles/filedetails/?id=434936477&tscn=1430507713

or in Wiki format, http://wiki.garrysmod.com/page/Updating_Scripts_From_GMod_12_to_GMod_13