TCF Suggestion Forum code blocks: more languages

Jofairden

Duke Fishron
tModLoader
Hey,

I use code blocks often. What bothers me is that the only supported languages are HTML and PHP for formatting. I'd love to see at the very least C# (C-Sharp) as this is the language used for Terraria (and tModLoader).

Another thing would be to implement line numbers as well, that would be really useful too.
 
This isn't likely to happen anytime soon, if it is even possible. The HTML and PHP options are standard within Xenforo. Looks like XF2 will add Rich (which just looks like you can add other standard bbcodes like COLOR) and JS for Javascript.

If you want to show something that preserves code indentation, your best bet is to write your snippet in Notepad++ or similar, highlight the block you want to copy, and paste in between CODE-/CODE BB tags.

This is just a snipped block from a very old version of the Terraria Chest.cs:
Code:
    public class Chest
    {
        public static int maxItems = 20;
        public Item[] item = new Item[Chest.maxItems];
        public int x;
        public int y;
        public object Clone()
        {
            return base.MemberwiseClone();
        }
        public static void Unlock(int X, int Y)
        {
            Main.PlaySound(22, X * 16, Y * 16, 1);
            for (int i = X; i <= X + 1; i++)
            {
                for (int j = Y; j <= Y + 1; j++)
                {
                    if (Main.tile[i, j] == null)
                    {
                        Main.tile[i, j] = new Tile();
                    }
                    if ((Main.tile[i, j].frameX >= 72 && Main.tile[i, j].frameX <= 106) || (Main.tile[i, j].frameX >= 144 && Main.tile[i, j].frameX <= 178))
                    {
                        Tile tile = Main.tile[i, j];
                        Tile expr_A5 = tile;
                        expr_A5.frameX -= 36;
                        for (int k = 0; k < 4; k++)
                        {
                            Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 11, 0f, 0f, 0, default(Color), 1f);
                        }
                    }
                }
            }
        }

But if your idea is to have auto-indentation/syntax highlighting/etc. as you type it in - This isn't a syntax editor; it's far less complex than something like Notepad++.
 
But if your idea is to have auto-indentation/syntax highlighting/etc. as you type it in - This isn't a syntax editor; it's far less complex than something like Notepad++.
I know. It's just that the code blocks here are incredibly dull, there's no syntax highlighting or line numbers, it feels more like a comment block or something. Just wanted to put this out there so there's at least one person showing interest in improvements :happy: I personally don't have a lot of experience with XenForo, but what if.. say.. I had made an addon myself that could syntax highlight more language, and add line numbers. Could that be added? (What I'm suggesting here is me making a plugin that will do that)

edit: For clarification, I can easily make line numbers with some javascript and css, the syntax highlighting is a different story.
 
That's because it IS a comment block. This is a discussion forum, not a software development tool.

Under no circumstances will we entertain putting member-generated code on our forum server. That's a security nightmare waiting to happen.

You can also post a screencap of the code from a more pleasant-looking application, you can also post the snippets on a github and link them. That's about the best that can be offered.
 
AFAIK the current 'supported' languages don't have any highlighting either, it just gives it a label.
 
That's because it IS a comment block. This is a discussion forum, not a software development tool.

Under no circumstances will we entertain putting member-generated code on our forum server. That's a security nightmare waiting to happen.

You can also post a screencap of the code from a more pleasant-looking application, you can also post the snippets on a github and link them. That's about the best that can be offered.
I'm sorry for throwing you off the charts so much, I guess? I was offering to improve it... but whatever
 
I am going to make an honest effort to implement this in ATCF 2. Not sure how I'll manage to detect language, but I'll work some magic.

Believe me, I've already thought "it'd be best if there was just an add-on the server; hell, I'd make one" so many times in the past, and I think the fact that ATCF exists shows how that works out. It's not great. It just suffices.

I'm not quite a fan of the "this is a discussion forum, not a software development tool" comment. I get where it comes from, and I'm not challenging the decision (he's not wrong), but the modding community is part of the Terraria Community; neglecting them is just likely to push them to making their own forum (which, honestly, I'm rooting for atm).
 
Last edited:
Re-Logic uses this forum for promoting Terraria and its other ventures. Thus, the integrity and reliability of the service is of paramount importance. We just can't provide the server for random people to 'mod' for their own purposes, even if the intended outcome is to improve this community's experience (or a small portion thereof).

Just because someone asks for something and gets told 'No' doesn't mean anyone is being neglected. The modding community has gotten wide latitude to do their thing, and in return we've seen a fair amount of resentment directed at the forum staff and even Re-Logic. If this site no longer serves the desires and purposes of "the modding community", then maybe it IS best for them to move elsewhere. Many of that part of the community have had no problem using Discord or other chat outlets for their activities.

Anyone can purchase a Xenforo license, rent a server to run it on, and mod it to their hearts content. If someone wants to do so, and demonstrate to us that they've created something useful, we'd be happy to take a look. I have looked around for an existing plug-in to provide this sort of formatting/bbcode, but I haven't found it, nor have I found anything nearly as complex as this seems to be.

*I* don't even have access to the server itself; only Skiphs does, for maintenance purposes. The forum is largely off-the-shelf software with some purchased plug-ins; the visual stuff you see (the customized themes) are constructed through the Admin control panel (ACP). Since Skiphs' time is mostly taken up on the development side (of Re-Logic, not the forum), there's really not a lot of opportunity to experiment with new things. As it is, some of the plug-in features we already have are hampering our ability to keep up with mainstream Xenforo updates, which concerns me greatly from the standpoint of stability and security.

I'll offer this: there is a facility in the ACP to define custom BB codes. A PHP callback can be used to format the text contained in the tags. If someone can create this functionality through that interface, I'll do what I can to help (and by that I mean: I'll tell you what information is needed, and I'll copy/paste it into the ACP form). I'm told that I can't really do anything harmful or irreversible through that interface.
 
Now that I'm less jetlagged after a night of sleep, I think it's fair to clear some stuff up:
But if your idea is to have auto-indentation/syntax highlighting/etc. as you type it in - This isn't a syntax editor; it's far less complex than something like Notepad++.

As far as I can tell, he is definitely not suggesting this; nobody with any sense would use a forum to actually write their code :p He simply wants the code in an actual post to be a little more pleasing to look at, which means syntax highlighting.

The line numbers comment comes from the fact that a lot of beginning modders have errors with code and stack traces usually give line numbers. Having those line numbers next to the code they post could (some might snip only what's relevant) be helpful to those trying to help. I'm actually pretty against having line numbers on the forum because of how niche they are.

In fact, the suggestion overall is pretty niche. I honestly feel like trying to implement either of these on the forum itself should be done either because the staff feels generous towards the modding community (of which, something tells me "generous" isn't the word they'd want to use) or because the staff thinks that the feature would prove to improve the quality of the forum... but it wouldn't really.

Looking at message post counts per forum (excluding news and social groups), the modding section only takes up about 21% of the forum and is actually second in size to Forum Games. Player Suggestions and the cumulative Social forums (PC social, Mobile social, Console social, and Crossroads) are also pretty close behind.

Out of that 21% that the modding forum takes up, even a smaller amount are actual developers who care about stuff like syntax highlighting. My honest guess (and I'm likely being very generous) would be that 5% of the 21% (therefore ~1% of the forum's users) are people who are developers... but not necessarily those who care about having syntax highlighting on the forum; that likely narrows it down even further below an already generously high 1%.

As you can tell, this feature suggestion really isn't quite worth it: the modding community on the forum might be sizable, but the developer community isn't. I'm more than happy to implement it for ATCF because I'm one of the people who would enjoy it (in the rare case where I actually visit the modding forum) and I can understand why it's useful. But I've also decided to default it to off because, while it does theoretically improve the forum, it's for such a narrow audience that having it on wastes resources for something that a user likely won't ever even find out about.

Honestly, I believe what TK said before is, honestly, a pathway to the true solution in my eyes, and I'm unhappy it was just glanced over:
You can also post a screencap of the code from a more pleasant-looking application, you can also post the snippets on a github [< changed by everest] and link them. That's about the best that can be offered.

The only concern I have about a screencap is it makes it hard to debug someone else's code because you can't copy it and try it yourself. Conversely, people who don't post screencaps probably don't care about having syntax highlighting (hell, I bet a number of them write in regular notepad in the first place) and if you want someone else's code to look nice then just copy it into your code editor of choice (except for visual studio; opening VS just to paste some code sounds like a lot of work :p)

The talk about github, though, is a step in the right direction. I wouldn't recommend making a repository just to share one file as that's too cumbersome; gist (github's mini code file sharing thingy) is more likely what TK meant, but I'd even go further and advocate for the use of hastebin or pastebin (my preference would be hastebin) because they basically solve all the issues seen in this post:
  • Syntax highlighting (hastebin lets you decide it when you view, pastebin lets the uploader decide)
  • Line numbers
  • Copy-able code
  • Not needing to host & execute member-written code
So that's where I stand: the solution is to use hastebin. or pastebin.

I also think "neglect" wasn't quite the word I was looking for earlier; I was more-so thinking about the sound of aggression that TK had in my head as I was reading his posts that made me unhappy. I'm not quite used to seeing staff approach a non-serious issue without some kind of lightheartedness.

divider.png

Anyone can purchase a Xenforo license, rent a server to run it on, and mod it to their hearts content. If someone wants to do so, and demonstrate to us that they've created something useful, we'd be happy to take a look.

I'm not quite going to agree with the "anyone can just purchase XenForo" part, but I do wish for clarification as to whether this is an invite for someone competent to actually make a quality add-on for the forum or not.
I'll offer this: there is a facility in the ACP to define custom BB codes. A PHP callback can be used to format the text contained in the tags. If someone can create this functionality through that interface, I'll do what I can to help (and by that I mean: I'll tell you what information is needed, and I'll copy/paste it into the ACP form). I'm told that I can't really do anything harmful or irreversible through that interface.

The issue with this is that the PHP callback is useless in this case: the PHP callback literally just takes the path to a PHP function to call to handle the BB code formatting. Unless a function exists that already does the functionality you want, you have to define it yourself, which brings us back to the "hosting member-written code" issue.
 
Last edited by a moderator:
I spent a good chunk of my professional life writing code; I can greatly appreciate the value and convenience of visually appealing code. If there were an easy/simple way to incorporate this suggestion, I'd be all for it.

The hastebin/pastebin solution seems to be the best compromise available at the moment. It doesn't integrate the snippets into posts or discussions, but it's something. That's where I was going with the 'post screenies of code' - both the code AND the discussion are together. But as I also tried to point out (perhaps a little too bluntly) - Xenforo isn't really designed to do things like collaborative development work, whereas other platforms (like Slack) might be a more natural and readily available choice for that function. Even the free Slack option allows for full syntax highlighting/line numbering/indentation of snippets right in the discussion chains.

IMHO, a more ideal situation for everyone would be that TCF would be the place to come find mods, and <somewhere else> would be the place to develop/learn to develop mods. I just don't think TCF/Xenforo lend themselves well to the latter. But I digress.

I'm not quite going to agree with the "anyone can just purchase XenForo" part, but I do wish for clarification as to whether this is an invite for someone competent to actually make a quality add-on for the forum or not.
Sure you can, right here: https://xenforo.com/purchase/ (My intended point is that it's available, not that everyone has the means or desire to buy it.)
Absolutely, knock yourself out. People do make money developing and selling plug-ins and services for Xenforo. If you come up with something useful, we'd be happy to take a look at it.
We just can't let people use our production server to develop/test such things out for themselves.

The issue with this is that the PHP callback is useless in this case: the PHP callback literally just takes the path to a PHP function to call to handle the BB code formatting. Unless a function exists that already does the functionality you want, you have to define it yourself, which brings us back to the "hosting member-written code" issue.
Fair point, I had glanced at the ACP page and thought there was a block where code could be pasted into, turns out it was something else. It does give a signature for the callback method, though. It's basically the hook for plug-ins to use to create more bbcodes.
 
It is probably worth mentioning the fact that there is an extremely active tModloader discord which is where most people seem to get support for developing mods.
Pretty much all experienced tModloader users are on there (including Yoraiz0r).
 
Many of that part of the community have had no problem using Discord or other chat outlets for their activities.
Heh, let me just point out that code blocks on Discord aren't a lot better than the one's here. They're practically the same with the only difference that they have a lot of languages available for syntax highlighting. I've been using Discord for a long time now, but it sure as hell is still lacking a lot of stuff (stuff that Slack has... beat that Discord...) I still stopped using Slack (even for development) because I feel like Discord is already so much better on many fronts (but even then, Slack wins on a lot of parts as well)

IMHO, a more ideal situation for everyone would be that TCF would be the place to come find mods, and <somewhere else> would be the place to develop/learn to develop mods. I just don't think TCF/Xenforo lend themselves well to the latter. But I digress.
'We', have considered making our own 'forum' of sorts for this (modding in general). A forum that is dedicated to the purpose of modding and using the api isn't a bad idea, now that the community for it has grown so big (before a member prune our server had almost 7000 members) I tried Reddit before (/r/tmodloader), the problem is that Reddit isn't really the right platform either and nobody really found the subreddit either. Right now, a lot of useful information can be found on our wiki and the source documentation. The problem mostly is that people aren't directed to these places often enough, so a lot of issues stay on this forum while the info for them is right there. Mostly the problem right now is money. We recently setup a Patreon that should help, because we obviously are going to need money to sustain such a platform. (Not to mention the Mod Browser, we're going to use the initial money for that)

It is probably worth mentioning the fact that there is an extremely active tModloader discord which is where most people seem to get support for developing mods.
Pretty much all experienced tModloader users are on there (including Yoraiz0r).
This is true. I made the Discord server a little over 2 years ago, exactly because of knowing it'd be better/easier than trying to do everything on this good ol' forum. Took it easy, little did I know the server would grow out so big. We've got Skiphs and Yoraiz0r on board, both developers for Terraria.. which is aawwessoomeee~~
Fortunately, people are often directed to our sever, which is nice. It's a lot easier to help people with live ongoing chat. Nevertheless, we still get a good chunk of messages on TCF which mostly lead to nothingness, sadly. I'm already happy finding out my help thread got pinned in multiple sections, I'm going to work on it again soon..

In fact, the suggestion overall is pretty niche. I honestly feel like trying to implement either of these on the forum itself should be done either because the staff feels generous towards the modding community (of which, something tells me "generous" isn't the word they'd want to use) or because the staff thinks that the feature would prove to improve the quality of the forum... but it wouldn't really.
Indeed, it is pretty niche. Too niche, probably. But I still wanted to make this point, showing that at least some audience cares.
 
The problem mostly is that people aren't directed to these places often enough, so a lot of issues stay on this forum while the info for them is right there.

I feel like the only solution to that is to ask a mod to lock the thread; that means that the people who don't read the post and just assume that the thread is the help center will be forced to read the thread (help 'em out and make it obvious where to get help) and, therefore, will be directed to the right area to get help.

That has its own problems though, i.e. the post always looks like its dead and nobody really knows when it updates unless the title changes and they remember the last version number.This might even make the situation worse if people just start making threads in Modding Discussion instead of finding the help area. Or maybe there's people who refuse to use services like discord (there's bound to be at least, like, 2 people in the world) and this basically excludes them.

¯\_(ツ)_/¯
 
I feel like the only solution to that is to ask a mod to lock the thread; that means that the people who don't read the post and just assume that the thread is the help center will be forced to read the thread (help 'em out and make it obvious where to get help) and, therefore, will be directed to the right area to get help.

That has its own problems though, i.e. the post always looks like its dead and nobody really knows when it updates unless the title changes and they remember the last version number.This might even make the situation worse if people just start making threads in Modding Discussion instead of finding the help area. Or maybe there's people who refuse to use services like discord (there's bound to be at least, like, 2 people in the world) and this basically excludes them.

¯\_(ツ)_/¯
I don't think locking the thread is a solution, and in regards to that we don't really need a 'solution'. 'We' (the tml developers) already kind of stopped answering most questions (but still occasionally), but still a lot of other fellow modders do, so in the end there isn't much of an issue. :)
 
Back
Top Bottom