Team Spartan Cookies & Milk Forums
Making holograms en-masse - 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: Making holograms en-masse (/thread-1288.html)



Making holograms en-masse - Destiny's Player - 26-08-2015

Basically, I need to create a bunch of holograms in a single for loop. As in, for the whole ship. But the whole chip dies of Ops starvation, and I can't figure out how to make it pause for a moment between operations. Could anybody help me with that?

Here's the part of the code I try to make. Consts contains all the entities in the ship.

function warpHolo()
if Self:getParent() ~= nil then
local PSelf = Self:getParent()
if Created ~=1 then
WarpField = holograms.create(PSelf:pos(),PSelf:ang()+Angle(90,0,0),
"models/holograms/torus3.mdl",Vector(50,50,50))
WarpGen = {}
WarpGenCap = {}
for i=1,#Consts do
sleep(1)
WarpGen[i] = holograms.create(Consts[i]:pos(),Consts[i]:ang(),
Consts[i]:model(),1.2)
sleep(1)
WarpGen[i]ConfusedetMaterial("models/props_combine/stasisfield_beam")
sleep(1)
WarpGen[i]ConfusedetColor(150,150,255)
sleep(1)
WarpGen[i]ConfusedetAlpha(100)
end

WarpFieldConfusedetMaterial("models/props_combine/portalball001_sheet")
WarpFieldConfusedetAlpha(0)
Created = 1
end
WarpFieldConfusedetPos(PSelf:pos())
WarpFieldConfusedetAng(PSelf:ang()+Angle(90,0,0))
end
end

And here's the sleep function.

function sleep(secs)
timer.simple(secs,function()
printConsole("Sleep finished")
end)
end

P.S. The ship I'm trying to do this with is the size of a Mk 11 shuttle, but with proper pauses, I don't think that size will make much of a difference.


RE: Making holograms en-masse - SuperPlayer - 26-08-2015

The only way I can think of right now is doing something like creating a timer and do a loop manuel. Like:


local Count = 0
timer.create("Holos",0.5,#Consts,function()
Count = Count+1
--Create your holos here

end)

In this example use Count as i in a loop
Edit:
Keep in mind that there is also a holo limit. If you are moving the holos you might wanna parent them to the prop it represents.


RE: Making holograms en-masse - Person8880 - 26-08-2015

(26-08-2015, 08:16 PM)Destinys Player Wrote: And here's the sleep function.

function sleep(secs)
timer.simple(secs,function()
printConsole("Sleep finished")
end)
end
This is not how timers or the threading model of the game works at all.

Everything (except maybe a few minor things) in the game is contained in a single thread. Rendering, internal C++ logic and Lua scripts. If something were to "sleep" in the way you're thinking of, your game would freeze up until it finished.

What the timer actually does, is call the function you passed after the given delay. It doesn't stop anything, it just delays whatever's in the function.

SuperPlayer's solution will probably work. The timers created by timer.create() are repeated but otherwise have the same principle.


RE: Making holograms en-masse - Destiny's Player - 26-08-2015

Hmm... Tried to do this:

local Count = 0
WarpGen = {}
timer.create("HoloMakes",0.5,#Consts,function()
Count = Count+1
WarpGen[Count] = holograms.create(Consts[Count]:pos(),Consts[Count]:ang(),
Consts[Count]:model(),1.2)()
WarpGen[Count]ConfusedetMaterial("models/props_combine/stasisfield_beam")
WarpGen[Count]ConfusedetColor(150,150,255)
WarpGen[Count]ConfusedetAlpha(100)
end)

But it kills the chip at the part where I set the hologram's model (line 7), like it did before with Ops, but this time with "Attempt to call a table value". Any way to fix this?


RE: Making holograms en-masse - Person8880 - 26-08-2015

Your problem is here:
holograms.create(Consts[Count]:pos(),Consts[Count]:ang(), Consts[Count]:model(),1.2)()
Notice what you have at the end?

You're trying to "call" the hologram you created (which in Starfall is represented by a special kind of table, that's why it says table).


RE: Making holograms en-masse - Destiny's Player - 26-08-2015

Ha! So it was a typo. Thank you very much, it works now, and with that Warp Field, I think that my special effects chip is finished.