![]() |
|
Release Shuttle Computer - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: Release Shuttle Computer (/thread-994.html) |
Shuttle Computer - SuperPlayer - 11-06-2015 This is my Shuttle Computer I am releasing today. Code: --@name Shuttle Computer
--@author SuperPlayer
--@updater STEAM_0:0:74694146
--@shared
local Self = ents.self()
local Shuttle = ents.self():isWeldedTo()
Self:parentTo(Shuttle)
local SWire = Shuttle:getWirelink()
local Owner = ents.owner()
local Target = nil
local SDTime = 10
local Loc = { }
--[[
You can add coordinates by your own!
This is an example:
Loc[Name] = Coordinates
Under this are just galaxy warp destinations
]]--
Loc["pegasus"] = Vector( 5928.50, -6937.34, 9728.70 )
Loc["universe"] = Vector( -3168.37, -4246.44, -6609.20 )
Loc["milkyway"] = Vector( 11720.89, 4981.85, 6595.30 )
function say(String)
printColor( Color(0, 255, 255 ), "[Shuttle] ",Color( 255, 255, 255 ), "" ..String)
end
function chatClk(Command, Player)
LS = Command:lower()
LSC = LS:explode( " " )
if Player == Owner then
if (LSC[1] == "shuttle") then
if (LSC[2] == "target") then
if(LSC[3] ~= "" and LSC[4] == nil)then
if LSC[3] == "off" then
Target = nil
say("Targetting off")
else
TargetFind = find.playerByName(LSC[3])
if IsValid(TargetFind) then
Target = TargetFind
say("Targetting "..Target:name())
else
say("Could not target "..LSC[3])
end
end
elseif(LSC[3] ~= "" and LSC[4] ~= "")then
local Player=find.playerByName(LSC[4])
local Targets = find.byClass( LSC[3], function( Ent ) return Ent:owner() == Player end )
if IsValid(Targets[1]) then
Target = Targets[1]
say("Targetting "..Target:class().." "..Target:owner():name())
else
say("Could not target "..LSC[4].."'s".." "..LSC[3])
end
end
elseif (LSC[2] == "beam") then
if LSC[4] == "up" then
SWire["Beam Up"] = 1
say("Beaming up")
elseif LSC[4] == "down" then
if LSC[5] == "to" and LSC[6] ~= nil then
local Ply = find.playerByName(LSC[6])
if IsValid(Ply) then
local Pos = Ply:pos()
SWire["Destination"] = Pos
SWire["Beam Down"] = 1
say("Beaming down to "..Ply:name())
else
say("There is no player "..LSC[6].." you could beam to.")
end
else
local Trace = trace.trace( Shuttle:pos(), Shuttle:getUp()*-10^14, function(Ent) return Ent ~= Shuttle end , nil, false )
local BPos = Trace.HitPos
SWire["Destination"] = BPos
SWire["Beam Down"] = 1
say("Beaming down")
end
end
elseif (LSC[2] == "warp" and LSC[3] == "to" and LSC[4] ~= nil) then
if Loc[LSC[4]] then
SWire["Transwarp Destination"] = Loc[LSC[4]]
SWire["Transwarp"] = 1
say("Warping to "..LSC[4])
else
local Player = find.playerByName(LSC[4])
if IsValid(Player) then
SWire["Transwarp Destination"] = Player:pos() + Vector(0,0,200)
SWire["Transwarp"] = 1
say("Warping to "..Player:name())
else
say("Could not warp to "..LSC[4])
end
end
elseif (LSC[2] == "self" and LSC[3] == "destruct") then
say("Self destruct activated! Self destruct in 10 seconds!")
timer.create("SD",1,0,SD)
elseif (LSC[2] == "abort" and LSC[3] == "self" and LSC[4] == "destruct") then
say("Self destruct aborted!")
SDTime = 10
timer.remove("SD")
end
return true
end
end
end
function SD()
SDTime = SDTime -1
if SDTime == 0 then
say("Self destruct complete")
SWire["Self Destruct"] = 1
ents.self():remove()
else
say("Self destruct in "..SDTime.." seconds!")
end
end
function listenToChat()
chat.listen(chatClk)
end
hook.add( "think", "Target", function()
if IsValid(Target) then
local Pos = Target:pos()
if Target:class() == "st_shuttle_type11" then
Pos = Pos+Vector(0,0,200)
end
if SWire then
SWire["Target"] = Pos
end
else
local Trace = trace.trace( Shuttle:pos(), Shuttle:getForward()*-10^14, function(Ent) return Ent ~= Shuttle end , nil, false )
local TPos = Trace.HitPos
if SWire then
SWire["Target"] = TPos
end
end
end)
timer.create("chat", 0.5, 0, listenToChat)The chip auto-wires to your shuttle. For chat commands look through the code. Enjoy it. RE: Shuttle Computer - SuperPlayer - 29-06-2015 I updated the Shuttle Computer to work with the new Shuttles. It also supports multiple shuttles. The new version can be found in my shared folder. RE: Shuttle Computer - тѕсм.[SG-1] Teal'c - 06-09-2015 what are the command tho RE: Shuttle Computer - SuperPlayer - 06-09-2015 How you start a command is printed in your chat when you spawn the chip. Then use "warp to DEST" DEST is either a player name or a galaxy name. If you look thorugh the code i commented how to add custom destinations. Use "target ENT PLY" In this case ENT is the entity name like ship_core And PLY is the players name who owns it. Use "beam me up" to beam you up. Use "bem me down" to beam you under the shuttle Use "beam me down to PLY" to beam you to a player |