Nebula Posted November 22, 2020 Share Posted November 22, 2020 function SearchGenerator(player) local player = getSpecificPlayer(0); local shutdown local generator if SandboxVars.ElecShutModifier >= -1 and GameTime:getInstance():getNightsSurvived() > SandboxVars.ElecShutModifier then shutdown = true; elseif GameTime:getInstance():getNightsSurvived() <= SandboxVars.ElecShutModifier then shutdown = false; end local zoneSize = 2; for z = 0, 3 do for x = player:getSquare():getX() - zoneSize, player:getSquare():getX() + zoneSize do for y = player:getSquare():getY() - zoneSize, player:getSquare():getY() + zoneSize do local Square = player:getCell():getGridSquare(x, y, z); if Square and Square:getGenerator() and Square:getGenerator():isActivated() then generator = true; end end end end end There were no problems with finding an included generator. But how to determine the presence of electricity in a cell? Link to comment Share on other sites More sharing options...
Nebula Posted November 22, 2020 Author Share Posted November 22, 2020 I figured it out ... need to use - getSquare():haveElectricity() But now I have the next question. Why, before the global power outage, is there a lack of electricity in the cells, although the lights are on and the refrigerators are working? Link to comment Share on other sites More sharing options...
Asilar Posted November 22, 2020 Share Posted November 22, 2020 I think it's because there is a special state about that general electricity. getSandboxOptions():getElecShutModifier() then you can compare with getGameTime():getWorldAgeHours() You also could check in the Sewing Machine mod, there are some code that checks for power if I remember well. Link to comment Share on other sites More sharing options...
Nebula Posted November 23, 2020 Author Share Posted November 23, 2020 Anyway, it's at least strange. Before the global power outage, it is believed that energy is everywhere. However, it is not in the cells. There is no energy in the buildings, but the lights are on, the refrigerators are on, etc. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now