testing character creation

This commit is contained in:
2026-09-22 21:03:45 -06:00
parent 8834269fee
commit e40ffb91da
5 changed files with 41 additions and 43 deletions
+4 -1
View File
@@ -34,4 +34,7 @@ end
table.sort(class_names)
return classes, class_names
return {
classes = classes,
names = class_names,
}
+1 -1
View File
@@ -1,4 +1,4 @@
return {
progress_bar_height = 30,
reading_time_multiplier = 1 / 12,
reading_time_multiplier = 1 / 9,
}
+4 -1
View File
@@ -34,4 +34,7 @@ end
table.sort(race_names)
return races, race_names
return {
races = races,
names = race_names,
}
+31 -39
View File
@@ -1,53 +1,38 @@
local window_width, window_height = love.graphics.getDimensions()
-- local filament = require "lib.filament"
local log = require "lib.log"
local lovebird = require "lib.lovebird"
local progress_bar = require "lib.progress_bar"
local timer = require "lib.timer"
local utility = require "lib.utility"
lovebird.whitelist[#lovebird.whitelist + 1] = "192.168.*.*" -- LAN access
lovebird.whitelist[#lovebird.whitelist + 1] = "192.168.*.*" -- WARNING LAN has full user access through this
log{
debug = true,
error = true,
say = true,
}
local constants = require "data.constants"
local classes, class_names = require "data.classes"
local races, race_names = require "data.races"
local classes = require "data.classes"
local races = require "data.races"
local voices = utility.load_data("macos_say-en.json")
local voice_int = 0
local send_test_message = function()
-- local selected_voice = voices[math.random(1, #voices)]
voice_int = voice_int + 1
if voice_int > #voices then voice_int = 1 end
local selected_voice = voices[voice_int]
local macOS_say = function(line)
local selected_voice = voices[math.random(1, #voices)]
local test_channel = love.thread.getChannel("say")
local line = "Hello, my name is " .. selected_voice .. "."
test_channel:push({
local say_channel = love.thread.getChannel("say")
line = line or "Hello, my name is " .. selected_voice .. "."
say_channel:push({
voice = selected_voice:enquote(),
line = line:enquote(),
})
log("debug", selected_voice, line)
log("say", selected_voice, line)
end
send_test_message()
-- macOS_say()
-- filament.run(function()
-- local line = "Hello, my name is " .. selected_voice .. "."
-- os.execute("say -v " .. selected_voice:enquote() .. " " .. line:enquote())
-- end)
-- local test_thread = love.thread.newThread([[
-- -- local utility = require "lib.utility"
-- -- local voices = utility.load_data("macos_say-en.json")
-- -- local selected_voice = voices[math.random(1, #voices)]
-- local selected_voice = "Bells"
-- local line = "Hello, my name is " .. selected_voice .. "."
-- os.execute("say -v \"" .. selected_voice .. "\" \"" .. line .. "\"")
-- ]])
local test_thread = love.thread.newThread([[
local say_thread = love.thread.newThread([[
local channel = love.thread.getChannel("say")
while true do
local message = channel:demand()
@@ -56,7 +41,7 @@ local test_thread = love.thread.newThread([[
end
end
]])
test_thread:start()
say_thread:start()
local new_character = function(name)
local base_stat_roll = function()
@@ -88,8 +73,8 @@ local new_character = function(name)
local character = {
seed = seed,
name = name,
race = race_names[math.random(1, #race_names)],
class = class_names[math.random(1, #class_names)],
race = races.names[math.random(1, #races.names)],
class = classes.names[math.random(1, #classes.names)],
charisma = base_stat_roll(),
constitution = base_stat_roll(),
dexterity = base_stat_roll(),
@@ -106,17 +91,21 @@ local new_character = function(name)
return character
end
-- for i = 1, 100 do
-- print(new_character())
-- end
-- os.exit(1)
local test_new_character = function()
local character = new_character()
local message = "My name is " .. character.name .. ", and I am a " .. character.class .. " " .. character.race .. "!"
macOS_say(message)
end
test_new_character()
-- test progress_bar
local test_bar = progress_bar(0, window_height - constants.progress_bar_height * 2, window_width, constants.progress_bar_height)
local test_message = "This is a test text string of significant length. It exists to test printing over a progress bar."
test_bar:set_text(test_message)
local test_timer = timer.every(#test_message * constants.reading_time_multiplier, function() log("debug", "The timer completed.") end) -- TODO consider making timer not need a function; cause I don't here!
local test_timer = timer.every(#test_message * constants.reading_time_multiplier, function()
-- macOS_say(test_message)
end)
local task_queue
task_queue = {
@@ -141,9 +130,10 @@ love.update = function(dt)
timer.update(dt)
test_bar:set_progress(test_timer.run_time / test_timer:get_interval())
local thread_error = test_thread:getError()
local thread_error = say_thread:getError()
if thread_error then
log("debug", thread_error)
log("error", thread_error)
end
end
@@ -163,6 +153,8 @@ love.keypressed = function(key)
elseif key == "right" then
update_book_progress(1)
elseif key == "v" then
send_test_message()
macOS_say()
elseif key == "c" then
test_new_character()
end
end