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 »
Timer/whatever problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
Timer/whatever problem
01-10-2015, 05:56 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Timer/whatever problem
Timers are asynchronous. You're running your check before the timer has even run. You need to wait until it's finished, then check. Also, you're leaking global variables in that getResources function, there's no need for them to be global.

        function getResources()
local Constr = Self:getConstraints()
local i = 0
timer.create("Res",0.01,#Constr,function()
i=i+1
Cur = Constr[i]
printConsole(Cur:class())
if Cur:class() == "ship_core" then
SCore = Cur
Co1 = 1
printColor(Color(255,255,255),"Ship Core Found")
printConsole(SCore)
elseif Cur:class() == "stargazer_node" then
Node = Cur
No1 = 1
printColor(Color(255,150,150),"Resource Node Found")
printConsole(Node)
elseif Cur:class() == "st_shield_emitter" then
Shield = Cur
Sh1 = 1
printColor(Color(100,200,250),"Shield Emitter Found")
printConsole(Shield)
elseif Cur:class() == "sensor_array" then
Sensor = Cur
Se1 = 1
printColor(Color(100,250,100),"Sensor Array Found")
printConsole(Sensor)
end
if i == #Const then
-- Now check your values (probably in another function so this one doesn't become a mammoth).
end
end)
AllCores = find.byClass("ship_core")
for i=1,#AllCores do
printConsole(AllCores[i])
AllCoresOwn[i] = AllCores[i]:owner()
printConsole(AllCoresOwn[i]:name():lower())
end
end
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
Timer/whatever problem - by Destiny's Player - 01-10-2015, 03:29 PM
RE: Timer/whatever problem - by Person8880 - 01-10-2015, 05:56 PM
RE: Timer/whatever problem - by Destiny's Player - 01-10-2015, 06:05 PM

  • 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.