[REQUEST -Solved] Line Numbers (a-la source-code editor)

Post your work in progress addons and get feedback

Post » Wed Feb 15, 2017 12:03 pm

I find myself writing a lot of projects which use either a home-brew scripting language or some sort of complex grammar. As I build the projects I pass around increasingly large text files to parse, and the error handling gets more and more complicated. Although I can always text out to an editor like Notepad++ to read line numbers, this becomes laborious - particularly with long scripts. More importantly, I would like to enable users of my projects to access these input methods themselves.

My request is for a plugin that will display text with line numbers. Other projects exist (details below) which satisfy this function and many more, such as syntax highlighting etc - although I personally am only really here for the line numbers. If porting an existing system is not an option, perhaps there is some way of 'faking' this in C2 with a custom textbox plugin?

Projects like https://codemirror.net/ or http://codepress.sourceforge.net are far more complex than I strictly need, but if anyone else can see the added value in making a C2 plugin for one of those (or their alternatives) that would suit. Less daunting and just as suited to my purposes (although not as useful to others who might seek a similar plugin) is http://alan.blog-city.com/jquerylinedtextarea.htm , which is a simple text area with lines written using jQuery.
Last edited by mrtumbles on Thu Feb 16, 2017 3:25 pm, edited 1 time in total.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Wed Feb 15, 2017 7:20 pm

I tried using that jquery plugin but it doesn't work with the way C2 positions the textbox.
In the end I did it with two textboxes. CSS was used to hide the scrollbar in the lines box, and javascript was used to sync the scrolling.
https://dl.dropboxusercontent.com/u/542 ... Lines.capx
You can probably style it with more css.

I'd be interested to know more details about your homebrew scripting languages or see a sample script. It sounds pretty cool.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Wed Feb 15, 2017 7:34 pm

The list object can be used as a box.
Just add a "List.ItemCount+1&" "&"your text"" when you add to it.
Image ImageImage
B
169
S
50
G
169
Posts: 8,290
Reputation: 108,224

Post » Wed Feb 15, 2017 9:20 pm

@newt
I think that would get in the way of editing.

@mrtumbles
I managed to get that codemirro library working:
https://dl.dropboxusercontent.com/u/542 ... basic.capx
It has too many features for it to be reasonable to make a plugin for, so instead I just got it to display and resize on top of a textbox, and provide it's javascript object so anything can be done with it. I tried hiding most of it in a group so it doesn't have to be dealt with.

cheers.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Thu Feb 16, 2017 11:55 am

WOW! R0j0hound to the rescue. I'll check those out now.

Yeah I find myself using large text files more and more. It started just for populating arrays and dictionaries using CSV-formatted files. Then I started using a grammar system for use with my procedural generation, and that required some quite complex data structures, so I wrote a sort-of scripting language to fill multiple structures at once.

The project that this will make the most impact on is my take on http://www.puzzlescript.net/. C2 is a beautiful environment, and I've always had a real fondness for middleware in general (Klik&Play4Lyfe). So now I'm making my own! :P It's still early days yet - I've been working on it in-between a related project (a Berlin roguelike) and trying to adult. Your plugin will speed things up dramatically though.

I'm aiming to add some extra functionality to the PS system by adding things like player inventory support, better support for real-time games, maybe an entity-component system to handle variables on objects. The rough idea is to extend Puzzlescript to be able to make something a little closer to an early Zelda game, or similar.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Thu Feb 16, 2017 3:24 pm

Update: the first option really was the best option in most of my current use-cases - but I'm sure myself and others will find a use for CodeMirror in the future. Thanks once again for the heads-up re: javascript execution as well - I had no idea it was that simple! It dropped into the pool without casting a single ripple.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Thu Feb 16, 2017 5:34 pm

That puzzlescript syntax looks interesting. Creating anything that makes things easier to do such as a custom scripting language are always fun. Way better than just using JavaScript, because as you see from my examples it gives access to everything which isn't wanted for scripts the player can add. Plus you can make the error checking much tighter.

Anyways I'm glad my capx' were useful and good luck with your project.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Fri Feb 17, 2017 6:55 pm

Oh, super-useful already. I can afford to have comment lines in my scripts now! :P I'll probably release something around the time of 7DRL, as this could conceivably used to make something Roguelike-ish, although I'm not sure what the completeness will be at that point.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306


Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests