Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 14 15 16 17 18 Next »
Release Resource screen
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Release Resource screen
26-04-2015, 10:27 PM,
#1
LocInt Offline
Long gone
****
Posts: 489
Threads: 91
Joined: Aug 2014
Resource screen
Here is my autolinking resource screen. Just paste it on your ship and it will show your resource amounts. Smile remember to download string lib from shared folder.

Enjoy!

Code:
--@name LocTECH_resources --@author Locint --@sharedscreen --@require lib/string.txt if(CLIENT) then local tex = render.getTextureID("Boba_Fett/textures/atlantisfloor_white") Data = {} Data.Resources = { } Data.Resources.EnergyCur=0 Data.Resources.EnergyMax=0 Data.Resources.WaterCur=0 Data.Resources.WaterMax=0 Data.Resources.OxygenCur=0 Data.Resources.OxygenMax=0 Data.Resources.DeuteriumCur=0 Data.Resources.DeuteriumMax=0 Data.colors = {} Data.colors.ceeeeee = Vector(238,238,238) Data.colors.blue1 = Vector(16,39,57) Data.colors.blue2 = Vector(29,110,125) Fonts = {} Fonts.basic = {} Fonts.basic.trebuchet16 = render.createFont("Trebuchet", 16) Fonts.basic.trebuchet12 = render.createFont("Trebuchet", 12) function sColor(Color) render.setColor(Color.x, Color.y, Color.z) end function sColorAlpha(Color, Alpha) render.setColor(Color.x, Color.y, Color.z, Alpha) end function drawTexturedCRect(x,y,w,h) render.drawTexturedRect(x-w/2,y-h/2,w,h) end function drawCRect(x,y,w,h) render.drawRect(x-w/2,y-h/2,w,h) end function drawTexturedScalingBarWithBackground(x,y,size,width,gap,value,color1,color2,Alpha1,Alpha2,bearing) if(Alpha1~=nil) then sColorAlpha(color1,Alpha1) else sColor(color1) end if(bearing==1) then drawTexturedCRect(x+gap,y,width,size) elseif(bearing==2) then drawTexturedCRect(x,y+gap,size,width) end if(Alpha2~=nil) then sColorAlpha(color2,Alpha2) else sColor(color2) end if(bearing==1) then drawTexturedCRect(x+gap,y+((size/2)*(1-value)),width,size*value) elseif(bearing==2) then drawTexturedCRect(x+((size/2)*(1-value)),y+gap,size*value,width) end end function renderScreen() render.clear() sColor(Data.colors.blue2) render.setTexture(tex) drawTexturedCRect(256,256,512,512) render.setTexture() local E = Data.Resources.EnergyCur/Data.Resources.EnergyMax local W = Data.Resources.WaterCur/Data.Resources.WaterMax local O = Data.Resources.OxygenCur/Data.Resources.OxygenMax local D = Data.Resources.DeuteriumCur/Data.Resources.DeuteriumMax sColorAlpha(Data.colors.blue2, 90) drawCRect(256,200,440,256) drawCRect(256,411,440,80) sColor(Data.colors.ceeeeee) render.drawText(Fonts.basic.trebuchet16, 67, 127, "Energy", 1) render.drawText(Fonts.basic.trebuchet16, 67+(63*2), 127, "Water", 1) render.drawText(Fonts.basic.trebuchet16, 67+(63*4), 127, "Oxygen", 1) render.drawText(Fonts.basic.trebuchet16, 67+(63*6), 127, "Deuterium", 1) render.drawText(Fonts.basic.trebuchet12, 48, 380, "Energy:", render.TEXT_ALIGN_LEFT) render.drawText(Fonts.basic.trebuchet12, 48, 380*1.04, "Water:", render.TEXT_ALIGN_LEFT) render.drawText(Fonts.basic.trebuchet12, 48, 380*1.08, "Oxygen:", render.TEXT_ALIGN_LEFT) render.drawText(Fonts.basic.trebuchet12, 48, 380*1.12, "Deuterium:", render.TEXT_ALIGN_LEFT) render.drawText(Fonts.basic.trebuchet12, 120, 380, tostring(string.format( "%.2f", E*100).."%", render.TEXT_ALIGN_LEFT)) render.drawText(Fonts.basic.trebuchet12, 120, 380*1.04, tostring(string.format( "%.2f",W*100).."%", render.TEXT_ALIGN_LEFT)) render.drawText(Fonts.basic.trebuchet12, 120, 380*1.08, tostring(string.format( "%.2f",O*100).."%", render.TEXT_ALIGN_LEFT)) render.drawText(Fonts.basic.trebuchet12, 120, 380*1.12, tostring(string.format( "%.2f",D*100).."%", render.TEXT_ALIGN_LEFT)) drawTexturedScalingBarWithBackground(67,235,180,58,0,E,Data.colors.blue1,Data.colors.ceeeeee,90,1000,1) drawTexturedScalingBarWithBackground(67,235,180,58,63*2,W,Data.colors.blue1,Data.colors.ceeeeee,90,1000,1) drawTexturedScalingBarWithBackground(67,235,180,58,63*4,O,Data.colors.blue1,Data.colors.ceeeeee,90,1000,1) drawTexturedScalingBarWithBackground(67,235,180,58,(63*6)-1,D,Data.colors.blue1,Data.colors.ceeeeee,90,1000,1) --Smart info render.drawText(Fonts.basic.trebuchet16, 256, 465, "Made By LocInt", 1) render.drawText(Fonts.basic.trebuchet12, 15, 495, "CPU Time: "..math.round(cpuAverage()/cpuMax()*100, 2).."% ", render.TEXT_ALIGN_LEFT ) render.drawText(Fonts.basic.trebuchet12, 495, 495, "OPS: "..math.round(opsUsed()/opsMax()*100, 2).."% ", render.TEXT_ALIGN_RIGHT ) end function receiveMessage(Length) local Type = net.readString() if(Type=="1") then local Resources=StringExplode(net.readString(),"|") Data.Resources.EnergyCur=tonumber(Resources[1]) Data.Resources.EnergyMax=tonumber(Resources[2]) Data.Resources.WaterCur=tonumber(Resources[3]) Data.Resources.WaterMax=tonumber(Resources[4]) Data.Resources.OxygenCur=tonumber(Resources[5]) Data.Resources.OxygenMax=tonumber(Resources[6]) Data.Resources.DeuteriumCur=tonumber(Resources[7]) Data.Resources.DeuteriumMax=tonumber(Resources[8]) end end hook( "render", "Render", renderScreen) hook( "net", "trustedChannel", receiveMessage) else --Just sending data to client local function sendToClient(Chip, Messagetype, Message, Entity) net.start() net.writeString(Messagetype) net.writeString(Message) net.broadcast() end --Lets update the resources to the screen local function updateResources() if(IsValid(Node1)) then local EnCur=Node1["Energy"] local EnMax=Node1["Max Energy"] local WaCur=Node1["Water"] local WaMax=Node1["Max Water"] local OxCur=Node1["Oxygen"] local OxMax=Node1["Max Oxygen"] local DeCur=Node1["Deuterium"] local DeMax=Node1["Max Deuterium"] local EActive = EnergyCore1["Active"] local RActive = RefCore1["Active"] sendToClient(ents.self(),"1",EnCur.."|"..EnMax.."|"..WaCur.."|"..WaMax.."|"..OxCur.."|"..OxMax.."|"..DeCur.."|"..DeMax.."|"..EActive.."|"..RActive, ents.self()) --print(EnCur.."|"..EnMax.."|"..WaCur.."|"..WaMax.."|"..OxCur.."|"..OxMax.."|"..DeCur.."|"..DeMax) end end --We unlink node so we can link it back again local function checkNode() if(Nodes and IsValid(Nodes[1])) then Nodes[1]:unlink() end if(Nodes and IsValid(Nodes[2])) then Nodes[2]:unlink() end end local function divertPower() if(IsValid(WaterCollector1)) then WaterCollector1.Activate=0 end if(IsValid(WaterCollector2)) then WaterCollector2.Activate=0 end end channels.listen("trustedChannel",function(Chip, Resource, Percent, Entity) if(Resource=="1" or Resource=="2" or Resource=="3") then if(Entity:index()==ents.self():index()) then if(Resource=="1") then divertPower() elseif(Resource=="2") then checkNode() end end end end) local function begin() ShipCores = find.byClass( "ship_core", function( Ent ) return Ent:owner() == ents.owner() end ) Nodes = find.byClass( "stargazer_node", function( Ent ) return Ent:owner() == ents.owner() end ) ResourceWaters = find.byClass( "quantum_slipstream_drive", function( Ent ) return Ent:owner() == ents.owner() end ) RefCores = find.byClass( "stargazer_refinement_core", function( Ent ) return Ent:owner() == ents.owner() end ) WaterCollectors = find.byClass( "st_shield_emitter", function( Ent ) return Ent:owner() == ents.owner() end ) EnergyCores = find.byClass( "stargazer_energy_core", function( Ent ) return Ent:owner() == ents.owner() end ) WaterCores = find.byClass( "stargazer_water_core", function( Ent ) return Ent:owner() == ents.owner() end ) if(IsValid(ShipCores[1])) then ShipCore1 = ShipCores[1]:getWirelink() end if(IsValid(ShipCores[2])) then ShipCore2 = ShipCores[2]:getWirelink() end if(IsValid(Nodes[1])) then Node1 = Nodes[1]:getWirelink() end if(IsValid(Nodes[2])) then Node2 = Nodes[2]:getWirelink() end if(IsValid(ResourceWaters[1])) then ResourceWater1 = ResourceWaters[1]:getWirelink() end if(IsValid(ResourceWaters[2])) then ResourceWater2 = ResourceWaters[2]:getWirelink() end if(IsValid(RefCores[1])) then RefCore1 = RefCores[1]:getWirelink() end if(IsValid(RefCores[2])) then RefCore2 = RefCores[2]:getWirelink() end if(IsValid(WaterCollectors[1])) then WaterCollector1 = WaterCollectors[1]:getWirelink() end if(IsValid(WaterCollectors[2])) then WaterCollector2 = WaterCollectors[2]:getWirelink() end if(IsValid(EnergyCores[1])) then EnergyCore1 = EnergyCores[1]:getWirelink() end if(IsValid(EnergyCores[2])) then EnergyCore2 = EnergyCores[2]:getWirelink() end if(IsValid(WaterCores[1])) then WaterCore1 = WaterCores[1]:getWirelink() end if(IsValid(WaterCores[2])) then WaterCore2 = WaterCores[2]:getWirelink() end end timer.create( "updateResources", 1, 0, function() updateResources() channels.send("trustedChannel", "99", tostring(ents.self():index()),ents.self()) end) timer.create( "begin", 1, 1, function() begin() end) end

тѕсм.Person8880 hovers the nerf bat over Tetryon damage
Website Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.