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
+1 -1
View File
@@ -53,7 +53,7 @@
[12, "Recharging"] [12, "Recharging"]
] ]
}, },
"Runeloremaster":{ "Rune-Lore Master":{
"stats":["wisdom"], "stats":["wisdom"],
"tasks":[ "tasks":[
"Enthusiastically explaining the applications of runes on trains" "Enthusiastically explaining the applications of runes on trains"
+4 -1
View File
@@ -34,4 +34,7 @@ end
table.sort(class_names) table.sort(class_names)
return classes, class_names return {
classes = classes,
names = class_names,
}
+1 -1
View File
@@ -1,4 +1,4 @@
return { return {
progress_bar_height = 30, 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) 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 window_width, window_height = love.graphics.getDimensions()
-- local filament = require "lib.filament"
local log = require "lib.log" local log = require "lib.log"
local lovebird = require "lib.lovebird" local lovebird = require "lib.lovebird"
local progress_bar = require "lib.progress_bar" local progress_bar = require "lib.progress_bar"
local timer = require "lib.timer" local timer = require "lib.timer"
local utility = require "lib.utility" 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{ log{
debug = true, debug = true,
error = true,
say = true,
} }
local constants = require "data.constants" local constants = require "data.constants"
local classes, class_names = require "data.classes" local classes = require "data.classes"
local races, race_names = require "data.races" local races = require "data.races"
local voices = utility.load_data("macos_say-en.json") local voices = utility.load_data("macos_say-en.json")
local voice_int = 0 local macOS_say = function(line)
local send_test_message = function() local selected_voice = voices[math.random(1, #voices)]
-- 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 test_channel = love.thread.getChannel("say") local say_channel = love.thread.getChannel("say")
local line = "Hello, my name is " .. selected_voice .. "." line = line or "Hello, my name is " .. selected_voice .. "."
test_channel:push({ say_channel:push({
voice = selected_voice:enquote(), voice = selected_voice:enquote(),
line = line:enquote(), line = line:enquote(),
}) })
log("debug", selected_voice, line) log("say", selected_voice, line)
end end
send_test_message() -- macOS_say()
-- filament.run(function() local say_thread = love.thread.newThread([[
-- 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 channel = love.thread.getChannel("say") local channel = love.thread.getChannel("say")
while true do while true do
local message = channel:demand() local message = channel:demand()
@@ -56,7 +41,7 @@ local test_thread = love.thread.newThread([[
end end
end end
]]) ]])
test_thread:start() say_thread:start()
local new_character = function(name) local new_character = function(name)
local base_stat_roll = function() local base_stat_roll = function()
@@ -88,8 +73,8 @@ local new_character = function(name)
local character = { local character = {
seed = seed, seed = seed,
name = name, name = name,
race = race_names[math.random(1, #race_names)], race = races.names[math.random(1, #races.names)],
class = class_names[math.random(1, #class_names)], class = classes.names[math.random(1, #classes.names)],
charisma = base_stat_roll(), charisma = base_stat_roll(),
constitution = base_stat_roll(), constitution = base_stat_roll(),
dexterity = base_stat_roll(), dexterity = base_stat_roll(),
@@ -106,17 +91,21 @@ local new_character = function(name)
return character return character
end end
-- for i = 1, 100 do local test_new_character = function()
-- print(new_character()) local character = new_character()
-- end local message = "My name is " .. character.name .. ", and I am a " .. character.class .. " " .. character.race .. "!"
-- os.exit(1) macOS_say(message)
end
test_new_character()
-- test progress_bar -- test progress_bar
local test_bar = progress_bar(0, window_height - constants.progress_bar_height * 2, window_width, constants.progress_bar_height) 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." 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) 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 local task_queue
task_queue = { task_queue = {
@@ -141,9 +130,10 @@ love.update = function(dt)
timer.update(dt) timer.update(dt)
test_bar:set_progress(test_timer.run_time / test_timer:get_interval()) 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 if thread_error then
log("debug", thread_error) log("error", thread_error)
end end
end end
@@ -163,6 +153,8 @@ love.keypressed = function(key)
elseif key == "right" then elseif key == "right" then
update_book_progress(1) update_book_progress(1)
elseif key == "v" then elseif key == "v" then
send_test_message() macOS_say()
elseif key == "c" then
test_new_character()
end end
end end