Jump to content
Sign in to follow this  
Nebula

How to determine the presence of electricity in a cell?

Recommended Posts

 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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...