This is just a cool test


#1


Trying out my code in Lua that will auto format some cool text to make it different colors and stuff

If you have Codea, I can give you the code and tell you how to use it


Hopscotch project JSON reader
#2

Cool!

first reply


#3


Now it should have a transparent background


#4

Hello @Valgo!:grinning: This is really cool!:grinning: I actually have Codea so if I could actually code this it would be awesome.:slight_smile:


#5

Wait it should work now


#6

You can have the code if you want. I'll also tell you how to use it

Tutorial for anyone who has Codea:

Link to Codea code: http://pastebin.com/Bmu6nGfV

Basically to format the text, you need to use hashtags. So #red would make the text Red.
To change the color of the text, put one of these in front of the text:
#red
#orange
#yellow
#green
#blue
#purple
#black
To change the size, use these:
#extra_large
#large
#medium
#small
#extra_small
To make a new line, use
#newl
Once you get the text, put it in the renderText() part of the code (it's at the top)
Then, paste the image copied to the clipboard into the notes app, save it, and upload it!

@PrincessBunny1


#7

lol cool


#8

Cool!

I recently(ish) learned text-colour-changing in HTML. Excited, I rushed to the forum. Didn't work :frowning:


#9

I know .-. I tried it last night, but it didn't work, so I made this


#10

Cool!

(I wish we could customise colour...)


#11

I know. I went on the discourse test forums where you can try it, and it didn't work there. I guess it's just not a feature of discourse yet


#12
We should make a #BringHTMLColours thing lol

Hopscotch project JSON reader
#13

This is awesome! I think only certain HTML tags are allowed on the forum otherwise people might take advantage of things and mess up the site... (even if it's just the colour scheme)


Ask questions to the Hopscotch Team!
#14

Good point. JavaScript is definitely powerful enough to do that.


#15

And really lovely of you to share the code! Do you think you could quickly go through how it works? :blush: Somehow seeing this makes me feel less lonely on Codea, guess it doesn't have a community for sharing like Hopscotch does. :grin: (Well I suppose it has its forum but it's not the same as a public community for sharing) I am still new to it :blush:


#16

So I have a class that takes in the text and does everything it needs to do to it. First, I have what I call The Parser. It is a function that will read through the text, and if it sees any specific hashtags (the ones above), it will do certain things to the text after it. I keep track of the text in a table. If you accidentally typo a tag, it won't do anything. Then, the class will take that Data table and render it into an image. It will pay attention to text size, text color, and any line breaks you put in. That's basically how that works! (I know, I need to add in more comments into my code :sweat_smile:)

Edit: I can explain it in simpler terms if necessary, or I can explain some terms XD


Electronics Talk!
#17

Thank you that's awesome :blush:

I can see that, in the parse() func, it checks for the # character and spaces, and it looks like it is collecting all the characters in between the # and " " in the token string, and then eventually whatever is in token goes into self.tokens.

And for any other words, it puts the characters in t instead, and it looks like those end up in the self.data table. At the moment I am not quite sure how the render() func works, and how the Tokens table and Data table are used yet, but I'll keep looking. If I've gotten anything confused so far, please feel free to point it out too :slight_smile:

(Hehe, don't worry :) Me, I used to go overboard with comments and comment every line when I was first learning text-based coding. But turns out you can convey the information in other ways https://blog.codinghorror.com/coding-without-comments/ like in variable names and function names for example.

Naming is a whole other thing :joy: I can go pretty overboard with that too, with doing long descriptive names, but then I realised I couldn't even read my own code from a glance when I did that :laughing: At the moment I find shortened forms of words easier to look at. Still learning :slight_smile:)

So lovely of you to help everyone by the way! :blush::blush::blush:


#18

Actually, the self.tokens table basically has all of the words that the parser will recognize as something important in it. It has all of the colors in it, and all of the sizes. And new line, too. The self.tokens table never changes.


#19

i do lease tell me please


#20

What do you need?