Team Spartan Cookies & Milk Forums
Running out of Ops when simply setting a holograms material - 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: Running out of Ops when simply setting a holograms material (/thread-1373.html)



Running out of Ops when simply setting a holograms material - Destiny's Player - 02-10-2015

Basically that. What in the world?
Spoiler Expand

--@name Power Turbine
--@author The Next Decade
--@model models/hunter/blocks/cube025x025x025.mdl

Self = ents.self()
Owner = ents.owner()

SpawnFinished = 0

SelfPos = Self:pos()
SelfAng = Self:ang()
SelfCon = Self:getConstraints()

Spin1C = 0
Spin2C = 0
Spin3C = 0

Node = nil
WireNode = nil

Start = 0

function starting()
Turbine = holograms.create(SelfPos,SelfAng,"models/Mechanics/gears2/gear_12t3.mdl",Vector(1.3,1.3,2))
TurbineConfusedetMaterial("sprops/textures/sprops_chrome")

TurbinePower = holograms.create(SelfPos,SelfAng,"models/Mechanics/gears2/gear_12t3.mdl",Vector(1.5,1.5,2))
TurbinePowerConfusedetMaterial("models/alyx/emptool_glow")
TurbinePowerConfusedetColor(255,200,100)
TurbinePowerConfusedetAlpha(0)

BallPower = holograms.create(SelfPos,SelfAng,"models/sprops/geometry/sphere_84.mdl",0.9)
BallPowerConfusedetMaterial("models/alyx/emptool_glow")
BallPowerConfusedetColor(255,200,100)
BallPowerConfusedetAlpha(0)

BallFusion = holograms.create(SelfPos,SelfAng,"models/sprops/geometry/sphere_84.mdl",0.85)
BallFusionConfusedetMaterial("spacebuild/Fusion")
BallFusionConfusedetAlpha(0)

Sound1 = sounds.create(Self,"ambient/wind/underground_wind_lp_01.wav")
Sound2 = sounds.create(Self,"br/ambience/gas_release_lp.wav")

Sound1:play()
Sound2:play()

print("Hologram set up finished")
SpawnFinished = 1
end

starting()

if SpawnFinished == 1 then
SelfCon = Self:getConstraints()
local i = 0
timer.create("NodeGet",0.1,#SelfCon,function()
i = i+1
printConsole(SelfCon[i]:class())
if SelfCon[i]:class() == "stargazer_node" then
Node = SelfCon[i]
WireNode = Node:getWirelink()
print("Node Found")
Start = 1
timer.remove("NodeGet")
return
end
error("No node found")
end)

if Start ~= 0 then
timer.create("refresh",0.1,0,function()
if Node ~= nil and WireNode["Max Energy"] ~= 0 then
Sound1ConfusedetVolume(1/WireNode["Max Energy"]*WireNode["Energy"])
Sound2ConfusedetVolume(0.6/WireNode["Max Energy"]*WireNode["Energy"])
Sound2ConfusedetPitch(10/WireNode["Max Energy"]*WireNode["Energy"]+math.random(1))
AlphaFusion = 150/WireNode["Max Energy"]*WireNode["Energy"]
AlphaPower = 255/WireNode["Max Energy"]*WireNode["Energy"]
BallSize = 0.9+(math.random()/20)

Spin1 = 10/WireNode["Max Energy"]*WireNode["Energy"]
Spin1C = Spin1C + Spin1
Spin2 = 15/WireNode["Max Energy"]*WireNode["Energy"]
Spin2C = Spin2C + Spin2
Spin3 = 20/WireNode["Max Energy"]*WireNode["Energy"]
Spin3C = Spin3C + Spin3

if Spin1C > 360 then
Spin1C = 0
end
if Spin2C > 360 then
Spin2C = 0
end
if Spin3C > 360 then
Spin3C = 0
end

TurbineConfusedetAng(Angle(0,Spin3C,0))
TurbinePowerConfusedetAng(Angle(0,Spin3C,0))
TurbinePowerConfusedetAlpha(AlphaPower)

BallPowerConfusedetAng(Angle(Spin3C,Spin1C,Spin2C))
BallPowerConfusedetAlpha(AlphaPower)
BallPowerConfusedetScale(BallSize)
BallFusionConfusedetAng(Angle(Spin3C,Spin1C,Spin2C))
BallFusionConfusedetAlpha(AlphaFusion)
BallFusionConfusedetScale(BallSize-0.05)
end
end)
end
end



RE: Running out of Ops when simply setting a holograms material - Person8880 - 03-10-2015

Creating entities (i.e. creating the holograms) is massively costly since a GMod update from last year. You're hitting it in setMaterial purely by co-incidence, it's the creation that's eating the quota.


RE: Running out of Ops when simply setting a holograms material - TheOneAndOnlyTee - 03-10-2015

Worked fine when i spawned it though


RE: Running out of Ops when simply setting a holograms material - Red The Blue Color - 03-10-2015

(03-10-2015, 11:26 AM)T-17 Wrote: Worked fine when i spawned it though

I say moderator cheatz lol


RE: Running out of Ops when simply setting a holograms material - Destiny's Player - 03-10-2015

Okay, it seems that ALL of my screens that use auto-wirelink crash out of Ops shortage when I try to connect them to my 1041 entity ship.


RE: Running out of Ops when simply setting a holograms material - Person8880 - 03-10-2015

(03-10-2015, 04:21 PM)Destinys Player Wrote: my 1041 entity ship.
There's your problem. That's a lot of entities (what even needs that many?) and so you're not going to be able to go through the constraints with the standard getConstraints() method without hitting the quota.

Look into getSingleConstrainedEnts(), and avoiding trying to find all constraints all at once.


RE: Running out of Ops when simply setting a holograms material - Destiny's Player - 03-10-2015

Person8880 Wrote:That's a lot of entities (what even needs that many?)

A big ship with a highly detailed interior.

Thanks a lot, though, I'll look into this function.