There's no reason for these to not work. Try defining the functions (inGame, isPlaying, etc) in the drill script. So copy and paste them from the globals into the drill script (leave a copy in the globals though) and see then. Weird.

-----------------------
--- REQUIRED GLOBALS --
-----------------------
-- IS SINGLEPLAYER
function isSinglePlayer()
return Global.game_settings.single_player or false
end
-- INGAME CHECK
function inGame()
if not game_state_machine then return false end
return string.find(game_state_machine:current_state_name(), "game")
end
-- IS PLAYING CHECK
function isPlaying()
if not BaseNetworkHandler then return false end
return BaseNetworkHandler._gamestate_filter.any_ingame_playing[ game_state_machine:last_queued_state_name() ]
end
------------
--- GAME ---
------------
if not AutoDrillRepair then
if inGame() and isPlaying() and isSinglePlayer() then
if not _drillsetjammed then
if not Drill then return end
if Drill then
_drillsetjammed = Drill.set_jammed
end end
drillautorep = drillautorep or function()
if managers.player then
local player = managers.player:local_player()
function Drill:set_jammed( jammed )
_drillsetjammed(self,jammed)
if self._unit:interaction() then
self._unit:interaction():interact( player )
end end end end
drillautorep()
end
AutoDrillRepair = true
end

Quote:

Originally Posted by B1313

There's no reason for these to not work. Try defining the functions (inGame, isPlaying, etc) in the drill script. So copy and paste them from the globals into the drill script (leave a copy in the globals though) and see then. Weird.

It seems that the drill is running before globals is intitialized, I posted a working fix for him

-----------------------
--- REQUIRED GLOBALS --
-----------------------
-- IS SINGLEPLAYER
function isSinglePlayer()
return Global.game_settings.single_player or false
end
-- INGAME CHECK
function inGame()
if not game_state_machine then return false end
return string.find(game_state_machine:current_state_name(), "game")
end
-- IS PLAYING CHECK
function isPlaying()
if not BaseNetworkHandler then return false end
return BaseNetworkHandler._gamestate_filter.any_ingame_playing[ game_state_machine:last_queued_state_name() ]
end
------------
--- GAME ---
------------
if not AutoDrillRepair then
if inGame() and isPlaying() and isSinglePlayer() then
if not _drillsetjammed then
if not Drill then return end
if Drill then
_drillsetjammed = Drill.set_jammed
end end
drillautorep = drillautorep or function()
if managers.player then
local player = managers.player:local_player()
function Drill:set_jammed( jammed )
_drillsetjammed(self,jammed)
if self._unit:interaction() then
self._unit:interaction():interact( player )
end end end end
drillautorep()
end
AutoDrillRepair = true
end

It seems that the drill is running before globals is intitialized, I posted a working fix for him

Yep, that should work at the minimum or he's doing something else lol

Quote:

Originally Posted by acepilot1023978

Do you think, perhaps, that putting his globals as a FirstRunScript: would resolve the issue?

I think SGS is right, it's trying to call the global function before the globals are initialized..

Weird, because I had the same issue with some other scripts and it was usually my error. Weird.

I went thru my other persists and saw that I had the global functions in them so I must of came across this error a while back but it certainly is weird

Should try that out, does it run persistent tho if its done like that?

I don't think first run will solve the problem. You could do what I did in the past with my Stealth Suite Sub Core. Make 1 persistent script which contains dofiles to the other persistent scripts, but only have 1 entry in the Persistent scripts section of the yml.

Should try that out, does it run persistent tho if its done like that?

When you use the correct testvar, the script only runs once anyway. Because you are specifying:

Code:

if not TestVar then
TestVar = true
end

Once TestVar = true, it doesn't fulfill the requirement of "if not TestVar"

Quote:

Originally Posted by B1313

I don't think first run will solve the problem. You could do what I did in the past with my Stealth Suite Sub Core. Make 1 persistent script which contains dofiles to the other persistent scripts, but only have 1 entry in the Persistent scripts section of the yml.

I just tested globals as a first run, and it works in regards to keybound scripts etc, but not for persistent.

The persistent scripts are run before the firstrun, so that wouldn't help the issue.

I don't think first run will solve the problem. You could do what I did in the past with my Stealth Suite Sub Core. Make 1 persistent script which contains dofiles to the other persistent scripts, but only have 1 entry in the Persistent scripts section of the yml.

That what happens when you fill your globals file with keybind scripts that have lazy first-run workarounds 'if not value then return end'... or as I like to call them 'B1313 fixes'...

Got something constructive to say or you just want to start a flame war? You need to get yourself in check or I will do it for you. I have tolerated your stuff for a long time but you seem to think it's ok to say anything you want about me and try to provoke a fight...that's not going to happen.

On-topic: Yeah, he did. We all also mentioned he needs to remove portions in his globals. So please read the topic a little bit more next time

-----------------------
--- REQUIRED GLOBALS --
-----------------------
-- IS SINGLEPLAYER
function isSinglePlayer()
return Global.game_settings.single_player or false
end
-- INGAME CHECK
function inGame()
if not game_state_machine then return false end
return string.find(game_state_machine:current_state_name(), "game")
end
-- IS PLAYING CHECK
function isPlaying()
if not BaseNetworkHandler then return false end
return BaseNetworkHandler._gamestate_filter.any_ingame_playing[ game_state_machine:last_queued_state_name() ]
end
------------
--- GAME ---
------------
if not AutoDrillRepair then
if inGame() and isPlaying() and isSinglePlayer() then
if not _drillsetjammed then
if not Drill then return end
if Drill then
_drillsetjammed = Drill.set_jammed
end end
drillautorep = drillautorep or function()
if managers.player then
local player = managers.player:local_player()
function Drill:set_jammed( jammed )
_drillsetjammed(self,jammed)
if self._unit:interaction() then
self._unit:interaction():interact( player )
end end end end
drillautorep()
end
AutoDrillRepair = true
end