how to disable unplugged icon?

Place to get help with not working mods / modding interface.
User avatar
Savaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Jul 07, 2014 4:27 pm
Contact:

how to disable unplugged icon?

Post by Savaro »

Is there a way to force turn off or hide icon of buiding unplugged?
Image
FishSandwich
Smart Inserter
Smart Inserter
Posts: 1847
Joined: Sun Feb 23, 2014 3:37 pm
Contact:

Re: how to disable unplugged icon?

Post by FishSandwich »

Power the building? Lol.

Apart from a mod I don't think there is a way.

Ed: just noticed this is in modding help, my bad.
Last edited by FishSandwich on Thu Jul 10, 2014 6:39 pm, edited 1 time in total.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: how to disable unplugged icon?

Post by FreeER »

The only way i can think of is to replace the data\core\graphics\electricity-icon-unplugged.png image with a transparent image.
like:
electricity-icon-unplugged.png
electricity-icon-unplugged.png (172 Bytes) Viewed 4895 times
(it's 'technically' shown but since it's transparent there's nothing to actually see).
Of course that will apply across the entire game, so if you just want it fixed for a single thing and to still have it shown for everything else...i don't know
edit: a mod could probably 'connect' it by spawning in an electric pole if it's the steam engine complaining about nothing taking power, if it's a machine being out of power the only thing that could correct it is giving it power (or maybe setting it's active property to false)
User avatar
Savaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Jul 07, 2014 4:27 pm
Contact:

Re: how to disable unplugged icon?

Post by Savaro »

FreeER wrote: so if you just want it fixed for a single thing and to still have it shown for everything else...i don't know.
thats sad (

i need hide icon for 1 building entity from mod thats can be moved.
i tried make a simple powernet with no sprites\collision\ets , but its bugy, cos if building is teleported - power connection calculates wrong\or do not calculates. if they destroyed after teleport - game crashed.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: how to disable unplugged icon?

Post by FreeER »

Hm, since I'm not sure exactly what you're doing (though I have a general idea now) it's hard for me to provide a specific answer :)
It might be 'easy' to give it power every tick using entity.energy = 1000 (or some sufficient number), of course if you don't want to give it power for free you'd need another entity to take power from (using power_collector.energy = power_collector.energy - energy_cost, after making sure that there is sufficient power of course). Which almost brings you back to the same problem, except that the power_collector doesn't need to be teleported (presumably), so that once a connection is set up for it, it should continue working :)
User avatar
Savaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Jul 07, 2014 4:27 pm
Contact:

Re: how to disable unplugged icon?

Post by Savaro »

FreeER wrote:Hm, since I'm not sure exactly what you're doing it's hard for me to provide a specific answer :)
It might be 'easy' to give it power every tick using entity.energy = 1000 (or some sufficient number), of course if you don't want to give it power for free you'd need another entity to take power from (using power_collector.energy = power_collector.energy - energy_cost, after making sure that there is sufficient power of course). Which almost brings you back to the same problem, except that the power_collector doesn't need to be teleported (presumably), so that once a connection is set up for it, it should continue working :)
but connection can be destroyed without loss of status "plugged".
Image
but when i tried do that with code, game crashed.
car creation code
car move code
so i think there may be a property of conncted\or not.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: how to disable unplugged icon?

Post by FreeER »

Savaro wrote: apc["roboport"].energy = apc["roboport"].energy + 20000
There is no check here to see if it's still connected or not, that's why the 'connection' can be destroyed without loss (because it's not actually connected at all, you're giving it free power). To maintain an actual connection you'd need a power_collector/power_transfer to be created as well then you'd reference that power_collector to see if it had power, if it does you'd drain some power by subtracting it from the power_collector's energy property, and give it to the roboport by incrementing it's energy as you're doing now. If it didn't have power then it wouldn't be given to the roboport, and then the status symbol would appear once again (to indicate that it's out of power).

edit: alternatively to that you could create a 'battery' item that could be placed in an inventory of the apc, and only if the battery 'has' energy would you give power to the roboport. Of course there is no way to use Factorio's 'battery' like this...The only way I can think of is to have a ton of battery items with their names indicating their 'energy', so when you give power to the apc you'd remove one of the batteries and insert a new one with a name of one less than the previous. Thus assuming 100 battery items named "battery0"-"battery99" (empty-full), you'd search the apc's inventory (by using apc["chassis"].getinventory(2).getcontents(), probably or maybe a for loop of getitemcount from 99-1, stopping at the first that give a value greater than 0) for a battery that is not battery0, and if you find one (say you find battery99), then you remove it and insert battery98 and then give the roboport energy, if you don't find a battery that isn't battery0 (no stored power) then you don't give the roboport any power. Of course, you'd need a way to reverse that process to 'charge' batteries. Somewhat annoying, but should be just as functional :)
User avatar
Savaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Jul 07, 2014 4:27 pm
Contact:

Re: how to disable unplugged icon?

Post by Savaro »

FreeER wrote:
Savaro wrote: apc["roboport"].energy = apc["roboport"].energy + 20000
There is no check here to see if it's still connected or not, that's why the 'connection' can be destroyed without loss (because it's not actually connected at all, you're giving it free power). To maintain an actual connection you'd need a power_collector/power_transfer to be created as well then you'd reference that power_collector to see if it had power, if it does you'd drain some power by subtracting it from the power_collector's energy property, and give it to the roboport by incrementing it's energy as you're doing now. If it didn't have power then it wouldn't be given to the roboport, and then the status symbol would appear once again (to indicate that it's out of power).

edit: alternatively to that you could create a 'battery' item that could be placed in an inventory of the apc, and only if the battery 'has' energy would you give power to the roboport. Of course there is no way to use Factorio's 'battery' like this...The only way I can think of is to have a ton of battery items with their names indicating their 'energy', so when you give power to the apc you'd remove one of the batteries and insert a new one with a name of one less than the previous. Thus assuming 100 battery items named "battery0"-"battery99" (empty-full), you'd search the apc's inventory (by using apc["chassis"].getinventory(2).getcontents(), probably or maybe a for loop of getitemcount from 99-1, stopping at the first that give a value greater than 0) for a battery that is not battery0, and if you find one (say you find battery99), then you remove it and insert battery98 and then give the roboport energy, if you don't find a battery that isn't battery0 (no stored power) then you don't give the roboport any power. Of course, you'd need a way to reverse that process to 'charge' batteries. Somewhat annoying, but should be just as functional :)
thank you!!!
Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: how to disable unplugged icon?

Post by Rahjital »

Savaro wrote:The only way I can think of is to have a ton of battery items with their names indicating their 'energy', so when you give power to the apc you'd remove one of the batteries and insert a new one with a name of one less than the previous.
Couldn't you simply have one item and use it's stack number to identify charge, so that 500 charge items in inventory would correspond to 500 energy? Seems a bit less clunky than having to create hundreds of items for that purpose.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: how to disable unplugged icon?

Post by FreeER »

Rahjital wrote:Couldn't you simply have one item and use it's stack number to identify charge, so that 500 charge items in inventory would correspond to 500 energy? Seems a bit less clunky than having to create hundreds of items for that purpose.
Sure :) Of course if you don't want the batter to disappear then you need a way to handle the 'last' battery, but that's small issue. Another 'side effect' is charging batteries, say you want to charge a battery, the charger should require a battery item to be placed in it before charging it (at least to replicate the real idea of a battery), however after you've gotten one 'charge' you can now remove that battery and place it in a new charger and get 'infinite' batteries for only the cost of charging since the first charger still has a battery in it, obviously the 'charging' could be a recipe that requires the ingredients to make a new battery but...then it's simply a matter that each 'battery' is made fully charged. Whereas with the multiple item implementation there is no item duplication (to the player's point of view) and it's a more 'accurate' version of real batteries (to get a new battery you must actually make a new battery, and then charge it of course, but you will not be able to 'split' that battery into different machines).

Graphically, a battery with it's charge represented by the item stack is 'visually' the same at all points between empty and full other than the stack count (empty and full could be separate items with different graphics, but everything else will be the same item so has the same image), whereas when each charge is a different item they can all have different graphics (perhaps showing the 'percent' charge or a power bar). So, yes, it can be done that way, it just depends on how you want it to look/work in game; I personally would prefer the more accurate version, even though it requires many items internally :) Of course, if you've an easy way to solve those issues then I'm listening :D

Obviously, if items had metadata of some sort (like minecraft does for instance and how damage works for entities) it could be a single item with the metadata holding the charge value (and perhaps the item itself could specify different graphics for different metadata values, though I'd survive with the same graphic lol)
Post Reply

Return to “Modding help”