Skip to content

Instantly share code, notes, and snippets.

@MattJeanes
Created May 10, 2020 23:34
Show Gist options
  • Save MattJeanes/c642afea526cbaab3d1b2f4d38d2c9e6 to your computer and use it in GitHub Desktop.
Save MattJeanes/c642afea526cbaab3d1b2f4d38d2c9e6 to your computer and use it in GitHub Desktop.
TARDIS Expression 2 (GMod)
@name TARDIS
@inputs
@outputs XYZ:vector
@persist Target:entity TARDIS:entity Visible SavePos:vector SaveAng:angle
runOnChat(1)
if (first()|dupefinished()){
TARDIS=entity():isConstrainedTo():tardisGet()
TARDIS:createWire(entity(),"XYZ", "XYZ")
Target=owner()
entity():setAlpha(0)
function demat(V:vector){
Success=TARDIS:tardisDemat(V)
if (Success){
print("TARDIS moving.")
}elseif(TARDIS:tardisInVortex()){
Success=TARDIS:tardisSetDestination(V)
if(Success){
print("TARDIS destination set.")
}
}
}
function demat2(V:vector, A:angle){
Success=TARDIS:tardisDemat(V,A)
if (Success){
print("TARDIS moving.")
}elseif(TARDIS:tardisInVortex()){
Success=TARDIS:tardisSetDestination(V,A)
if(Success){
print("TARDIS destination set.")
}
}
}
function vector getEscapePos(){
if (map()=="gm_madgrass_v6"){
return vec(-11270, -6790, -955)
}elseif (map()=="freespace_revolution"){
return vec(840, -12840, -6120)
}elseif (map()=="gm_wot_a5"){
return vec(-8939, 2716, -9199)
}else{
return vec(0,0,0)
}
}
function angle getEscapeAng(){
if (map()=="gm_wot_a5"){
return ang(0,-152,0)
}else{
return ang(0,0,0)
}
}
}
if(chatClk(owner())){
LastSaid=owner():lastSaid():explode(" ")
Cmd=LastSaid[1,string]
Arg=LastSaid[2,string]
if (Cmd=="!target"){
if(LastSaid[2,string]){
Target=findPlayerByName(Arg)
}else{
Target=owner()
}
hideChat(1)
print("Target set to " + Target:name())
}elseif(Cmd=="!go"){
local NewPos=Target:pos()
if (Target:tardisGet():isValid()){
NewPos=Target:tardisGet():pos()
}
local Yaw=Target:eyeAngles():yaw()
local Offset=150
if(Arg=="up"){
demat(NewPos+Target:up()*Offset)
}elseif(Arg=="forward"){
demat2(NewPos+Target:forward()*Offset, ang(0,Yaw+180,0))
}elseif(Arg=="back"){
demat2(NewPos+Target:forward()*-Offset, ang(0,Yaw,0))
}elseif(Arg=="down"){
demat(NewPos+Target:up()*-Offset)
}elseif(Arg=="right"){
demat2(NewPos+Target:right()*Offset, ang(0,Yaw+90,0))
}elseif(Arg=="left"){
demat2(NewPos+Target:right()*-Offset, ang(0,Yaw+270,0))
}elseif(Arg=="exact"){
demat2(NewPos,ang(0,Yaw,0))
}elseif(Arg=="playx"){
findByClass("gmod_playx")
PlayX=find()
demat2(PlayX:toWorld(vec(-290,-38,-230)), ang(0,0,0))
}else{
demat2(NewPos+Target:forward()*Offset, ang(0,Yaw+180,0))
}
hideChat(1)
}elseif(Cmd=="!escape"){
demat2(getEscapePos(),getEscapeAng())
hideChat(1)
}elseif(Cmd=="!phase"){
local Success=TARDIS:tardisPhase()
if (Success==1){
if(TARDIS:tardisVisible()){
print("TARDIS now visible.")
}else{
print("TARDIS no longer visible.")
}
}
hideChat(1)
}elseif(Cmd=="!flightmode"){
local Success=TARDIS:tardisFlightmode()
if (Success==1){
if(TARDIS:tardisFlying()){
print("TARDIS now flying.")
}else{
print("TARDIS no longer flying.")
}
}
hideChat(1)
}elseif(Cmd=="!lock"){
local Success=TARDIS:tardisLock()
if (Success==1){
if(TARDIS:tardisLocked()){
print("TARDIS now locked.")
}else{
print("TARDIS no longer locked.")
}
}
hideChat(1)
}elseif(Cmd=="!physlock"){
local Success=TARDIS:tardisPhyslock()
if (Success==1){
if(TARDIS:tardisPhyslocked()){
print("TARDIS now phys-locked.")
}else{
print("TARDIS no longer phys-locked.")
}
}
hideChat(1)
}elseif(Cmd=="!power"){
local Success=TARDIS:tardisPower()
if (Success==1){
if(TARDIS:tardisPowered()){
print("TARDIS now powered up.")
}else{
print("TARDIS no longer powered up.")
}
}
hideChat(1)
}elseif(Cmd=="!isomorph"){
local Success=TARDIS:tardisIsomorph()
if (Success==1){
if(TARDIS:tardisIsomorphic()){
print("TARDIS isomorphic security systems enabled.")
}else{
print("TARDIS isomorphic security systems disabled.")
}
}
hideChat(1)
}elseif(Cmd=="!longflight"){
local Success=TARDIS:tardisLongflight()
if (Success==1){
if(TARDIS:tardisLongflighted()){
print("TARDIS long-flight enabled.")
}else{
print("TARDIS long-flight disabled.")
}
}
hideChat(1)
}elseif(Cmd=="!mat"){
local Success=TARDIS:tardisMaterialise()
if (Success==1){
print("TARDIS materialising.")
}
hideChat(1)
}elseif(Cmd=="!selfrepair"){
local Success=TARDIS:tardisSelfrepair()
if (Success==1){
if(owner():tardisGet()!=TARDIS){
if(TARDIS:tardisSelfrepairing()){
print("TARDIS self-repair initiated.")
}else{
print("TARDIS self-repair cancelled.")
}
}
}
hideChat(1)
}elseif(Cmd=="!track"){
local TrackEnt=owner():aimEntity()
if (Arg=="me"){TrackEnt=owner()}
if (Arg=="off"){TrackEnt=noentity()}
local Success=TARDIS:tardisTrack(TrackEnt)
if (Success==1){
if (TARDIS:tardisTracking():isValid()){
print("TARDIS tracking entity set.")
}else{
print("TARDIS tracking disabled.")
}
}
hideChat(1)
}elseif(Cmd=="!hads"){
local Success=TARDIS:tardisHADS()
if (Success){
if (TARDIS:tardisIsHADS()){
print("TARDIS HADS enabled.")
}else{
print("TARDIS HADS disabled.")
}
}
hideChat(1)
}elseif(Cmd=="!spinmode"){
if(Arg==""){Arg="-1"}
local Spinmode=TARDIS:tardisSpinmode(Arg:toNumber())
local SpinmodeS=""
if (Spinmode==-1){SpinmodeS="anti-clockwise"}
if (Spinmode==0){SpinmodeS="none"}
if (Spinmode==1){SpinmodeS="clockwise"}
print("TARDIS Spinmode set to: " + SpinmodeS + ".")
hideChat(1)
}elseif(Cmd=="!save"){
SavePos=TARDIS:pos()
SaveAng=TARDIS:angles()
XYZ=SavePos
print("Position saved.")
hideChat(1)
}elseif(Cmd=="!restore"){
demat2(SavePos,SaveAng)
hideChat(1)
}elseif(Cmd=="!demat"){
TARDIS:tardisFastDemat()
hideChat(1)
}elseif(Cmd=="!back"){
TARDIS:tardisFastReturn()
hideChat(1)
}elseif(Cmd=="!health"){
print("TARDIS Health: " + TARDIS:tardisHealth() + "%")
hideChat(1)
}elseif(Cmd=="!pilot"){
if(TARDIS:tardisPilot():isValid()){
print("TARDIS pilot: " + TARDIS:tardisPilot():name())
}else{
print("TARDIS has no current pilot.")
}
}
}
XYZ=getEscapePos()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment