Last active
September 17, 2020 02:54
-
-
Save Randactyl/152a31770aed36910584c301c5d2e669 to your computer and use it in GitHub Desktop.
Modification of Autonauts Workshop mod by spv to include well usage for all bucket types. Well now starts with crude buckets and can be upgrades with the materials used to make the subsequent tiers of bucket.
This file contains hidden or 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
| local WellBase = { | |
| Recipes = { | |
| "Water", | |
| }, | |
| ModelName = "Well", | |
| TopLeftCoord = {0, 0}, | |
| BottomRightCoord = {1, 1}, | |
| Access = {0, 2}, | |
| Spawn = {1, 2}, | |
| IsCustomModel = true, | |
| } | |
| local Well = { | |
| Recipes = WellBase.Recipes, | |
| ModelName = WellBase.ModelName, | |
| TopLeftCoord = WellBase.TopLeftCoord, | |
| BottomRightCoord = WellBase.BottomRightCoord, | |
| Access = WellBase.Access, | |
| Spawn = WellBase.Spawn, | |
| IsCustomModel = WellBase.IsCustomModel, | |
| Name = "Water Well", | |
| StructurePartsRequired = { | |
| "Plank", | |
| "Pole", | |
| }, | |
| NumberOfStructureParts = {6, 4}, | |
| } | |
| local WellCrude = { | |
| Recipes = WellBase.Recipes, | |
| ModelName = WellBase.ModelName, | |
| TopLeftCoord = WellBase.TopLeftCoord, | |
| BottomRightCoord = WellBase.BottomRightCoord, | |
| Access = WellBase.Access, | |
| Spawn = WellBase.Spawn, | |
| IsCustomModel = WellBase.IsCustomModel, | |
| Name = "Water Well (Crude)", | |
| StructurePartsRequired = { | |
| "Rock", | |
| "Mortar", | |
| "WoodenBeam", | |
| "FixingPeg", | |
| "RoofTiles", | |
| "Crank", | |
| "StringBall" | |
| }, | |
| NumberOfStructureParts = {32, 16, 3, 4, 32, 1, 1}, | |
| } | |
| local WellMetal = { | |
| Recipes = WellBase.Recipes, | |
| ModelName = WellBase.ModelName, | |
| TopLeftCoord = WellBase.TopLeftCoord, | |
| BottomRightCoord = WellBase.BottomRightCoord, | |
| Access = WellBase.Access, | |
| Spawn = WellBase.Spawn, | |
| IsCustomModel = WellBase.IsCustomModel, | |
| Name = "Water Well (Metal)", | |
| StructurePartsRequired = { | |
| "MetalPlateCrude", | |
| }, | |
| NumberOfStructureParts = {4}, | |
| } | |
| function Creation() | |
| ModConverter.CreateConverter( | |
| Well.Name, | |
| Well.Recipes, | |
| Well.StructurePartsRequired, | |
| Well.NumberOfStructureParts, | |
| Well.ModelName, | |
| Well.TopLeftCoord, | |
| Well.BottomRightCoord, | |
| Well.Access, | |
| Well.Spawn, | |
| Well.IsCustomModel | |
| ) | |
| ModConverter.UpdateModelScale(Well.Name, 0.35) | |
| ModConverter.UpdateModelTranslation(Well.Name, 1.5, 0, -1.5) | |
| ModConverter.RegisterForCustomCallback(Well.Name, "ConverterCreateItem", OnConverterItemCreated) | |
| ModConverter.CreateConverter( | |
| WellCrude.Name, | |
| WellCrude.Recipes, | |
| WellCrude.StructurePartsRequired, | |
| WellCrude.NumberOfStructureParts, | |
| WellCrude.ModelName, | |
| WellCrude.TopLeftCoord, | |
| WellCrude.BottomRightCoord, | |
| WellCrude.Access, | |
| WellCrude.Spawn, | |
| WellCrude.IsCustomModel | |
| ) | |
| ModConverter.UpdateModelScale(WellCrude.Name, 0.35) | |
| ModConverter.UpdateModelTranslation(WellCrude.Name, 1.5, 0, -1.5) | |
| ModConverter.RegisterForCustomCallback(WellCrude.Name, "ConverterCreateItem", OnConverterItemCreated) | |
| ModConverter.CreateConverter( | |
| WellMetal.Name, | |
| WellMetal.Recipes, | |
| WellMetal.StructurePartsRequired, | |
| WellMetal.NumberOfStructureParts, | |
| WellMetal.ModelName, | |
| WellMetal.TopLeftCoord, | |
| WellMetal.BottomRightCoord, | |
| WellMetal.Access, | |
| WellMetal.Spawn, | |
| WellMetal.IsCustomModel | |
| ) | |
| ModConverter.UpdateModelScale(WellMetal.Name, 0.35) | |
| ModConverter.UpdateModelTranslation(WellMetal.Name, 1.5, 0, -1.5) | |
| ModConverter.RegisterForCustomCallback(WellMetal.Name, "ConverterCreateItem", OnConverterItemCreated) | |
| end | |
| function BeforeLoad() | |
| ModVariable.SetVariableForBuildingUpgrade(WellCrude.Name, Well.Name) | |
| ModVariable.SetVariableForBuildingUpgrade(Well.Name, WellMetal.Name) | |
| ModVariable.SetIngredientsForRecipeSpecific(Well.Name, "Water", {"ToolBucket"}, {1}, 1) | |
| ModVariable.SetIngredientsForRecipeSpecific(WellCrude.Name, "Water", {"ToolBucketCrude"}, {1}, 1) | |
| ModVariable.SetIngredientsForRecipeSpecific(WellMetal.Name, "Water", {"ToolBucketMetal"}, {1}, 1) | |
| end | |
| function OnConverterItemCreated(converterName, converterTopLeftX, converterTopLeftY, itemUid, converterUid) | |
| -- Get bucket used in recipe. | |
| local lastObjectAddedType = ModConverter.GetConverterProperties(converterUid)[11] | |
| -- Get coordinate info of item spawned by recipe. | |
| local spawnedItemProperties = ModObject.GetObjectProperties(itemUid) | |
| local spawnX = spawnedItemProperties[2] | |
| local spawnY = spawnedItemProperties[3] | |
| -- Destroy good bucket created by recipe, since recipe amount created always at least 1. | |
| ModObject.DestroyObject(itemUid) | |
| -- Spawn bucket used in recipe filled with fresh water. | |
| ModBase.SpawnLiquid("Water", lastObjectAddedType, spawnX, spawnY) | |
| end |
Author
Hey, sorry I forgot to answer. Thanks for the suggestions, I will add these but I'm waiting for ConvertCreateItem to go out of beta to live version
Author
no problem! sorry, I didnt realize the new callback event wasnt generally available.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
revision 2 corrects a misunderstanding from the API docs on GetConverterProperties return values and moves common well properties to a single base entity so that changes get reflected across all well types.