Jump to content

Recommended Posts

I'm creating a charging station for a robotic character, and I've been trying to figure out how to attach a hunger aura to the structure I made that will apply to only him when he stands on it. I'm a little lost though, since everything I tried just didn't do anything. Any help?

(Also, another thing: I can't seem to get the placer to work. Whenever I craft the structure it instantly spawns on top of me. I don't know if I'm missing anything or something, this is my first time trying to create a custom structure)

charging_station.lua:

Spoiler
require "prefabutil"
require "recipe"
require "modutil"

local assets=
{
    Asset("ANIM", "anim/charging_station.zip"),
    Asset("ATLAS", "images/inventoryimages/charging_station.xml"),
    Asset("IMAGE", "images/inventoryimages/charging_station.tex"),
}

local function fn()
    local inst = CreateEntity()
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddMiniMapEntity()
    inst.entity:AddNetwork()

    MakeObstaclePhysics(inst, 0.66)

    inst:AddTag("structure")

    local minimap = inst.entity:AddMiniMapEntity()
    minimap:SetIcon( "charging_station.tex" )

    inst.AnimState:SetBank("charging_station")
    inst.AnimState:SetBuild("charging_station")
    inst.AnimState:PlayAnimation("idle")

    if not TheWorld.ismastersim then
        return inst
    end

    STRINGS.CHARACTERS.GENERIC.DESCRIBE.CHARGING_STATION = "Test"
	STRINGS.CHARACTERS.PAINTER.DESCRIBE.CHARGING_STATION = "Test2"

    inst:AddComponent("lootdropper")
    inst:AddComponent("inspectable")
    inst:AddComponent("workable")
	
	inst.Physics:ClearCollisionMask()

		return inst
	end

return Prefab( "charging_station", fn, assets, prefabs),
MakePlacer( "charging_station_placer", "charging_station", "charging_station", "idle" ) 

 

modmain:

Spoiler
AddRecipe2("charging_station", 
	{
		Ingredient("transistor", 2),
		Ingredient("cutstone", 4)
	},
	RECIPETABS.CHARACTER,
	TECH.SCIENCE_ONE,
	{
		placer = "charging_station_placer",
		builder_tag = "painter",
		atlas = "images/inventoryimages/charging_station.xml"
	}
)

 

 

        inst:DoPeriodicTask(
    2.5, --time you want it to tick in seconds
    function(inst)
        local x, y, z = inst.Transform:GetWorldPosition()
        local ents = TheSim:FindEntities(x, y, z, 5.0, {"player"}, {"playerghost"}) --5.0 is the range, make it smaller if you'd like
        for _,v in pairs(ents)
        do
        if v:HasTag("puttaghere") then -- the tag needs to be changed
            v.components.hunger:DoDelta(-10) -- hunger you want when it ticks
            end
        end
    end
)    

Put this in your local function fn() and fill in the character tag

 

for the recipe I can't really help you as I'm using the old one but here's mine if you want to try it

 

local hellhound_house_recipe = AddRecipe("hellhound_house", -- name
{GLOBAL.Ingredient("boards", 4), GLOBAL.Ingredient("silk", 8), GLOBAL.Ingredient("rope", 8) }, --Ingredients
GLOBAL.RECIPETABS.FARM, -- tab ( FARM, WAR, DRESS etc)
GLOBAL.TECH.NONE, -- level (GLOBAL.TECH.NONE, GLOBAL.TECH.SCIENCE_ONE, etc)
"hellhound_house_placer", -- placer
nil, -- min_spacing
nil, -- nounlock
nil, -- numtogive
nil, -- builder_tag
"images/inventoryimages/hellhound_house.xml", -- atlas
"hellhound_house.tex") -- image
hellhound_house_recipe.builder_tag ="demondramos"
hellhound_house_recipe.tagneeded = false
hellhound_house_recipe.atlas = resolvefilepath("images/inventoryimages/hellhound_house.xml")

  • Thanks 1

Thanks for responding! Unfortunately I still couldn't get the effect (or placer) to work 💔 I also tried doing something similar to how Walter gains sanity from trees, but no luck there either. Not sure if it's worth mentioning, but for the structure I'm using a sample structure.

3 hours ago, kyupita said:

Thanks for responding! Unfortunately I still couldn't get the effect (or placer) to work 💔 I also tried doing something similar to how Walter gains sanity from trees, but no luck there either. Not sure if it's worth mentioning, but for the structure I'm using a sample structure.

NEVERMIND I FIGURED IT OUT!! I think the sample structure was the problem, I remade the structure using something from the game as a base and I finally got the aura to work. Now the only issue I'm having is with the placer

It didn't seem to be working right for me for some reason (I edited it a little so I may have accidentally broken something um), but I eventually ended up using this:

Spoiler
local G = GLOBAL
local Action = GLOBAL.Action
local ACTIONS = GLOBAL.ACTIONS
local ActionHandler = GLOBAL.ActionHandler

local resolvefilepath = GLOBAL.resolvefilepath

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local TECH = GLOBAL.TECH	
	
	
AddCharacterRecipe("charging_station",
	{ -- ingredients
		GLOBAL.Ingredient("transistor", 2),
		GLOBAL.Ingredient("cutstone", 4),
	},
	GLOBAL.TECH.SCIENCE_ONE,
	{ -- config
		builder_tag = "painter",
		atlas = "images/inventoryimages/charging_station.xml",
		placer = "charging_station_placer",
	}, 
	{ -- filters
		"CHARACTER",
		"STRUCTURES",
		"MODS",
	}
)

 

And now everything's working properly! All that's left for me to do now is actually draw the structure

 

Thank you very much again!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...