Last active
August 29, 2015 14:05
-
-
Save bloxgate/08e3406bc163e38dce6d to your computer and use it in GitHub Desktop.
e2 holographic radar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@name Holo Radar | |
@inputs | |
@outputs Targets Runs:number Planets PlanPos:array | |
@persist Runs Scheduler:table | |
@trigger | |
@autoupdate | |
#ifdef getPlanetRadius(entity) | |
if(first()) | |
{ | |
#include "libCoroutine" | |
Scheduler=newScheduler() | |
State = table() | |
State["SomeStateVar", number] = 1 | |
State["SomeStateVar2", number] = 2 | |
Scheduler:coSchedule(newRoutine("deleteMissing", State)) | |
#Scheduler:coSchedule(newRoutine("movePlanets", State)) | |
function deleteMissing(State:table, Routine:table){ | |
local Var = State["SomeStateVar", number] | |
for(X =1, Targets){ | |
if(!findResult(X):isValid()){ | |
holoDelete(X) | |
} | |
} | |
State["SomeStateVar", number] = Var | |
Scheduler:coSchedule(Routine) | |
} | |
Planets = findByClass("logic_case") | |
for(X = 1, Planets){ | |
Radius = getPlanetRadius(findResult(X)) / 3000 | |
HoloID = X + 128 | |
PlanPos:insertVector(HoloID,findResult(X):pos()) | |
holoCreate(HoloID, entity():pos() + entity():toLocal(findResult(X):pos()) / vec(900,900,900) + vec(0,0,15) * entity():up(), vec(0.75 * Radius,0.75 * Radius,0.75 * Radius)) | |
holoModel(HoloID, "hqicosphere") | |
if(getPlanetTemp(findResult(X)) < 283) | |
{ | |
holoColor(HoloID, vec4(0,0,255,100)) | |
} | |
else | |
{ | |
if(getPlanetTemp(findResult(X)) > 308) | |
{ | |
holoColor(HoloID, vec4(255,0,0,100)) | |
} | |
else{ | |
holoColor(HoloID, vec4(0,255,0,100)) | |
} | |
} | |
} | |
function movePlanets(){ | |
#local Var = State["SomeStateVar2", number] | |
for(X = PlanPos:min(), PlanPos:maxIndex()){ | |
holoPos(X + 128, entity():pos() + entity():toLocal(PlanPos[X+128,vector]) / vec(900,900,900) + vec(0,0,15)) | |
holoParent(X + 128, entity()) | |
} | |
#State["SomeStateVar2",number] = Var | |
#Scheduler:coSchedule(Routine) | |
} | |
movePlanets() | |
# Find Players | |
findIncludeClass("player") | |
findIncludeClass("Vehicle") | |
findIncludeClass("gmod_wire_gps") | |
findIncludeClass("pewpew_base_cannon") | |
findIncludeClass("logic_case") | |
findIncludeClass("sg_vehicle_*") | |
findIncludeClass("prop_dynamic") | |
findIncludeClass("grob_*") | |
Targets = findInSphere(entity():pos(), 50000) | |
# Initialize a black backdrop for the other holograms | |
holoCreate(0,entity():pos() + vec(0,0,5), vec(0,0,0), ang(), vec()) | |
holoModel(0,"plane") | |
holoAlpha(0,128) | |
# Initialize radar holograms | |
for( X = 1, Targets) | |
{ | |
if(findResult(X) == owner()) | |
{ | |
holoCreate( X, entity():pos(), vec(0.1,0.1,0.1) ) | |
holoModel( X, "tetra") | |
holoColor(X, vec(130,250,200)) | |
} | |
else{ if(findResult(X):isPlayer()) | |
{ | |
holoCreate( X, entity():pos(), vec(0.05,0.05,0.05) ) | |
holoModel( X, "hqicosphere") | |
holoColor(X, vec(0,0,255)) | |
} | |
else{ if(findResult(X):isVehicle() || findResult(X):type() == "sg_vehicle_f302" | "sg_vehicle_dart") | |
{ | |
holoCreate( X, entity():pos(), vec(0.05,0.05,0.05) ) | |
holoModel( X, "cube") | |
holoColor(X, vec(0,255,0)) | |
} | |
else | |
{ | |
if(findResult(X):type() == "pewpew_*") | |
{ | |
holoCreate( X, entity():pos(), vec(0.05,0.05,0.05) ) | |
holoModel( X, "hq_rcylinder_thick") | |
holoColor( X, vec(255,0,0)) | |
} | |
} | |
} | |
} | |
} | |
timer("holoDeletion",500) | |
} | |
interval(200) | |
# Update position of backdrop | |
holoPos(0,entity():pos() + vec(0,0,10)) | |
# Update positions of radar holograms | |
for( X = 1, Targets) | |
{ | |
if(findResult(X):isPlayer() | findResult(X):isVehicle() | findResult(X):owner()) | |
{ | |
# Get position of targeted player, localize the vector, place at expression chip, and scale down | |
holoPos( X, (entity():pos() + entity():toLocal(findResult(X):pos()) / vec(900,900,900)) + vec(0,0,15) * entity():up() ) | |
holoParent(X, entity()) | |
} | |
else | |
{ | |
holoPos(X, (entity():pos() + entity():toLocal(findResult(X):pos()) / vec(900,900,900)) + vec(0,0,15)) | |
holoParent(X, entity()) | |
} | |
} | |
if(clkName() == "holoDeletion"){ | |
Scheduler:coRun() | |
timer("holoDeletion",500) | |
} | |
Runs = Runs + 1 | |
if(Runs == 500) | |
{ | |
reset() | |
} | |
#else | |
print("Failure: Missing Bloxgate's Planet Keyvalue Extension") | |
selfDestruct() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment