Good vs. Evil

  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
6 someone who made a thing that throws liquid over you.
He also made a thing that shines a laser in your eye and an alarm that goes off whenever someone subscribes to him
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
6 so..the good news is that reading the source code for lua-term is actually very easy thus copying that wasn't hard.
However, this did make me feel a bit bad as I feared it would end up as a straight copy.
Luckily, bash is so nice that going above 16 colors I need a different order of characters to compose them.
In order to explain what I mean an example is probably the best. In order to create black text I write
Code:
\e[30m{Your text here}
Here the number 30 is telling the terminal that I want black text.
However, if I want to access more than 16 colors the pattern suddenly becomes
Code:
\e[38;5;ColorNumberm
//so..something like
\e[38;5;30m
And, no that will not make black text. It will actually make some greenish/blueish text. If I want black text with this pattern I should replace the 30 with either a 0a 16 or a 232. Note that going higher than 232 will make gray to white text.

So... I think I'm going to structure my color api a bit different. Mainly by being able to use numbers, compose colors and using their raw numbers as well as making names for the most used ones.
Basically allowing me to write
Code:
local colorFun = colors:make():foreground(colors.RED):background(colors:BLACK):attr(colors.BOLD,true):comp()
print(colorFun("some Text")) --will print bolded red text on a black background.

If I do it right it should result in better code overall and may even make it easier for me to work with the background color in combination with transparency.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
7 so...decided to make it work a bit difrent.
Its now
Code:
local textColor = Colors:new("some text"):setColor(1):setBackground(2):setAttr(1,true):write()
It also contains a split function which has as input 2 functions. One decides when and how to split, the other can set the appropriate colors up for each piece.

I also learned that in order to turn off bold, I use the same character that turns off dim, instead of the character that turns off bold. Don't ask me why, apparently there are more terminals with that problems. Additionally, I learned that my terminal is one of the few that support blink.

Oh, those magic numbers will of course go away. I'll make them accessible using
Code:
Colors.COLORS.RED
Colors.ATTRIBUTES.BOLD
or something
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
6 I'm bad at being lazy... I ended up starting a project for school that I have time for, and made significant progress. So, today didn't go according to plan.
 

GamerwithnoGame

Over-Achiever
Jan 29, 2015
2,808
1,507
224
7. Well, there are worse things ;)

I finally made the natura pylons to go with my elven gateway core. That was quite some task...! Thankfully I was able to afk while standing on a Rosa Arcana and surrounded by crystals that give a slow trickle of XP to get the mana.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
6 and... apparently true color is a thing in a good amount of terminals......

I guess its time to figure out how that works....
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
6 if you don't know what true color is, it just means you can set the red,green and blue channel separately up to a max of 255.
This results in 16777216 (256*256*256) different colors you can use.

The old setup could only show 256 colors in total.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
6 so... I fixed the split function and made it work with true color. Its now trivial to do stuff like
upload_2018-4-23_21-15-13.png
Now, time for the rest of the code to make use of it....
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
4 Yeah. I've been developing a simplified population simulator, with plants, prey, and predators. I've got most of the action functions implemented, just need to implement plant growth and the selection of an action for each animal. And statistics gathering. I should probably actually record the population, given the goal is to show population change over time...