diff --git a/.github/workflows/autoPublish.yml b/.github/workflows/autoPublish.yml deleted file mode 100644 index f4ea894..0000000 --- a/.github/workflows/autoPublish.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Auto publish - -on: - push: - paths: - - 'info.json' # Triggers only if the mod info file is updated - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository and submodules - uses: actions/checkout@v3 - with: - submodules: recursive - - name: get mod_version - id: mod_version - uses: notiz-dev/github-action-json-property@release - with: - path: 'info.json' - prop_path: 'version' - - name: get factorio_version - id: factorio_version - uses: notiz-dev/github-action-json-property@release - with: - path: 'info.json' - prop_path: 'factorio_version' - - name: get mod name - id: mod_name - uses: notiz-dev/github-action-json-property@release - with: - path: 'info.json' - prop_path: 'name' - - name: Zip mod - run: bash ./.scripts/zip_mod.sh - - name: Upload the mod on mods.factorio.com - env: - FACTORIO_MOD_API_KEY: ${{ secrets.FACTORIO_MOD_API_KEY }} - run: bash ./.scripts/upload.sh - - uses: marvinpinto/action-automatic-releases@latest - id: aar - with: - automatic_release_tag: "${{steps.mod_version.outputs.prop}}" - title: "For factorio ${{steps.factorio_version.outputs.prop}}" - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - files: | - ./${{steps.mod_name.outputs.prop}}_${{steps.version.outputs.prop}}.zip \ No newline at end of file diff --git a/.scripts/zip_mod.sh b/.scripts/zip_mod.sh new file mode 100644 index 0000000..38ce9f0 --- /dev/null +++ b/.scripts/zip_mod.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +(set -o igncr) 2>/dev/null && set -o igncr; # This comment is required. +### The above line ensures that the script can be run on Cygwin/Linux even with Windows CRNL. +### Run this script after updating the mod to prepare a zip of it. + +main() { +### Check commands +if ! command -v git &> /dev/null; then + echo "Please install/use git https://git-scm.com/downloads" +fi +local has_errors=false +if ! command -v 7z &> /dev/null; then + echo "Please install 7-Zip https://www.7-zip.org/download.html" + local has_errors=true +fi +if [ $has_errors = true ] ; then + exit 1 +fi + + +### mod_folder is a mod directory with info.json +local init_dir=`pwd` + +echo "Target folder: ${init_dir}" + + +### Prepare zip +### https://www.7-zip.org/download.html +local name="sitelen_pona_lua" +if command -v git &> /dev/null; then + git clean -xdf +fi +7z a -xr'!.*' "${init_dir}/${name}.zip" "${init_dir}" +} +main diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d45d285..26595a0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,12 +1,22 @@ { "version": "2.0.0", "tasks": [ + { + "label": "zip mod", + "type": "shell", + "command": "bash", + "args": [".scripts/zip_mod.sh"], + "group": "build", + "presentation": { + "reveal": "silent", + } + }, { "label": "Luacheck", "type": "shell", "command": "luacheck", "args": ["${file}"], "group": "test" - }, + } ] } \ No newline at end of file diff --git a/main.lua b/main.lua index f220af2..72eeb7e 100644 --- a/main.lua +++ b/main.lua @@ -26,7 +26,7 @@ M.ConScriptParts_to_string(parts: ConScriptPart[], new_line_characters="\r\n"): ---@class ConScriptModule : module local M = { - _VERSION = "0.2.0", + _VERSION = "0.2.1", _LICENSE = "MIT", _SOURCE = "https://github.com/ZwerOxotnik/sitelen_pona_lua", _URL = "https://github.com/ZwerOxotnik/sitelen_pona_lua" @@ -361,6 +361,7 @@ function M.ligature(language, font, parts) local ligature_length = 0 local ligature_lexicon = _ligature_lexicon local i = 0 + while true do while true do if i == #parts_copy then return parts_copy, #parts_copy ~= #parts @@ -372,14 +373,14 @@ function M.ligature(language, font, parts) ligature_length = 0 ligature_lexicon = _ligature_lexicon original_text = "" - goto skip + break -- it's continue actually end if part.original == "-" then if ligature_length > 0 then ligature_length = ligature_length + 1 end - goto skip + break -- it's continue actually end ligature_lexicon = ligature_lexicon[part.result_text] or _ligature_lexicon @@ -390,15 +391,15 @@ function M.ligature(language, font, parts) ligature_lexicon = ligature_lexicon[part.result_text] if ligature_lexicon == nil then ligature_lexicon = _ligature_lexicon - goto skip + break -- it's continue actually end end ligature_length = ligature_length + 1 original_text = original_text .. part.original .. " " - if type(ligature_lexicon) ~= "table" then - goto skip + if type(ligature_lexicon) == "table" then + break -- it's continue actually end local prev_i = i - ligature_length + 1 @@ -411,8 +412,7 @@ function M.ligature(language, font, parts) original = original_text, is_add_space = part.is_add_space } - - ::skip:: + end end end @@ -432,24 +432,21 @@ function M.ConScriptParts_to_string(parts, new_line_characters) if part.is_new_line then r_i = r_i + 1 results[r_i] = new_line_characters - goto continue - end - - r_i = r_i + 1 - if part.result_text then - results[r_i] = part.result_text - is_ConScript_part = true else - results[r_i] = part.original - is_ConScript_part = false - end - - if not is_ConScript_part and part.is_add_space then r_i = r_i + 1 - results[r_i] = " " - end + if part.result_text then + results[r_i] = part.result_text + is_ConScript_part = true + else + results[r_i] = part.original + is_ConScript_part = false + end - ::continue:: + if not is_ConScript_part and part.is_add_space then + r_i = r_i + 1 + results[r_i] = " " + end + end end return table.concat(results, "")