Jump to content

My techtree is acting weird. What do


Recommended Posts

So i just started doing my own structure with its own tech tree but im lost, its giving me the tech tree of both myprefab and the perdshrine!

I double checked my modmain and prefab but i cant seem to find the cause of the matter. Maybe im just blind. Help?

MyPrefab:

 

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

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

--------------------------------

-- local function onopen(inst) 
    -- inst.AnimState:PlayAnimation("open") 
    -- inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_open")
-- end 

-- local function onclose(inst) 
    -- inst.AnimState:PlayAnimation("idle") 
    -- inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_close")        
-- end 

----------------------------------
----------------------------------
local MYPREFAB = {SCIENCE = 0, ANCIENT = 0, MYPREFAB = 2, MAGIC = 0, SHADOW = 0, CARTOGRAPHY = 0}

local function light(inst)    
	inst.Light:Enable(true)
end

local function extinguish(inst)
	inst.Light:Enable(false)
	inst.AnimState:PlayAnimation("idle")
end

local function complete_onturnon(inst)

	inst.AnimState:PlayAnimation("open") 
    if not inst.SoundEmitter:PlayingSound("idlesound") then
        inst.SoundEmitter:PlaySound("dontstarve/common/ancienttable_LP", "idlesound")
    end
	
end

local function complete_onturnoff(inst)
	inst.AnimState:PlayAnimation("idle")
        inst.SoundEmitter:KillSound("dontstarve/common/ancienttable_LP", "idlesound")
    end

local function complete_doonact(inst)
    if inst._activecount > 1 then
        inst._activecount = inst._activecount - 1
    else
        inst._activecount = 0
        inst.SoundEmitter:KillSound("sound")
    end
	inst.AnimState:PlayAnimation("open") 
    inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
end

local function complete_onactivate(inst)
	inst.AnimState:PlayAnimation("open") 

    inst._activecount = inst._activecount + 1

    if not inst.SoundEmitter:PlayingSound("sound") then
        inst.SoundEmitter:PlaySound("dontstarve/common/ancienttable_craft", "sound")
    end

    inst:DoTaskInTime(1.5, complete_doonact)
end
--------------------------------------

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

    MakeObstaclePhysics(inst, 0.66)

    inst:AddTag("structure")
    -- inst:AddTag("chest")

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

    inst.AnimState:SetBank("myprefab")
    inst.AnimState:SetBuild("myprefab")
    inst.AnimState:PlayAnimation("idle")
	
	inst.Light:Enable(false)
    inst.Light:SetRadius(4)
    inst.Light:SetFalloff(1)
    inst.Light:SetIntensity(0.75)
    inst.Light:SetColour(190 / 255, 250 / 255, 190 / 255)
	
	inst:AddTag("prototyper")
	-- inst:AddTag("giftmachine")

    if not TheWorld.ismastersim then
        return inst
    end
	
	inst:AddTag("antlion_sinkhole_blocker")

    STRINGS.CHARACTERS.GENERIC.DESCRIBE.MYPREFAB = "It's a custom prefab!" --Examine 

    inst:AddComponent("lootdropper")
    inst:AddComponent("inspectable")
    inst:AddComponent("workable")
	
	inst:AddComponent("prototyper")
	inst.components.prototyper.trees = MYPREFAB
	
	inst.components.prototyper.onturnon = complete_onturnon
    inst.components.prototyper.onturnoff = complete_onturnoff
    inst.components.prototyper.onactivate = complete_onactivate
	
	inst:AddComponent("playerprox")
    inst.components.playerprox:SetDist(10, 10.1)
    inst.components.playerprox:SetOnPlayerNear(light)
    inst.components.playerprox:SetOnPlayerFar(extinguish)

    -- inst:AddComponent("container")
    -- inst.components.container:WidgetSetup("treasurechest")
    -- inst.components.container.onopenfn = onopen
    -- inst.components.container.onclosefn = onclose
	
	inst._activecount = 0

    return inst
end

return Prefab( "common/myprefab", fn, assets, prefabs),
        MakePlacer( "common/myprefab_placer", "myprefab", "myprefab", "idle" ) 

My modmain:

 

PrefabFiles = {
	"myprefab",
}
local assets=
{
    Asset("ATLAS", "images/inventoryimages/myprefab.xml"),
    Asset("IMAGE", "images/inventoryimages/myprefab.tex"),
	
	Asset( "ATLAS", "images/hud/myprefabtab.xml" ),
	Asset( "IMAGE", "images/hud/myprefabtab.tex" ),
}
AddMinimapAtlas("images/inventoryimages/myprefab.xml")

--
modimport "custom_tech_tree.lua"
AddNewTechTree("MYPREFAB",2)

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH
local ACTIONS = GLOBAL.ACTIONS
local ActionHandler = GLOBAL.ActionHandler 
local Action = GLOBAL.Action
local EQUIPSLOTS = GLOBAL.EQUIPSLOTS
local EventHandler = GLOBAL.EventHandler
local FRAMES = GLOBAL.FRAMES
local State = GLOBAL.State
local TimeEvent = GLOBAL.TimeEvent
local COLLISION = GLOBAL.COLLISION
local SpawnPrefab = GLOBAL.SpawnPrefab
--

local myprefab_tab = AddRecipeTab("MyPrefab", 990, "images/hud/myprefabtab.xml", "myprefabtab.tex", nil )

AddRecipe("myprefab", 
{Ingredient("cutstone", 1)}, 
RECIPETABS.SCIENCE, TECH.SCIENCE_TWO, "myprefab_placer", nil, nil, nil, nil, "images/inventoryimages/myprefab.xml", "myprefab.tex")

local meat_recipe = GLOBAL.Recipe("meat",{Ingredient("nightmarefuel", 8)},                     
        myprefab_tab, {MYPREFAB = 2}, nil, nil, true, 8, nil)
	meat_recipe.atlas = "images/inventoryimages/myprefab.xml"

--local myrecipe = AddRecipe("myprefab", -- name
--{Ingredient("boards", 1)}, -- ingredients Add more like so , {Ingredient("boards", 1), Ingredient("rope", 2), Ingredient("twigs", 1), etc}
--GLOBAL.RECIPETABS.FARM, -- tab ( FARM, WAR, DRESS etc)
--GLOBAL.TECH.NONE, -- level (GLOBAL.TECH.NONE, GLOBAL.TECH.SCIENCE_ONE, etc)
--"myprefab_placer", -- placer
--nil, -- min_spacing
--nil, -- nounlock
--nil, -- numtogive
--nil, -- builder_tag
--"images/inventoryimages/myprefab.xml", -- atlas
--"myprefab.tex") -- image

GLOBAL.STRINGS.NAMES.MYPREFAB = "My Prefab" --It's name in-game
GLOBAL.STRINGS.RECIPE_DESC.MYPREFAB = "It's a custom prefab!" --recipe description
Edited by rons0n
Link to comment
Share on other sites

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
 Share

×
  • Create New...