diff --git a/README.md b/README.md index c1e2bc1..1a29aca 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ | Settings stage | Data stage | Control stage | | -------------- | ---------- | ------------- | -| [ZKSettings](/experimental/ZKSettings.lua) - libary with new features for settings | [sound auto-handling](https://github.com/ZwerOxotnik/Mod-generator) + [PUAN api](/data-api/puan_api.lua) | ["zk-lib" - remote interface of libs](/zk-lib/control.lua) +| [ZKSettings](/experimental/ZKSettings.lua) - libary with new features for settings | [sound auto-handling](https://github.com/ZwerOxotnik/Mod-generator) + [PUAN2 api](/data-api/puan2_api.lua) | ["zk-lib" - remote interface of libs](/zk-lib/control.lua) | ["Static libs"](#static-libs) | ["Static libs"](#static-libs) | ["Static libs"](#static-libs) | | [lazyAPI](/experimental/lazyAPI.lua) | [lazyAPI](/experimental/lazyAPI.lua) - Are you lazy to change/add/remove/check some prototypes in the data stage? Use this library then. | [Event listener][event-listener] (not important, currently) | | | [simpleTiers](/experimental/simpleTiers.lua) | | diff --git a/changelog.txt b/changelog.txt index ac1154f..87ef049 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ --------------------------------------------------------------------------------------------------- +Version: 0.13.10 +Date: 28. 07. 2023 + Scripting: + - Added puan2_api to fix sound issues + - Updated ZwerOxotnik's static libs +--------------------------------------------------------------------------------------------------- Version: 0.13.9 Date: 19. 07. 2023 Scripting: diff --git a/data-api/puan2_api.lua b/data-api/puan2_api.lua new file mode 100644 index 0000000..0f754ea --- /dev/null +++ b/data-api/puan2_api.lua @@ -0,0 +1,76 @@ +--[[ +Copyright (C) 2018-2020, 2022-2023 ZwerOxotnik +Licensed under the EUPL, Version 1.2 only (the "LICENCE"); +Source: github.com/ZwerOxotnik/zk-lib +]]-- + +---- Generates sounds etc for programmable speakers +---- Use https://github.com/ZwerOxotnik/Mod-generator + + +local puan2_api = {} + + + +---@param sound table +---@param path string +puan2_api.check_and_get_sound = function(sound, path) + local new_sound = {} + + new_sound.aggregation = sound.aggregation + new_sound.audible_distance_modifier = sound.audible_distance_modifier + if sound.variations then + new_sound.variations = sound.variations + else + new_sound.filename = sound.filename or (path .. sound.name .. ".ogg") + new_sound.volume = sound.volume + new_sound.preload = sound.preload + end + + return new_sound +end + + +---@param sound table +---@param path string +puan2_api.add_sound = function(sound, path) + local new_sound = puan2_api.check_and_get_sound(sound, path) + new_sound.type = "sound" + new_sound.name = sound.name + new_sound.category = "gui-effect" + new_sound.volume = sound.volume or 1 + new_sound.audible_distance_modifier = 1e20 + + data:extend{new_sound} +end + + +---@param sounds table +---@param path string +puan2_api.make_notes = function(sounds, path) + local notes = {} + for _, sound in pairs(sounds) do + notes[#notes+1] = { + name = sound.name, + sound = puan2_api.check_and_get_sound(sound, path) + } + end + return notes +end + + +local programmable_speaker = data.raw["programmable-speaker"]["programmable-speaker"].instruments +---@param sounds_list table +puan2_api.add_sounds = function(sounds_list) + for _, sound in pairs(sounds_list.sounds) do + puan2_api.add_sound(sound, sounds_list.path) + end + + if sounds_list.name then + local notes = puan2_api.make_notes(sounds_list.sounds, sounds_list.path) + return table.insert(programmable_speaker, {name = sounds_list.name, notes = notes}) + end +end + + +return puan2_api diff --git a/data.lua b/data.lua index 31f370d..3f0370f 100644 --- a/data.lua +++ b/data.lua @@ -4,6 +4,7 @@ local lazyAPI = lazyAPI simpleTiers = require("experimental/simpleTiers") easyTemplates = require("experimental/easyTemplates") puan_api = require("data-api/puan_api") +puan2_api = require("data-api/puan2_api") fakes = require("data-api/fakes") zk_lib = require("data-api/zk_lib") zk_SPD = require("experimental/SPD") diff --git a/info.json b/info.json index 6cc51c6..c263b86 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "zk-lib", - "version": "0.13.9", + "version": "0.13.10", "factorio_version": "1.1", "title": "ZwerOxotnik's extendable mod with 8 addons", "author": "ZwerOxotnik", diff --git a/static-libs b/static-libs index 2b3ba66..8ce1e94 160000 --- a/static-libs +++ b/static-libs @@ -1 +1 @@ -Subproject commit 2b3ba663c5af3c68dbc468e43f57f028b60713a7 +Subproject commit 8ce1e948b218353220510f43c5aba62662cfc5f6