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 … 11 12 13 14 15 … 18 Next »
Making holograms en-masse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Making holograms en-masse
26-08-2015, 08:16 PM, (This post was last modified: 26-08-2015, 08:18 PM by Destiny's Player.)
#1
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
Making holograms en-masse
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.
Find
Reply
26-08-2015, 08:25 PM, (This post was last modified: 26-08-2015, 08:28 PM by SuperPlayer.)
#2
SuperPlayer Offline
TSCM Super Member
****
Posts: 234
Threads: 30
Joined: Oct 2014
RE: Making holograms en-masse
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.
Find
Reply
26-08-2015, 08:34 PM,
#3
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Making holograms en-masse
(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.
Find
Reply
26-08-2015, 08:43 PM, (This post was last modified: 26-08-2015, 08:47 PM by Destiny's Player.)
#4
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: Making holograms en-masse
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?
Find
Reply
26-08-2015, 08:52 PM,
#5
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Making holograms en-masse
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).
Find
Reply
26-08-2015, 09:06 PM,
#6
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: Making holograms en-masse
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.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


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

Powered By MyBB, © 2002-2026 MyBB Group.