Page 1 of 1

drawing and writing

Posted: Wed May 25, 2016 7:23 am
by Plop and run
Is it possible to draw lines and print text on the ground? For example, connect two assemblers with a labeled arrow. I need some visualization for an algorithm I'm currently playing with.

Re: drawing and writing

Posted: Wed May 25, 2016 7:37 am
by DaveMcW
You can create a line or letter entity and give it the appropriate graphic.

Re: drawing and writing

Posted: Wed May 25, 2016 7:58 am
by Plop and run
Well, I cannot make smooth non-original lines that way like in the picture, can I

Re: drawing and writing

Posted: Wed May 25, 2016 8:03 am
by DaveMcW
You would need to make a separate line for every possible way of connecting two points.

Re: drawing and writing

Posted: Wed May 25, 2016 8:18 am
by Plop and run
As you can place assemblers anywhere relative to each other, the possibilities are infinite. There may be workarounds, like with the train network where there are 8 possible directions, but I'd need to spend a good couple of hours to implement that.
Anyway, since there is no easy way and creating a drawing library is a huge derailment, I have to abandon this idea and focus on my main task instead.

Re: drawing and writing

Posted: Wed May 25, 2016 4:48 pm
by DedlySpyder
Plop and run wrote:As you can place assemblers anywhere relative to each other, the possibilities are infinite. There may be workarounds, like with the train network where there are 8 possible directions, but I'd need to spend a good couple of hours to implement that.
Anyway, since there is no easy way and creating a drawing library is a huge derailment, I have to abandon this idea and focus on my main task instead.
Thought: make a small pixel like entity (like 5x5 or so) , make an algorithm to place a line of them between the two assemblers. It might take some work, but I think it could be doable

Re: drawing and writing

Posted: Thu May 26, 2016 10:35 pm
by DedlySpyder
DedlySpyder wrote:
Plop and run wrote:As you can place assemblers anywhere relative to each other, the possibilities are infinite. There may be workarounds, like with the train network where there are 8 possible directions, but I'd need to spend a good couple of hours to implement that.
Anyway, since there is no easy way and creating a drawing library is a huge derailment, I have to abandon this idea and focus on my main task instead.
Thought: make a small pixel like entity (like 5x5 or so) , make an algorithm to place a line of them between the two assemblers. It might take some work, but I think it could be doable
So, this can totally work, here is an example of it in action. The trigger to draw the line in this mod is messed up, but the drawing function itself works fine.

Feel free to use it (credit would be appreciated, but not necessary :D )

Function in case someone can't open the mod:

Code: Select all

function drawLine(positionStart, positionEnd, surface)
	
	--Find the total distance in each X and Y that has to be travelled
	local xDistance = -(positionStart.x - positionEnd.x)
	local yDistance = -(positionStart.y - positionEnd.y)
	
	--Find the total distance of the line
	local distance = math.sqrt((xDistance^2) + (yDistance^2))
	
	--How close is each dot of the line?
	local size = 1/32
	
	--Find the number of steps to draw the line
	local steps = math.ceil(distance/size)
	
	--Find the distance between each step
	local xStepDistance = xDistance/steps
	local yStepDistance = yDistance/steps
	
	--Start position
	local xPlacement = positionStart.x
	local yPlacement = positionStart.y
	
	--For each step, place a dot step distance closer to the end point
	for i=0, steps do
		surface.create_entity{name="draw-line-dot", position={xPlacement+(i*xStepDistance), yPlacement+(i*yStepDistance)}}
	end
end

Re: drawing and writing

Posted: Mon Sep 12, 2016 2:11 pm
by Lilly
The labels should be fairly easy to create using entities. The arrows can be created using beam entities. Though, unfortunately, there seems to be a bug in the rendering of beams.
Screenshot
Screenshot
arrows1.png (380.35 KiB) Viewed 5302 times
The mod I used to create this image:
lines_0.0.1.zip
Arrow mod
(3.52 KiB) Downloaded 157 times
the code

Re: drawing and writing

Posted: Mon Sep 12, 2016 2:53 pm
by aubergine18
This is fantastic! You've just solved a roadblock I was having in one of my mods! Credit will be given!

If you have other gems like this floating around, please share! :D

Re: drawing and writing

Posted: Mon Sep 12, 2016 7:14 pm
by Lilly
aubergine18 wrote:This is fantastic! You've just solved a roadblock I was having in one of my mods! Credit will be given!

If you have other gems like this floating around, please share! :D
What mod are you working on and what problem did you have? Not, per chance, figuring out how to draw the wires/cables for the Ropeway conveyor above the factory...? I'm trying to make a proof of concept mod. Even though I don't care much about the graphics, being able to render the cables is kind of important.

The only other thing I've made so far is a script that, for every item in the game that can be contained in a blueprint, creates a blueprint containing that item (using pcall excessively). My goal was to create a mod that works around the problem that ghost building using shift+click doesn't work well when you have a personal roboport. The robots grab the item out of your hand, such that you can no longer use it to build ghosts. I might pick it up again and make a 'portable blueprint library'-mod out of it.

If you happen to find a fix for the bad rendering of the head and tail, please let me know.

Re: drawing and writing

Posted: Mon Sep 12, 2016 7:25 pm
by Nexela
For labels you can use the flying-text entity set to active=false

label=surface.create_entity{type="flying-text"..........blah blah}
label.active=false

Re: drawing and writing

Posted: Mon Sep 12, 2016 8:44 pm
by aubergine18
The mod where I need to draw lines is a wireless network mod, basically circuit network over various forms of radio (AM, FM, Digital Multicast, Cellular Wifi). I want to be able to show connections between antennas in much same way as logistic network shows links between roboports. The two methods of drawing lines posted earlier in this topic enable me to get lines after the antennas are placed, but not while placing them, but it's still a massive improvement on no lines at all.

Love the look of that Ropeway conveyor BTW. It's a shame we can't add custom wires - for example, if we could add a "metal rope" circuit wire, and special "power poles" to carry it, there's all sorts of stuff that could be done with that. Problem with the game rendered wires though: they are saggy, which wouldn't look good for a ropeway conveyor. An alternate to ropeway conveyor would be a dirigible (airship) which would get loaded like a train, then slowly fly to destination, get unloaded, etc. Benefit is that it wouldn't need tracks, disadvantage is that it's weak if attacked and much slower than train (could even make it get blown off course in high winds lol).