From 044fb30b1b7ab26bf9e9ea97c9152ed4d68e08f0 Mon Sep 17 00:00:00 2001 From: Lonami Date: Thu, 31 Dec 2020 22:30:35 +0100 Subject: [PATCH] Support inline comments (#4196) * Support inline comments Closes https://github.com/Anuken/Mindustry-Suggestions/issues/1698. * Apply suggestions from code review Co-authored-by: Patrick 'Quezler' Mounier * Stick with Mindustry formatting style Co-authored-by: Patrick 'Quezler' Mounier --- core/src/mindustry/logic/LAssembler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/logic/LAssembler.java b/core/src/mindustry/logic/LAssembler.java index fe1c7e1267..8282e66ca6 100644 --- a/core/src/mindustry/logic/LAssembler.java +++ b/core/src/mindustry/logic/LAssembler.java @@ -62,7 +62,9 @@ public class LAssembler{ int index = 0; for(String line : lines){ //comments - if(line.startsWith("#") || line.isEmpty()) continue; + int commentIdx = line.indexOf('#'); + if(commentIdx != -1) line = line.substring(0, commentIdx).trim(); + if(line.isEmpty()) continue; //remove trailing semicolons in case someone adds them in for no reason if(line.endsWith(";")) line = line.substring(0, line.length() - 1);