drawing and writing

Place to get help with not working mods / modding interface.
Plop and run
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Fri Jan 31, 2014 8:47 pm
Contact:

drawing and writing

Post 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.
Attachments
Untitled.png
Untitled.png (363.55 KiB) Viewed 6024 times
Black blood of the factory
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3717
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: drawing and writing

Post by DaveMcW »

You can create a line or letter entity and give it the appropriate graphic.
Plop and run
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Fri Jan 31, 2014 8:47 pm
Contact:

Re: drawing and writing

Post by Plop and run »

Well, I cannot make smooth non-original lines that way like in the picture, can I
Black blood of the factory
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3717
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: drawing and writing

Post by DaveMcW »

You would need to make a separate line for every possible way of connecting two points.
Plop and run
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Fri Jan 31, 2014 8:47 pm
Contact:

Re: drawing and writing

Post 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.
Black blood of the factory
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: drawing and writing

Post 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
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: drawing and writing

Post 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
Attachments
Draw_Line_0.1.0.zip
(2.04 KiB) Downloaded 131 times
Lilly
Inserter
Inserter
Posts: 49
Joined: Mon Apr 11, 2016 6:42 pm
Contact:

Re: drawing and writing

Post 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 5899 times
The mod I used to create this image:
lines_0.0.1.zip
Arrow mod
(3.52 KiB) Downloaded 171 times
the code
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: drawing and writing

Post 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
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Lilly
Inserter
Inserter
Posts: 49
Joined: Mon Apr 11, 2016 6:42 pm
Contact:

Re: drawing and writing

Post 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.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: drawing and writing

Post 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
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: drawing and writing

Post 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).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding help”