forked from ShadowTheAge/yafc
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IMO, we've had too many people asking about PyHM problems recently, so I automated the fix. I also added an extra function to make life easier for us, and hopefully for mod authors too, once it becomes widely available.
- Loading branch information
Showing
7 changed files
with
68 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Script execution | ||
|
||
Mod-specific fixes go in this folder. | ||
The file name format is _modname.path.to.modfile_.lua | ||
|
||
Scripts are executed after `require("__modname__.path.to.modfile")`. | ||
`...` (varargs) will contain the return from the normal call to `require("")`. | ||
The script is expected to return a patched require result. | ||
|
||
It is not possible to create a script that explicitly executes after data.lua, data-updates.lua, or data-final-fixes.lua. | ||
|
||
## YAFC-specific data | ||
### Script-generated objects | ||
|
||
`data.script_enabled` is initially-empty sequence of tables that can be modified by these mod-fix scripts, or by mods themselves. | ||
Each table in `data.script_enabled` should contain `type` and `name` keys with string values. | ||
The object identified by the type and name (e.g. `{ type = "item", name = "carbonic-asteroid-chunk" }`) will be treated as an accessibility root, similar to nauvis or the character. | ||
The primary use for this table is to specify entities that are placed on the map via scripts, and starting items. | ||
|
||
`data.script_enabled:insert` accepts any number of array-or-entry arguments, and will insert all the supplied entries into `script_enabled`. | ||
For example, the first three calls all insert three items, but the last will insert coal and one invalid (ignored) entry: | ||
```lua | ||
data.script_enabled:insert({ type = "item", name = "iron-ore" }, { type = "item", name = "copper-ore" }, { type = "item", name = "coal" }) | ||
data.script_enabled:insert({{ type = "item", name = "iron-ore" }, { type = "item", name = "copper-ore" }}, { type = "item", name = "coal" }) | ||
data.script_enabled:insert({{ type = "item", name = "iron-ore" }, { type = "item", name = "copper-ore" }, { type = "item", name = "coal" }}) | ||
-- Don't do this, though: | ||
data.script_enabled:insert({{{ type = "item", name = "iron-ore" }, { type = "item", name = "copper-ore" }}, { type = "item", name = "coal" }}) | ||
``` | ||
|
||
## Example of a valid mod fix | ||
<filename: core.lualib.util.lua> | ||
```lua | ||
local util = ...; | ||
log("Captured it!"); | ||
return util; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
data.script_enabled:insert({ | ||
type = "item", | ||
name = "burner-mining-drill", | ||
}, | ||
{ | ||
type = "item", | ||
name = "offshore-pump", | ||
}) | ||
|
||
return ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters