Page 1 of 1

Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 1:06 am
by robertpaulson
Hi, I want to create a radar that works without power grid, however when I place it with 0kw consumption setting the game crashes. I tried making it "solar" with 1w consumption but that didnt work- didn't crash the game tho. Is there a way to modify the energy source to allow it to function without power? I need it to scan only nearby sectors and only for a short duration (implementing charting will be more problematic)

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 9:36 am
by Adil
Probably no. The game have things like this hardcoded to the very depth of it.

This might have been uncalled for, but the following statement
robertpaulson wrote:(implementing charting will be more problematic)
caught my thought and I've spent fifteen minutes to prove the opposite:
code

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 5:52 pm
by impetus maximus
Creative mode mod has entities (including radar) that run without power, with power flashing icon still present.

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 6:14 pm
by robertpaulson
Adil wrote:Probably no. The game have things like this hardcoded to the very depth of it.

This might have been uncalled for, but the following statement
robertpaulson wrote:(implementing charting will be more problematic)
caught my thought and I've spent fifteen minutes to prove the opposite:
code
Well then, maybe I don't belong here or I'm really slow because it took me more than 15 to understand the code lol.... Much thanks for the work! btw, the variable e is never used, why is it there? to verify the r.next is there to simulate the radar scanning sector by sector? that's elegant!
impetus maximus wrote:Creative mode mod has entities (including radar) that run without power, with power flashing icon still present.
those can be removed with render_no_power_icon =false, but if its there the entity doesn't work on 0 power and the work is done by scripts (like the one provided by Adil, above)

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 6:32 pm
by impetus maximus
ok, i'm not a coder/modder. just trying to help.

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 7:34 pm
by robertpaulson
impetus maximus wrote:ok, i'm not a coder/modder. just trying to help.
no worries, I will probably take a look at the mod you mentioned. Thank you for info, and sorry if I came on rude, wasn't my intention. cheers.

Re: Creating new entity that has 0kw consumption

Posted: Mon Aug 21, 2017 8:55 pm
by impetus maximus
not at all. cheers :)

Re: Creating new entity that has 0kw consumption

Posted: Tue Aug 22, 2017 7:34 am
by Adil
robertpaulson wrote:Much thanks for the work! btw, the variable e is never used, why is it there? to verify the r.next is there to simulate the radar scanning sector by sector? that's elegant!
You are welcome. Unused e is a typo, I've intended to read position, force and surface from it, not from r:

Code: Select all

                local e=r.entity
                local p,s,f=e.position,e.surface,e.force
Sorry, about that.

Yes. r.next_x and r.next_y are there to keep track of the next chunk to scan.

Also, I'm lagging behind somewhat. We didn't have the `render_no_power_icon ` field back then. With that, who knows, maybe adding a buffer to the entity's power source (like roboport has) and using scripts to refill it, will suffice.
something like this