Skip to content

Commit

Permalink
allow printing of square brackets.
Browse files Browse the repository at this point in the history
For [ use [[], you can use ] safely as long as you don't have an open bracket from a command that has not been closed.
  • Loading branch information
sysl-dev committed Aug 31, 2023
1 parent 369499a commit b0eed45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion example/library/slog-text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ function M:send(text, wrap_num, show_all)
local command_word = false -- Special Character is always off at the start of any new string processing
for i = 1, #text do -- For each character in the string, do the following
local character = text:sub(i, i) -- Separate the character -- TODO UTF8Fix, for now use the insert commands [|ò]
local next_character = text:sub(i+1, i+1) -- Separate the character -- TODO UTF8Fix, for now use the insert commands [|ò]
character = convert_special_character(character) -- Convert any special characters
if character == special_character[1] then -- If it's the first special character, confirm that
if character == special_character[1] and next_character ~= special_character[1] then -- If it's the first special character, confirm that
command_word = true -- all should be combined until the second special character
self.table_string[#self.table_string + 1] = "" -- Create the next table entry as an empty string
end
Expand Down Expand Up @@ -1191,6 +1192,7 @@ M.command_table = {
self.cursor.x = self.cursor.x + undefined_image:getWidth()
end
end,

-----------------------------------------------------------------------------
-- Sound Commands
-----------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion example/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ example8box:send("[function=example.bop=true]Did you hear about the [color=#FF00
example9box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.comic_neue_small, character_sound = true, print_speed = 0.04, sound_every = 2, sound_number = 4})
example9box:send("Hello! Welcome to the world of Pocket Creatures![waitforinput][scroll][newline]My name is Professor Tree![newline][waitforinput][scroll][scroll]And you are?", 150, false)
example10box = Text.new("left", { color = {0.9,0.9,0.9,0.95}, shadow_color = {0.5,0.5,1,0.4}, font = Fonts.monogram_extended_custom, character_sound = false, keep_space_on_line_break=true, modify_character_width_table = {["j"] = -1, }})
example10box:send("Special Sheep Polution Test, Bahhh:\n\nij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij\n\na a a a a a a a a a a a a a a a a a a a a a a a a\n\nI've dropped so many letters oh no!\nOjan Pjan Ajan Testj Characterj oj mh wj ikj applej orangej colaj Martijn..", 540, true)
local sp_test_string = "[shake][[]color=red][/shake]"
example10box:send("Special Sheep Polution Test, Bahhh:\n\nij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij ij\n\na a a a a a a a a a a a a a a a a a a a a a a a a\n\nI've dropped so many letters oh no!\nOjan Pjan Ajan Testj Characterj oj mh wj ikj applej orangej colaj Martijn..\n" .. sp_test_string, 540, true)
end

--[[-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------]]--
Expand Down Expand Up @@ -353,6 +354,9 @@ function love.update(dt)
if example.display_mode == 9 then
example9box:update(dt)
end
if example.display_mode == 10 then
example10box:update(dt)
end
end

--[[-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------]]--
Expand Down

0 comments on commit b0eed45

Please sign in to comment.