Page 55 of 83

Re: Simple Questions and Short Answers

Posted: Sat Feb 29, 2020 5:15 pm
by Honktown
Pi-C wrote:
Sat Feb 29, 2020 4:37 pm
I've an entity based on the flamethrower. I want it to be able to use one of two possible fluids (exchanging fluids works once the fluidbox has been emptied). To make things both complicated: the two fluids look differently (so I've recolored the stream graphics for one of them) and do different damage. Is it possible to set different streams in the prototype, so that the one matching fluid A will be used if the turret contains fluid A, and the other one if it contains fluid B?

I guess I could do some trickery in the control stage (replacing entities depending on its contents), but it would be much cheaper if I could do everything with just one prototype.
Going by the wiki the only potential modification is damage:
https://wiki.factorio.com/Types/StreamAttackParameters

An experiment would be if liquids can be used as an ammo category, then the projectile effect would belong to the liquid ammo. The turret would effectively be a gun turret that gets ammo from fluidboxes. Would be simple with "fluid" as items (like flamethrower ammo), but combining ammo and fluidboxes? Unsure.

An easier control effect is possible if a gun-turret can have a fluidbox: if there's fluid the turret can fire, take it out of the fluidbox and insert the fake liquid ammo (if matching fluid or empty.... don't over-fill.... etc)

Re: Simple Questions and Short Answers

Posted: Sat Feb 29, 2020 5:28 pm
by Pi-C
Honktown wrote:
Sat Feb 29, 2020 5:15 pm
An experiment would be if liquids can be used as an ammo category, then the projectile effect would belong to the liquid ammo. The turret would effectively be a gun turret that gets ammo from fluidboxes. Would be simple with "fluid" as items (like flamethrower ammo), but combining ammo and fluidboxes? Unsure.

An easier control effect is possible if a gun-turret can have a fluidbox: if there's fluid the turret can fire, take it out of the fluidbox and insert the fake liquid ammo (if matching fluid or empty.... don't over-fill.... etc)
I think you've got me wrong. I don't want to mix fluid and solid ammo. It's about water turrets that are able to shoot either water or steam (obviously, the fluidbox must have been cleared before one can switch ammo). It would be nice if the steam stream would be automatically picked if the turret contains steam, and the water stream otherwise. But I guess I'll go with replacing entities (perhaps in on_entity_damaged -- could be a bit late because a wrong stream could already have been released when a target is hit, shouldn't be too important, though.

Re: Simple Questions and Short Answers

Posted: Sat Feb 29, 2020 7:46 pm
by Honktown
Pi-C wrote:
Sat Feb 29, 2020 5:28 pm
...
I understood what the goal was, but I didn't think it was doable (besides the control change). In my mind, replacing the entities might take a lot of performance, but I could be wrong. Good luck!

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 10:41 am
by brunzenstein
I cannot find the infinity underground belt or a auto loader to a belt in the /editor - how to?

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 11:12 am
by disentius
They are under the question mark icon.
editor menu.png
editor menu.png (236.49 KiB) Viewed 4153 times

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 11:16 am
by brunzenstein
disentius wrote:
Sun Mar 01, 2020 11:12 am
They are under the question mark icon.

editor menu.png
The loader yes - but the underground belt not - and also the possibility to empty a belt to a "infinity" box without the use of a inserter - is this probably a mod?

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 1:04 pm
by disentius
I am not sure what you mean by "underground belt"...
Loaders/unloaders are on the belt tab, infinity chests and pipes are on the question mark tab. You kan use the infinity chests/pipes for both loading and unloading.

Here is an example setup for use(paste in editor mode). What are you missing?

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 1:05 pm
by brunzenstein
disentius wrote:
Sun Mar 01, 2020 1:04 pm
I am not sure what you mean by "underground belt"...
Loaders/unloaders are on the belt tab, infinity chests and pipes are on the question mark tab. You kan use the infinity chests/pipes for both loading and unloading.

Here is an example setup for use(paste in editor mode). What are you missing?
Yes. Thanks for your kind assistance

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 1:07 pm
by disentius
Beer please :D

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 3:24 pm
by brunzenstein
disentius wrote:
Sun Mar 01, 2020 1:07 pm
Beer please :D
Acutally I saw this loading icon and was looking for it:
Icon.png


you were indeed very helpful as this obvious and simple solution is often not visible - to simple thinking Mac users :-)


So I offer you a free Corona safety net in return for your help _ the tex in German reads:
Stay save against a infection - drink Corona Beer

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 4:00 pm
by Pi-C
Regarding entity health:

We can read the health of an entity, and in on_entity_damaged, we can see the final_damage_amount an entity will take at the end of a tick. However, there seems to be no way to find out the health of that entity before this damage.

The Lua-API description has this to say about the health property:
Health of the entity. Setting health to less than 0 will set health to 0, entities with 0 health can not be attacked. Setting health to higher than max health will set health to max health.
What does that mean? Will it be possible that health has a negative value while on_entity_damaged is still running? I want to know this to implement damage-immunity without additional healing.

Say, a unit that should be immune to my turret's damage has taken damage from it. One way to restore its health is to add final_damage_amount to health. However, this wouldn't work (it would restore more health than damage done) if health_before_damage - final_damage_amount < 0, but health was automatically set to 0.

Another way I could imagine would be to set event.final_damage_amount to 0 -- but will that work, or has the damage already been applied when the event script is called, so that health_in_event = health_before_damage - final_damage_amount?

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 6:10 pm
by brunzenstein
When I try to place the loader (second line - right loader) he offsets a few pixels to the left and cannot connect to the box - pls help

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 6:13 pm
by disentius
Thanks for the beer:)
If you look closely, you will see one end has a belt extension.
Connect that one to the belt and reverse direction of loader with "r"

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 6:20 pm
by brunzenstein
disentius wrote:
Sun Mar 01, 2020 6:13 pm
Thanks for the beer:)
If you look closely, you will see one end has a belt extension.
Connect that one to the belt and reverse direction of loader with "r"
Have one more "Corona" on me :D

Re: Simple Questions and Short Answers

Posted: Sun Mar 01, 2020 10:25 pm
by eradicator
Pi-C wrote:
Sun Mar 01, 2020 4:00 pm
in on_entity_damaged [...] there seems to be no way to find out the health of that entity before this damage.
Correct. What you want is not supported by the engine. There've been several threads about it in the past.

Re: Simple Questions and Short Answers

Posted: Mon Mar 02, 2020 1:54 pm
by Honktown
brunzenstein wrote:
Sun Mar 01, 2020 6:10 pm
When I try to place the loader (second line - right loader) he offsets a few pixels to the left and cannot connect to the box - pls help
The loader is backwards. When loaders are placed, R shifts their in-out direction, but shift-R I think actually flips them around. When you go to place them, R actually flips the entity around, but I think most mods add "snapping" code so that when it gets placed, it figures in/out and picks a direction.

Re: Simple Questions and Short Answers

Posted: Thu Mar 05, 2020 12:50 pm
by Pi-C
I've some trouble with surface.find_entities_filtered. How exactly does it work? I've used it with position, radius, and direction, and I expected this would look for entities in a segment (determined by "direction") of a circle with the given radius around position. However, I run this search on_tick
Just during testing, of course! Will be changed to more sane values later on.
, the area should be quite large (radius = 50), and I see entities in the area. Could it be that the search is performed just along a line (length == radius) in the given direction, not in an area at all?

EDIT: Indeed that was the reason: as soon as I removed "direction", entities were found. The description isn't really clear about direction and position+radius being exclusive:
If no area and no position are given, then the entire surface is searched. If both area and position are specified, returns only entities matching the position. If position and radius are given, returns only entities within that radius of the position.

Re: Simple Questions and Short Answers

Posted: Thu Mar 05, 2020 8:05 pm
by brunzenstein
How do I convert a sandbox save to a normal playable one?
How do I drive a Locomotive when in sandbox?

Re: Simple Questions and Short Answers

Posted: Thu Mar 05, 2020 9:32 pm
by brunzenstein
brunzenstein wrote:
Thu Mar 05, 2020 8:05 pm
How do I convert a sandbox save to a normal playable one?
How do I drive a Locomotive manually when in sandbox?

Re: Simple Questions and Short Answers

Posted: Thu Mar 05, 2020 9:35 pm
by Jap2.0
brunzenstein wrote:
Thu Mar 05, 2020 8:05 pm
How do I drive a Locomotive when in sandbox?
You should be able to hover over it with the mouse and press enter (or whatever you use to get into a locomotive).
Not sure on the second one; the only thing I can think of is manually undoing all of its effects via console, eg. /c game.player.create_character() to spawn a character (wiki).