FreeSpace Releases > Scripting Releases
auxiliary-Instrument Display
PoDo:
Hi!
one of my really long time dreams is a fully immersive cockpit to play freespace (i first hat that idea when freespace 2 came out). sadly, i just don't have enough space to build it (according to my girlfriend XD )
but on and off again i play around with the idea, building some panels and programming some stuff and i thought i can share this with you all ^^
the following (lua) scripts require to pc's, one running the freespace game you are playing, and the other pc another instance of freespace that just displays stuff (like the radar, weapon stuff, target info etc.)
it's not finnished, the radar for instance uses a fair ammount of cpu time because the tailing scannlines are programmed poorly :lol:
the server script (the one running on the gaming machine) collects all information and sends it via udp-socket to the client machine which then tries to display those information in a pleasing way (more or less ^^)
the (data/tables/)Scripting.tbl for the pc you're playing on would be
--- Code: ---#Global Hooks
$HUD:[
]
#End
#Conditional Hooks
$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Key Pressed: [
taste=hv.Key
doenergychange=function(wertA,wertB,wertC,aktion)
if aktion<0 then
emani=math.min(wertA,2)
else--if aktion==2 then
emani=math.min(12-wertA,2)
end
local change=(emani/2*aktion*-1)
local cA=emani*aktion
local cB=change
local cC=change
local rest=0
if (wertB+change)>12 then
rest=12-(wertB+change)
cB=change-rest
cC=change+rest
elseif (wertC+change)>12 then
rest=12-(wertC+change)
cC=change-rest
cB=change+rest
elseif (wertB+change)<0 then
rest=(wertB+change)
cB=change-rest
cC=change+rest
elseif (wertC+change)<0 then
rest=(wertC+change)
cC=change-rest
cB=change+rest
end
return cA,cB,cC
end
energyverwaltung=function(ve,vs,vg)
local e=0
local s=0
local g=0
if ve~=0 then
e,s,g=doenergychange(e_nrg,s_nrg,g_nrg,ve)
elseif vs~=0 then
s,e,g=doenergychange(s_nrg,e_nrg,g_nrg,vs)
elseif vg~=0 then
g,e,s=doenergychange(g_nrg,e_nrg,s_nrg,vg)
end
e_nrg=e_nrg+e
s_nrg=s_nrg+s
g_nrg=g_nrg+g
end
-- if hv.Key=="2" and radar_range<10000 then
-- radar_range = radar_range+500
-- elseif hv.Key=="1" and radar_range>500 then
-- radar_range = radar_range-500
if hv.Key=='Page Down' then
energyverwaltung(-1,0,0)
elseif hv.Key=='Page Up' then
energyverwaltung(1,0,0)
elseif hv.Key=='End'then
energyverwaltung(0,-1,0)
elseif hv.Key=='Home' then
energyverwaltung(0,1,0)
elseif hv.Key=='Delete' then
energyverwaltung(0,0,-1)
elseif hv.Key=='Insert' then
energyverwaltung(0,0,1)
end
]
$On State Start:
[
taste=""
--clr=require("CLRPackage")
--import "Microsoft.VisualBasic"
--import "System.Windows.Forms"
timestamp = 0
socket=require("socket")
sendinginterval=0.02--alle so viele Sekunden werden Spielinfos verschickt
udp=socket.udp()
udp:settimeout(0)
-- connect to UDP server
--ip auflösen evtl host = socket.dns.toip("Computername, zB Cerberos")
udp:setpeername ("192.168.0.7",14285)
--energie verteilung beim starten einer mission
e_nrg=4
s_nrg=4
g_nrg=4
]
$On Frame:
[
--tweakables!
posX,posY = 10,500
local e_nrg_displ=e_nrg --math.floor(10/12*e_nrg)/10
local s_nrg_displ=s_nrg --math.floor(10/12*s_nrg)/10
local g_nrg_displ=g_nrg --math.floor(10/12*g_nrg)/10
--gr.drawString(g_nrg_displ.."|"..s_nrg_displ.."|"..e_nrg_displ.." = "..(g_nrg_displ+s_nrg_displ+e_nrg_displ),80,25)
if mn.getMissionTime() > timestamp then
timestamp = mn.getMissionTime() + sendinginterval
ship = mn.Ships["Alpha 1"]
plr = hv.Player
-- only continue if we can get valid player handle
if plr:isValid() and ship:isValid() then
shipinfo={}
--schiffstyp
table.insert(shipinfo,ship.Class.Name)
--speed
table.insert(shipinfo,math.floor(plr.Physics.Velocity:getMagnitude()))
--life/damage aka hull integrity in %
table.insert(shipinfo,math.floor(100/ship.HitpointsMax*ship.HitpointsLeft))
--empf effekt
--ship:getEMP()
--gr.drawString(ship:getEMP() ,110,85)
--mn.runSEXP('( when true ( clear-goals "'..curShip.Name..'" ) )')
--countermeasures aka flares
table.insert(shipinfo,ship.CountermeasuresLeft..":|:"..ship.Class.CountermeasuresMax)
--nachbrennerenergie in %
table.insert(shipinfo,math.floor(100/ship.AfterburnerFuelMax*ship.AfterburnerFuelLeft))
--if plr.Physics:AfterburnerActive() then
--gr.drawString("NACHBRENNER!",100,50)
--end
--schilde insgesamt / 1=rechts / 2=vorne / 3=hinten / 4=links
table.insert(shipinfo,math.floor(100/plr.Shields.CombinedMax*plr.Shields.CombinedLeft)..":|:"..math.floor(plr.Shields[1])..":|:"..math.floor(plr.Shields[2])..":|:"..math.floor(plr.Shields[3])..":|:"..math.floor(plr.Shields[4]))
--energie management
table.insert(shipinfo,g_nrg..":|:"..s_nrg..":|:"..s_nrg)
--local test=ship:isMatchingSpeed()
--waffen energie in %
local wepeng=math.floor((ship.WeaponEnergyLeft/ship.WeaponEnergyMax)*100)
table.insert(shipinfo,wepeng)
-------gun ammo
local guninfo={}
local missleinfo={}
local primarydual=hv.Player.PrimaryBanks.Linked
local secondyrydual=hv.Player.SecondaryBanks.DualFire
if secondyrydual then secondyrydual="1"
else secondyrydual="0" end
for i = 1, 3, 1 do
if ship.PrimaryBanks[i]:isValid() then
local warmed="0"
----primarys with ammo: Gattler, Archer, UX Accelerator, Redeemer, Vajra
if ship.PrimaryBanks[i].Armed or primarydual then local warmed="1" end
if ship.PrimaryBanks[i].AmmoMax>0 then
table.insert(guninfo,ship.PrimaryBanks[i].WeaponClass.Name..":|:"..warmed..":|:"..ship.PrimaryBanks[i].AmmoLeft..":|:"..ship.PrimaryBanks[i].AmmoMax..":|:".."0")
else
table.insert(guninfo,ship.PrimaryBanks[i].WeaponClass.Name..":|:"..warmed..":|:"..wepeng..":|:100:|:0")
end
end
end
-------missile ammo
for i = 1, 4, 1 do
if ship.SecondaryBanks[i]:isValid() then
local warmed="0"
if ship.SecondaryBanks[i].Armed then local warmed="1" end
table.insert(missleinfo,ship.SecondaryBanks[i].WeaponClass.Name..":|:"..warmed..":|:"..ship.SecondaryBanks[i].AmmoLeft..":|:"..ship.SecondaryBanks[i].AmmoMax..":|:"..secondyrydual)
end
end
for i = 1, 4, 1 do
if ship.TertiaryBanks[i]:isValid() then
local warmed="0"
if ship.TertiaryBanks[i].Armed then local warmed="1" end
table.insert(missleinfo,ship.TertiaryBanks[i].WeaponClass.Name..":|:"..warmed..":|:"..ship.TertiaryBanks[i].AmmoLeft..":|:"..ship.TertiaryBanks[i].AmmoMax":|:".."0")
end
end
table.insert(shipinfo,table.concat(guninfo,","))
table.insert(shipinfo,table.concat(missleinfo,","))
--target information START
targetinfo={}
if plr.Target:isValid() then
--probleme mit asteroiden und debris!!!!
local targetdistance=plr.Target.Position:getDistance(plr.Position)
if lasttargetdistance==nil or targetdistance==lasttargetdistance then
distpm=""
elseif targetdistance>lasttargetdistance then
distpm="+"
else
distpm="-"
end
lasttargetdistance=targetdistance
local targetdistance=math.floor(targetdistance)
local targetspeed = plr.Target.Physics.Velocity:getMagnitude()
if lasttargetspeed==nil or targetspeed==lasttargetspeed then
sistpm=""
elseif targetspeed>lasttargetspeed then
sistpm="+"
else
sistpm="-"
end
lasttargetspeed = targetspeed
local targetspeed = math.floor(targetspeed)
local targetdcm = math.floor(100/plr.Target.HitpointsMax*plr.Target.HitpointsLeft)
table.insert(targetinfo,plr.Target.Team.Name)
table.insert(targetinfo,plr.Target.Name)
table.insert(targetinfo,plr.Target.Class.Name)
table.insert(targetinfo,targetdistance..distpm)
table.insert(targetinfo,targetspeed..sistpm)
table.insert(targetinfo,targetdcm)
local torientation = (plr.Target.Position-plr.Position)
table.insert(targetinfo,table.concat({-torientation.x,-torientation.y,torientation.z},":|:"))
end
--target information END
--radar START
radarinfo={}
local stv--zum zwischenspeichern des targets
if mn.Debris ~= nil then
for i= 1,#mn.Debris do
if mn.Debris[i]:isValid() then
--transform vector and get length
local tpos = plr.Orientation:rotateVector(mn.Debris[i].Position - plr.Position)
if plr.Target == mn.Debris[i] then --target zwischenspeichern
stv = {"a",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"1"}
else
local tmpradarblip={"d",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"0","Debris"}
table.insert(radarinfo,table.concat(tmpradarblip,":|:"))
end
end
end
end
if mn.Asteroids ~= nil then
for i= 1,#mn.Asteroids do
if mn.Asteroids[i]:isValid() then
--transform vector and get length
local tpos = plr.Orientation:rotateVector(mn.Asteroids[i].Position - plr.Position)
if plr.Target == mn.Asteroids[i] then --target zwischenspeichern
stv = {"d",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"1"}
else
local tmpradarblip={"a",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"0","Asteroid"}
table.insert(radarinfo,table.concat(tmpradarblip,":|:"))
end
end
end
end
if mn.Ships ~= nil then
for i= 1,#mn.Ships do
if mn.Ships[i]:isValid() and mn.Ships[i] ~= plr then
--transform vector and get length
local tpos = plr.Orientation:rotateVector(mn.Ships[i].Position - plr.Position)
if mn.Ships[i]:isWarpingIn() then local iswrp=1
else local iswrp=0
end
if plr.Target == mn.Ships[i] then --target zwischenspeichern
stv = {"s",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"1",mn.Ships[i].Name,mn.Ships[i].Team.Name,mn.Ships[i].Class.Name,iswrp}
else
local tmpradarblip={"s",tpos.x,tpos.z,tpos.y,tpos:getMagnitude(),"0",mn.Ships[i].Name,mn.Ships[i].Team.Name,mn.Ships[i].Class.Name,iswrp}
table.insert(radarinfo,table.concat(tmpradarblip,":|:"))
end
end
end
end
if stv then
table.insert(radarinfo,table.concat(stv,":|:"))
end
--radar ENDE
--das senden wir zum client
local clientstring=table.concat({table.concat(shipinfo,":||:"),table.concat(targetinfo,":||:"),table.concat(radarinfo,":||:")},":|||:")
--udp:sendto(clientstring, ip, destport)
udp:send(clientstring)
end
end
]
$On State End:
[
--den bildschirm clearen
udp:send(":|||::|||::|||:")
]
#END
--- End code ---
you have to change to code line
--- Code: ---udp:setpeername ("192.168.0.7",14285)
--- End code ---
according to the ip address of the pc you'll be using to display your radar etc
and the Scripting.tbl for the recieving (display) pc would be:
--- Code: ---#Global hooks
$Splash: [
gr.setColor(255,0,255,255)
gr.drawRectangle(10,10,500,500,true)--hintergrund
]
+Override: true
#End#Conditional Hooks
$Application: FS2_Open
$State: GS_STATE_INITIAL_PLAYER_SELECT
$On State Start:
[
radar_range = 3500
lastclienstring = ":|||::|||::|||:"
socket=require("socket")
udp = socket.udp()
udp:settimeout(0)
-- bind UDP to all local interfaces
udp:setsockname("*",14285)
]
$State: GS_STATE_INITIAL_PLAYER_SELECT
$On Frame:
[
local clientstring=lastclienstring
function update()
gr.setColor(255,255,255,255)
-- receive incoming data from clients
while true do
local new_clientstring,ip,port=udp:receivefrom()
if new_clientstring == nil then
--gr.drawString("neeeeeee",10,10)--clientstring
break
end
clientstring=new_clientstring
--if radar_range==nil then radar_range = 3500 end
--if lastclienstring==nil then lastclienstring = ":|||::|||::|||:" end
end
--ba.getFrametime(false)
--ba.getFrametime(true)
gr.drawString("Interval: "..(math.floor(ba.getFrametime(false)*100)/100),10,10)--min Interval
lastclienstring=clientstring
local tmpinfogroups=clientstring:split(":|||:")
inf={}
for kii,wii in pairs(tmpinfogroups) do
for kyy,wyy in pairs(wii:split(":||:")) do
if inf[kii]==nil then inf[kii]={} end
if inf[kii][kyy]==nil then inf[kii][kyy]={} end
table.insert(inf[kii][kyy],wyy:split(":|:"))
inf[kii][kyy]=wyy:split(":|:")
end
end
--drawshipinfo(inf[1])
drawtargetinfo(inf[2])
drawradar(inf[3])
end
--timer=Timer()
--timer:start (100,true)
--timer.on_tick=function(timer)
-- update ()
--end
drawradar = function (radinf)
--bildschirmposition der radar mitte
local radarposx=500
local radarposy=50
--radius des radars
local radarradius=300
local rs = radarradius * 0.85, radarradius * 0.08
--mal 1.2 wegen dem deco rand des radars
local sc = rs/(radar_range*1.2)
gr.setColor(0,0,0,255)
gr.drawRectangle(radarposx,radarposy,radarposx+(radarradius*2),radarposy+(radarradius*2)+100,true)--hintergrund
--die datei befindet (bzw sollte) sich in "\data\interface\" und heisst "radar_bg.tga"
radarbg = gr.loadTexture("radar_bg")
if gr.drawImage(radarbg,radarposx,radarposy,radarposx+(radarradius*2),radarposy+(radarradius*2))==false then
--hübscher radar hintergrund konnte nicht gezeichnet werden, also zeichnen wir einfach einen kreis
gr.setColor(50,255,50,255)
gr.drawCircle(radarradius,radarposx+radarradius,radarposy+radarradius)
gr.setColor(0,0,0,255)
gr.drawCircle(radarradius-2,radarposx+radarradius,radarposy+radarradius)
end
radarbg:unload()
if sweeppos==nil or sweeppos>200 then sweeppos=0 end
local tmpswp=(sweeppos+150);
if tmpswp>200 then tmpswp=tmpswp-200 end
local cswpos=math.pi*(2-(tmpswp/100))
--den führenden sweep linie zeichnen
gr.setColor(150,170,50,125)
local sclnx=(radarposx+radarradius)+((radarradius/100*78)*math.sin(cswpos));
local sclny=(radarposy+radarradius)+((radarradius/100*78)*math.cos(cswpos));
gr.drawLine((radarposx+radarradius),(radarposy+radarradius),sclnx,sclny)
--den schwanz der sweep linie zeichen
for sw = 1, 150, 0.2 do
local tmpswp=(sweeppos+sw);
if tmpswp>200 then tmpswp=tmpswp-200 end
local swpos=math.pi*(2-(tmpswp/100))
gr.setColor(150,170,50,math.floor(50/150*sw))
local sclnx=(radarposx+radarradius)+((radarradius/100*78)*math.sin(swpos));
local sclny=(radarposy+radarradius)+((radarradius/100*78)*math.cos(swpos));
gr.drawLine((radarposx+radarradius),(radarposy+radarradius),sclnx,sclny)
end
sweeppos=sweeppos+1
--die radarobjekte zeichnen
local anzhost=0
local anzfrndl=0
local anzunkn=0
for kii,wii in pairs(radinf) do
--daten sind ok und blip ist innerhalb der radar range
if table.getn(wii)>1 and radar_range>math.floor(wii[5]) then
local xkoord = (wii[2]*sc)
local ykoord = -(wii[3]*sc)
local bxkoord = radarposx+radarradius+xkoord-13
local bykoord = radarposy+radarradius+ykoord-13
local abstand2d=math.sqrt(math.pow(math.abs(ykoord),2)+math.pow(math.abs(xkoord),2))
if xkoord<0 then
zwinkel=(math.pi*2)-math.acos(ykoord/abstand2d)
else
zwinkel=math.acos(ykoord/abstand2d)
end
if wii[6]=="1" then calpha=255
else calpha=125 end
gr.setColor(255,0,255,calpha)
local R,G,B,A
if wii[10] and wii[10]==1 then
R,G,B,A = 50,50,255,calpha
anzunkn=anzunkn+1
elseif wii[8] == "Hostile" or wii[8] == "Traitor" or wii[8] == "Neutral" then
R,G,B,A = 255,0,0,calpha
anzhost=anzhost+1
elseif wii[8] == "Friendly" then
R,G,B,A = 0,255,0,calpha
anzfrndl=anzfrndl+1
elseif wii[8] == "Unknown" then
R,G,B,A = 255,0,255,calpha
anzunkn=anzunkn+1
elseif wii[8] == "Asteroid" then
R,G,B,A = 155,155,155,calpha
anzunkn=anzunkn+1
else
R,G,B,A = 128,128,128,calpha
anzunkn=anzunkn+1
end
gr.setColor(R,G,B,A)
if wii[6]=="1" then
--falls es das target ist, dann durchgezogene umrandung
gr.drawRectangle(bxkoord,bykoord,bxkoord+26,bykoord+26,false)--umrandung
else
--nur ein normales radar objekt, kein target
--ecke oben links
gr.drawLine(bxkoord,bykoord,bxkoord+8,bykoord)
gr.drawLine(bxkoord,bykoord,bxkoord,bykoord+8)
--ecke oben rechts
gr.drawLine(bxkoord+17,bykoord,bxkoord+25,bykoord)
gr.drawLine(bxkoord+25,bykoord,bxkoord+25,bykoord+8)
--ecke unten links
gr.drawLine(bxkoord,bykoord+25,bxkoord+8,bykoord+25)
gr.drawLine(bxkoord,bykoord+17,bxkoord,bykoord+25)
--ecke unten rechts
gr.drawLine(bxkoord+25,bykoord+25,bxkoord+17,bykoord+25)
gr.drawLine(bxkoord+25,bykoord+17,bxkoord+25,bykoord+25)
end
gr.drawString(math.floor(wii[5]),bxkoord,bykoord-10)--entfernung
if wii[1]=="s" then
local textlaenge=math.ceil(math.max(string.len(wii[7]),string.len(wii[9]))*8.6)
--local textlaenge=math.ceil(math.max(gr.getStringWidth(wii[7]),gr.getStringWidth(wii[9])))
--gr.setColor(0,0,0,100)
--gr.drawRectangle(bxkoord+26,bykoord,bxkoord+26+textlaenge+30,bykoord+26,true)--texthintergrund
gr.drawLine(bxkoord+26,bykoord+13,bxkoord+26+textlaenge,bykoord+13)--texttrennlinie horizontal
if wii[6]=="1" then
gr.drawString(math.floor(math.abs(wii[4])),bxkoord+30+textlaenge,bykoord+10)--steigung
if math.floor(wii[4]) > 40 then
gr.drawLine(bxkoord+30+textlaenge,bykoord+8,bxkoord+30+textlaenge+20,bykoord+8)
gr.drawLine(bxkoord+30+textlaenge,bykoord+8,bxkoord+30+textlaenge+10,bykoord-2)
gr.drawLine(bxkoord+40+textlaenge,bykoord-2,bxkoord+30+textlaenge+20,bykoord+8)
elseif math.ceil(wii[4]) < -40 then
gr.drawLine(bxkoord+30+textlaenge,bykoord+20,bxkoord+30+textlaenge+20,bykoord+20)
gr.drawLine(bxkoord+30+textlaenge,bykoord+20,bxkoord+30+textlaenge+10,bykoord+30)
gr.drawLine(bxkoord+30+textlaenge+10,bykoord+30,bxkoord+30+textlaenge+20,bykoord+20)
end
end
gr.drawString(wii[7],bxkoord+30,bykoord+2)--schiffname
gr.drawString(wii[9],bxkoord+30,bykoord+18)--schiffklasse
end
local blipalpha=100
if zwinkel then
local blipfade
if zwinkel>cswpos then
blipfade=(math.pi*20)+math.floor(cswpos*10)-math.floor(zwinkel*10)
else
blipfade=math.floor(cswpos*10)-math.floor(zwinkel*10)
end
blipalpha=40+(140/62.82*blipfade)
--gr.drawString(blipfade,50,50)
end
gr.setColor(160,180,60,blipalpha-20)
gr.drawCircle(6,bxkoord+13+math.random(-1,1),bykoord+13+math.random(-1,1))--radarpunkt
gr.setColor(160,180,60,blipalpha-10)
gr.drawCircle(4,bxkoord+13+math.random(-1,1),bykoord+13+math.random(-1,1))--radarpunkt
gr.setColor(160,180,60,blipalpha+10)
gr.drawCircle(5,bxkoord+13+math.random(-1,1),bykoord+13+math.random(-1,1))--radarpunkt
gr.setColor(160,180,60,blipalpha+20)
gr.drawCircle(3,bxkoord+13+math.random(-1,1),bykoord+13+math.random(-1,1))--radarpunkt
end
end
--zusätzlicher infotext unterhalb des radars
local xoffs=150
gr.setColor(0,200,50,255)
gr.drawRectangle(radarposx+100+xoffs,radarposy+(radarradius*2)+22,radarposx+(radarradius*2)-150+xoffs,radarposy+(radarradius*2)+35,true)
local radarrangestring=""
if radar_range>1000 then
radarrangestring=(math.floor(radar_range/100)/10).." Km"
else
radarrangestring=radar_range.." m"
end
gr.setColor(0,0,0,255)
gr.drawRectangle(radarposx+209+xoffs,radarposy+(radarradius*2)+9,radarposx+212+xoffs,radarposy+(radarradius*2)+92,true)
gr.drawRectangle(radarposx+324+xoffs,radarposy+(radarradius*2)+9,radarposx+327+xoffs,radarposy+(radarradius*2)+92,true)
gr.drawString("Range: ",radarposx+150+xoffs,radarposy+(radarradius*2)+25)--range
gr.drawString("Objects: "..table.getn(radinf),radarposx+225+xoffs,radarposy+(radarradius*2)+25)--anzahl objekte
gr.drawString("Tech: "..table.getn(radinf),radarposx+365+xoffs,radarposy+(radarradius*2)+25)--deko
gr.setColor(0,200,50,255)
gr.drawString(radarrangestring,radarposx+150+xoffs,radarposy+(radarradius*2)+40)--range
gr.drawString(math.floor(((2*math.pi)-cswpos)*100),radarposx+345+xoffs,radarposy+(radarradius*2)+40)--techA
gr.drawString(math.floor(cswpos*100),radarposx+345+xoffs,radarposy+(radarradius*2)+55)--techB
gr.drawString(" / "..math.floor(cswpos*100),radarposx+375+xoffs,radarposy+(radarradius*2)+40)--techC
gr.drawString(" / "..math.floor(((2*math.pi)-cswpos)*100),radarposx+375+xoffs,radarposy+(radarradius*2)+55)--techD
gr.drawLine(radarposx+210+xoffs,radarposy+(radarradius*2)+10,radarposx+210+xoffs,radarposy+(radarradius*2)+90)--texttrennlinie vertikal
gr.drawLine(radarposx+325+xoffs,radarposy+(radarradius*2)+10,radarposx+325+xoffs,radarposy+(radarradius*2)+90)--texttrennlinie vertikal
gr.setColor(255,50,50,255)
gr.drawString("Hostile: "..anzhost,radarposx+225+xoffs,radarposy+(radarradius*2)+40)--anzahl objekte
gr.setColor(0,255,0,255)
gr.drawString("Friendly: "..anzfrndl,radarposx+225+xoffs,radarposy+(radarradius*2)+55)--anzahl objekte
gr.setColor(255,255,0,255)
gr.drawString("Unknown: "..anzunkn,radarposx+225+xoffs,radarposy+(radarradius*2)+70)--anzahl objekte
end
drawshipinfo = function(sinfo)
end
drawtargetinfo = function(tinfo)
--zeichnet die target-info box
local targetboxpositionx=50
local targetboxpositonY=100
local targetboxwidth=200
local targetboxheight=250
local targetrenderbreite=200
local targetrenderhoehe=200
local randabstand=5
local zeilenabstand=15
local targetrenderposx=targetboxpositionx
local targetrenderposy=targetboxpositonY+50
--umrandung
gr.setColor(50,250,50,100)
gr.drawRectangle(targetboxpositionx,targetboxpositonY,targetboxpositionx+targetboxwidth,targetboxpositonY+targetboxheight,false)
--hintergrund für die targetrenderbox
gr.setColor(50,250,50,25)
gr.drawRectangle(targetrenderposx,targetrenderposy,targetrenderposx+targetrenderbreite,targetrenderposy+targetrenderhoehe,true)
--hintergrund für die targetrenderbox
gr.setColor(50,250,50,50)
gr.drawRectangle(targetrenderposx+targetrenderbreite-38,targetrenderposy,targetrenderposx+targetrenderbreite,targetrenderposy+zeilenabstand,true)
gr.drawRectangle(targetrenderposx,targetrenderposy,targetrenderposx+targetrenderbreite-38,targetrenderposy+2,true)
gr.setColor(50,250,50,150)
gr.drawRectangle(targetrenderposx+targetrenderbreite-5,targetrenderposy+zeilenabstand,targetrenderposx+targetrenderbreite,targetrenderposy+targetrenderhoehe,true)
--team name scheint nicht zu funktionieren
if tinfo[1] == "Hostile" then gr.setColor(255,50,50,255)
elseif tinfo[1] == "Friendly" then gr.setColor(0,255,0,255)
elseif tinfo[1] == "Neutral" then gr.setColor(255,50,50,155)
elseif tinfo[1] == "Unknown" then gr.setColor(255,255,0,255)
end
if table.getn(tinfo) == 7 then
local calpha=255
local R,G,B,A
if wii[10] and wii[10]==1 then
R,G,B,A = 50,50,255,calpha
elseif wii[8] == "Hostile" or wii[8] == "Traitor" or wii[8] == "Neutral" then
R,G,B,A = 255,0,0,calpha
elseif wii[8] == "Friendly" then
R,G,B,A = 0,255,0,calpha
elseif wii[8] == "Unknown" then
R,G,B,A = 255,0,255,calpha
elseif wii[8] == "Asteroid" then
R,G,B,A = 155,155,155,calpha
else
R,G,B,A = 128,128,128,calpha
end
gr.setColor(R,G,B,A)
gr.drawString(tinfo[2][1].." ("..tinfo[1][1]..")",targetboxpositionx+randabstand,targetboxpositonY+randabstand)--name
gr.drawString(tinfo[3][1],targetboxpositionx+randabstand,targetboxpositonY+(zeilenabstand*1)+randabstand)--klasse
gr.drawString("D: "..tinfo[4][1],targetboxpositionx+randabstand,targetboxpositonY+(zeilenabstand*2)+randabstand)--entfernung
gr.drawString("S: "..tinfo[5][1],targetboxpositionx+randabstand+targetboxwidth-50,targetboxpositonY+(zeilenabstand*2)+randabstand)--geschwindigkeit
gr.setColor(50,250,50,255)
gr.drawString(tinfo[6][1].."%",targetboxpositionx+randabstand+targetboxwidth-40,targetboxpositonY+(zeilenabstand*3)+randabstand+randabstand)--hull integrity
local targetshiphandle = tb.ShipClasses[tinfo[3][1]]
if targetshiphandle ~= nil and targetshiphandle:isValid() and targetshiphandle:isInTechroom() then
targetshiphandle:isModelLoaded(true)
local tpostest=ba.createVector(tinfo[7][1],tinfo[7][2],tinfo[7][3]):getOrientation()
targetshiphandle:renderTechModel2(targetrenderposx,targetrenderposy,targetrenderposx+targetrenderbreite,targetrenderposy+targetrenderhoehe,tpostest,0.95)
end
else
gr.drawString("No Target",targetrenderposx+targetrenderbreite+50,targetboxpositonY+randabstand+50)
end
end
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end
update()
]
+Override: true
$On Key Pressed: [
kp=hv.Key
--gr.setColor(255,255,255,255)
--gr.drawString("Taste: "..hv.Key,50,50)
if hv.Key=="2" and radar_range<10000 then
radar_range = radar_range+500
elseif hv.Key=="1" and radar_range>500 then
radar_range = radar_range-500
end
]
#End
--- End code ---
Notes:
* the energy distribution does not work proberly, because the script just reads the (home,end,del,insert,pg down,pg up) keys and tries to replicate the energy settings.
* the display script is not yet styled in any way, it mostly just dumps the output in some form or the other ^^
* you need lua-socket librarys installed in your freespace game directory ( http://w3.impa.br/~diego/software/luasocket/introduction.html )
chief1983:
This looks awesome.
PoDo:
I hope that I get it working over the next weekend ^^
i've just played around a bit, and tried to draw some hud-images:
does the "drawMonochromeImage" function deliberately not stretch images (with the "drawImage" function i'm able to stretch images)?
//EDIT:
little screenshot added what i have for today. ^^
[attachment deleted by ninja]
MatthTheGeek:
What does "Tech" refer to ?
PoDo:
those are just some changing numbers (angles of the sweeping radar line), I just used them for debugging etc, but i thought they looked cool (the change pretty fast).
but the whole area beneath the radar needs some tinkering ^^
Navigation
[0] Message Index
[#] Next page
Go to full version