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

0 favourites
  • 8 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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.

  • 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.

  • The list object can be used as a box.

    Just add a "List.ItemCount+1&" "&"your text"" when you add to it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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! 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.

  • 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.

  • 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.

  • Oh, super-useful already. I can afford to have comment lines in my scripts now! 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)