Jump to content

Recommended Posts

Ok so i have this item that should be placeable, but for some reason when i build it nothing happens...

Can anyone help?

 

This is the prefab lua:

local Assets ={	Asset("ANIM", "anim/paintedrock.zip"),    Asset("ATLAS", "images/inventoryimages/paintedrock.xml"),    Asset("IMAGE", "images/inventoryimages/paintedrock.tex"),}local names = {     "prock1",    "prock2",    "prock3",    "prock4",    "prock5",}local function onsave(inst, data)    data.anim = inst.animnameendlocal function onload(inst, data)    if data and data.anim then        inst.animname = data.anim        inst.AnimState:PlayAnimation(inst.animname)    endendlocal function onhammered(inst, worker)    inst.components.lootdropper:DropLoot()    local rocks = SpawnPrefab("rocks")    rocks.Transform:SetPosition(inst.Transform:GetWorldPosition())    SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())    inst.SoundEmitter:PlaySound("dontstarve/common/destroy_stone")    inst:Remove()endlocal function onhit(inst, worker)    inst.AnimState:PlayAnimation("hit" .. inst.animname)    inst.AnimState:PushAnimation(inst.animname)endlocal function fn(Sim)	local inst = CreateEntity()    inst.entity:AddSoundEmitter()	inst.entity:AddTransform()	inst.entity:AddAnimState()    MakeObstaclePhysics(inst, .5)     inst:AddTag("structure")    inst.AnimState:SetBank("paintedrock")    inst.AnimState:SetBuild("paintedrock")	inst:AddComponent("inspectable")    inst:AddComponent("characterspecific")    inst.components.characterspecific:SetOwner("drok")    inst:AddComponent("lootdropper")    inst:AddComponent("workable")    inst.components.workable:SetWorkAction(ACTIONS.HAMMER)    inst.components.workable:SetWorkLeft(4)    inst.components.workable:SetOnFinishCallback(onhammered)    inst.components.workable:SetOnWorkCallback(onhit)      inst.animname = names[math.random(#names)]    inst.AnimState:PlayAnimation(inst.animname)    inst.OnSave = onsave    inst.OnLoad = onload     return instendSTRINGS.NAMES.PAINTEDROCK = "Rock Paintings"STRINGS.CHARACTERS.DROK.DESCRIBE.PAINTEDROCK = "Drok show dominance!"STRINGS.CHARACTERS.GENERIC.DESCRIBE.PAINTEDROCK = "Those paintings are from an ancient time..."return Prefab( "common/objects/paintedrock", fn, assets),        MakePlacer( "common/paintedrock_placer", "paintedrock", "paintedrock", "prock1" ) 

 

This is the recipe in the modmain:

local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSlocal OldIsRecipeValid = GLOBAL.IsRecipeValidlocal function IsRecipeValid(recipe)	return OldIsRecipeValid(recipe) and		((GLOBAL.ThePlayer and GLOBAL.ThePlayer:HasTag(recipe.name.."_builder")) or not recipe.tagneeded)endGLOBAL.IsRecipeValid = IsRecipeValidlocal Recipe = GLOBAL.Recipelocal RECIPETABS = GLOBAL.RECIPETABSlocal TECH = GLOBAL.TECHlocal recipes = {	Recipe("redpaint", {Ingredient("ash", 2), Ingredient("rocks", 1), Ingredient("berries_cooked", 3)}, RECIPETABS.REFINE, TECH.SCIENCE_ONE),	Recipe("wigstan", {Ingredient("wigstanstone", 1, "images/inventoryimages/wigstanstone.xml"), Ingredient("redpaint", 2, "images/inventoryimages/redpaint.xml")}, RECIPETABS.REFINE, TECH.SCIENCE_ONE),	Recipe("wigstanfull", {Ingredient("wigstan", 1, "images/inventoryimages/wigstan.xml"), Ingredient("beefalowool", 5), Ingredient("rope", 3)}, RECIPETABS.REFINE, TECH.SCIENCE_TWO),		Recipe("beefalo_hide", {Ingredient("beefalowool", 6), Ingredient("houndstooth", 1), Ingredient("silk", 6)}, RECIPETABS.DRESS, TECH.SCIENCE_TWO),	Recipe("javelin", {Ingredient("twigs", 2), Ingredient("rope", 1), Ingredient("houndstooth", 1)}, RECIPETABS.WAR, TECH.SCIENCE_ONE),	Recipe("paintedrock", {Ingredient("rocks", 3), Ingredient("redpaint", 2, "images/inventoryimages/redpaint.xml")}, RECIPETABS.TOWN, TECH.SCIENCE_TWO,"paintedrock_placer" ),	}for k,v in pairs(recipes) do    v.tagneeded = true    v.atlas = "images/inventoryimages/" .. v.name .. ".xml"end 

 

Thanks for your help!

@QuickShot010

By any chance, is your paintedrock invisible too?

return Prefab( "common/objects/paintedrock", fn, assets),
Shouldn't it be this?

return Prefab( "common/objects/paintedrock", fn, Assets),
Notice the capital "A". Edited by Ryuushu

@QuickShot010

By any chance, is your paintedrock invisible too?

return Prefab( "common/objects/paintedrock", fn, assets),
Shouldn't it be this?

return Prefab( "common/objects/paintedrock", fn, Assets),
Notice the capital "A".

 

 

Got it working, you have to be careful with everything writing code :p

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...