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, 03:29 PM, (This post was last modified: 01-10-2015, 03:31 PM by Destiny's Player.)
#1
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
Timer/whatever problem
I can't figure out, why won't the part under an "if all of these are equal to 1 then do" thingie work, even though I've checked, the entities are gotten. Are variables that are stuck under a timer always local to it? Or something else?

Spoiler Expand

function chatMenu(msg,ply)
local Message = msg:lower():explode(" ")
if Message[1] == "!page" or Message[1] == "/page" or Message[1] == "page" then
Page = tonumber(Message[2])
end
end

function tactical(msg,ply)
local Message = msg:lower():explode(" ")
if Message[1] == "!shield" or Message[1] == "/shield" or Message[1] == "shield" then
if Alert < 1 then
print("Alert level is too low")
return
end
if Message[2] == "on" then
Shield["Activate"] = 1
--print("Shield turned on")
elseif Message[2] == "off" then
Shield["Activate"] = 0
--print("Shield turned off")
elseif Message[2] == "balance" then
Shield["Divert Power"] = -1
ShDivert = -1
--print("Shields prioritized to all sides")
elseif Message[2] == "separate" then
Shield["Divert Power"] = 0
ShDivert = 0
--print("Shields prioritized to no sides")
elseif Message[2] == "front" then
Shield["Divert Power"] = 1
ShDivert = 3
--print("Shields prioritized to the front")
elseif Message[2] == "back" then
Shield["Divert Power"] = 2
ShDivert = 4
--print("Shields prioritized to the back")
elseif Message[2] == "left" then
Shield["Divert Power"] = 3
ShDivert = 1
--print("Shields prioritized to the left")
elseif Message[2] == "right" then
Shield["Divert Power"] = 4
ShDivert = 2
--print("Shields prioritized to the right")
elseif Message[2] == "up" then
Shield["Divert Power"] = 5
ShDivert = 5
--print("Shields prioritized to the top")
elseif Message[2] == "down" then
Shield["Divert Power"] = 6
ShDivert = 6
--print("Shields prioritized to the bottom")
end
elseif Message[1] == "!target" or Message[1] == "/target" or Message[1] == "target" then
if Alert < 1 then
print("Alert level is too low")
return
end
local Tgt = Message[2]
for i=1,#AllCoresOwn do
local Found = string.find(AllCoresOwn[i]:name():lower(),Tgt)
if Found ~= nil then
Sensor["Target"] = AllCores[i]
TgtName = AllCoresOwn[i]:name()
return
end

end
print("No cores belonging to "..Tgt.." found.")
end
if Message[1] == "!alert" or Message[1] == "/alert" or Message[1] == "alert" then
if Message[2] == "green" then
Alert = 0
Shield["Activate"] = 0
Sensor["Target"] = nil
print("Alert is set to "..Message[2].."\nShields and weapons are blocked")
elseif Message[2] == "yellow" then
Alert = 1
print("Alert is set to "..Message[2].."\nShields are unlocked, weapons are blocked")
elseif Message[2] == "red" then
Alert = 2
print("Alert is set to "..Message[2].."\nShields and weapons are unlocked")
end
end
end

function getResources()
Constr = Self:getConstraints()
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
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

Page = 2
SCore = nil
Co1 = 0
Node = nil
No1 = 0
Shield = nil
Sh1 = 0
Sensor = nil
Se1 = 0
Alert = 0
AllCores = {}
AllCoresOwn = {}
ShDivert = 0
Plating = 0

TgtHealthMax = 0
TgtHealth = 0
TgtArmor = 0
TgtShieldOn = 0
TgtShieldMax = 0
TgtShield = 0
TgtName = ""

getResources()
if Co1 == 1 and No1 == 1 and Sh1 == 1 and Se1 == 1 then
printColor(Color(255,200,0),"Resources Assigned")
Sensor["Target"] = nil

chat.listen(chatMenu,Owner)
chat.listen(tactical,Owner)

timer.create("Refresh",1,0,function()
HPFull = SCore:getWirelink()["Max Health"]
HP = SCore:getWirelink()["Health"]
Plating = SCore:getWirelink()["Plating"]
ArmourMax = SCore:getWirelink()["Armour"]
Armour = SCore:getWirelink()["Armour Deployed"]

EnergyFull = Node:getWirelink()["Max Energy"]
Energy = Node:getWirelink()["Energy"]

ShChargeFull = Shield:getWirelink()["Max Charge"]
ShCharge = Shield:getWirelink()["Total Charge"]

ShLeft = Shield:getWirelink()["Left"]
ShRight = Shield:getWirelink()["Right"]
ShFront = Shield:getWirelink()["Front"]
ShBack = Shield:getWirelink()["Back"]
ShUp = Shield:getWirelink()["Up"]
ShDown = Shield:getWirelink()["Down"]

TgtHealthMax = Sensor:getWirelink()["Max Health"]
TgtHealth = Sensor:getWirelink()["Health"]
TgtArmor = Sensor:getWirelink()["Plating"]
TgtShieldOn = Sensor:getWirelink()["Shield Active"]
TgtShieldMax = Sensor:getWirelink()["Max Shields"]
TgtShield = Sensor:getWirelink()["Shield Emitter"]


for i=1,#AllCores do
AllCores = find.byClass("ship_core")
if AllCores[i] ~= nil and AllCores[i]:owner() ~= nil then
AllCoresOwn[i] = AllCores[i]:owner()
end
--printConsole(AllCoresOwn[i]:name():lower())
end
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.