Skip to content

Commit

Permalink
Added RandomTextCase
Browse files Browse the repository at this point in the history
  • Loading branch information
Hampo committed Jul 3, 2024
1 parent 91e9b7b commit 8fde803
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Randomiser/Meta.ini
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ ConditionSetting=RandomText
Operator=EqualTo
Value=1

[Setting]
Name=RandomTextCase
Title=Random Case
Type=TickBox
Default=0
Tooltip=Randomises the case of all text in the game.
Page=Chaos Randomisations
Group=Text

; Car pools - I hate this

Expand Down
33 changes: 33 additions & 0 deletions Randomiser/Resources/Modules/Chaos/RandomTextCase.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local math_random = math.random

local RandomTextCase = Module("Random Text Case", "RandomTextCase", 2)

RandomTextCase:AddP3DHandler("art/frontend/scrooby/resource/txtbible/srr2.p3d", function(Path, P3DFile)
local FrontendTextBible = P3DFile:GetChunk(P3D.Identifiers.Frontend_Text_Bible)
if not FrontendTextBible then
return false
end

for FrontendLanguage in FrontendTextBible:GetChunks(P3D.Identifiers.Frontend_Language) do
local Buffer = FrontendLanguage.Buffer
for i=1,#Buffer do
local c = Buffer[i]
if c ~= 0 then
local case = math_random(2)
if case == 1 then
if c >= 65 and c <= 90 then
Buffer[i] = c + 32
end
else
if c >= 97 and c <= 122 then
Buffer[i] = c - 32
end
end
end
end
end

return true
end)

return RandomTextCase

0 comments on commit 8fde803

Please sign in to comment.