mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
big ass modding update
This commit is contained in:
+26
-27
@@ -5,18 +5,26 @@
|
||||
-- onBoulderMoved = fn } where a script is a list of { "command", args... }
|
||||
-- rows executed by src/script/ScriptRunner.lua. Every hand-ported script
|
||||
-- cites the pokered source it was ported from.
|
||||
--
|
||||
-- The modules land in src/script/MapScripts.lua as the engine's base
|
||||
-- contribution: attachBase keeps the historical merge (talk tables merge
|
||||
-- per TEXT constant, other hooks are replaced by later files, so
|
||||
-- different files can each add NPCs to the same map), and mod
|
||||
-- contributions from the map_scripts registry compose on top of it.
|
||||
|
||||
local registry = {
|
||||
PALLET_TOWN = require("data.scripts.pallet_town"),
|
||||
OAKS_LAB = require("data.scripts.oaks_lab"),
|
||||
REDS_HOUSE_1F = require("data.scripts.reds_house"),
|
||||
CELADON_MANSION_ROOF_HOUSE = require("data.scripts.celadon_eevee"),
|
||||
}
|
||||
local MapScripts = require("src.script.MapScripts")
|
||||
|
||||
-- story-critical scripts, one table per map. Later files MERGE into
|
||||
-- earlier ones: talk tables merge per TEXT constant, other hooks
|
||||
-- (onEnter, onVictory, ...) are replaced, so different files can each
|
||||
-- add NPCs to the same map.
|
||||
for _, mapEntry in ipairs({
|
||||
{ "PALLET_TOWN", "data.scripts.pallet_town" },
|
||||
{ "OAKS_LAB", "data.scripts.oaks_lab" },
|
||||
{ "REDS_HOUSE_1F", "data.scripts.reds_house" },
|
||||
{ "CELADON_MANSION_ROOF_HOUSE", "data.scripts.celadon_eevee" },
|
||||
}) do
|
||||
MapScripts.attachBase(mapEntry[1], require(mapEntry[2]))
|
||||
end
|
||||
|
||||
-- story-critical scripts, one table per map, in the order the old merge
|
||||
-- loop required them
|
||||
for _, file in ipairs({ "data.scripts.story", "data.scripts.story2",
|
||||
"data.scripts.story3", "data.scripts.story4",
|
||||
"data.scripts.story5", "data.scripts.story6",
|
||||
@@ -24,33 +32,24 @@ for _, file in ipairs({ "data.scripts.story", "data.scripts.story2",
|
||||
"data.scripts.safari", "data.scripts.seafoam",
|
||||
"data.scripts.gyms" }) do
|
||||
for mapId, mod in pairs(require(file)) do
|
||||
local existing = registry[mapId]
|
||||
if not existing then
|
||||
registry[mapId] = mod
|
||||
else
|
||||
for k, v in pairs(mod) do
|
||||
if k == "talk" and existing.talk then
|
||||
for textConst, script in pairs(v) do
|
||||
existing.talk[textConst] = script
|
||||
end
|
||||
else
|
||||
existing[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
MapScripts.attachBase(mapId, mod)
|
||||
end
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.get(mapId)
|
||||
return registry[mapId]
|
||||
return MapScripts.get(mapId)
|
||||
end
|
||||
|
||||
-- script to run when the player talks to an object with this TEXT_ constant
|
||||
function M.talkScript(mapId, textConst)
|
||||
local mod = registry[mapId]
|
||||
return mod and mod.talk and mod.talk[textConst] or nil
|
||||
return MapScripts.talkScript(mapId, textConst)
|
||||
end
|
||||
|
||||
-- attribution for that script's run: the owning mod's source, nil for base
|
||||
function M.talkSource(mapId, textConst)
|
||||
return MapScripts.talkSource(mapId, textConst)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user