NeddoFreddo Posted May 19, 2017 Share Posted May 19, 2017 When I try to build the structure, I get this error: The log says the exact same thing as the game. I checked map.lua and this is the related paragraph. function Map:CanDeployRecipeAtPoint(pt, recipe, rot) return self:IsPassableAtPoint(pt:Get()) and (recipe.testfn == nil or recipe.testfn(pt, rot)) and self:IsDeployPointClear(pt, nil, recipe.min_spacing or 3.2) end Which doesn't really explain to me why it's crashing. My prefab.lua: Spoiler require "prefabutil" require "recipe" require "modutil" local assets= { Asset("ANIM", "anim/musicprototyper1.zip"), Asset("ATLAS", "images/inventoryimages/musicprototyper1.xml"), Asset("IMAGE", "images/inventoryimages/musicprototyper1.tex"), } local prefabs = { "collapse_small", } local function onhammered(inst, worker) local fx = SpawnPrefab("collapse_small") fx.Transform:SetPosition(inst.Transform:GetWorldPosition()) fx:SetMaterial("wood") inst:Remove() end local function onhit(inst, worker) inst.AnimState:PlayAnimation("hit") --hit inst.AnimState:PushAnimation("idle", true) --closed? end local function onbuilt(inst) inst.AnimState:PlayAnimation("place") --place inst.AnimState:PushAnimation("idle", true) inst.SoundEmitter:PlaySound("dontstarve/common/dragonfly_chest_craft") end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() --inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() MakeObstaclePhysics(inst, 0.33) inst:AddTag("structure") --local minimap = inst.entity:AddMiniMapEntity() --minimap:SetIcon( "musicprototyper1.tex" ) inst.AnimState:SetBank("musicprototyper1") inst.AnimState:SetBuild("musicprototyper1") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst:AddComponent("lootdropper") inst:AddComponent("inspectable") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(2) inst.components.workable:SetOnFinishCallback(onhammered) inst.components.workable:SetOnWorkCallback(onhit) inst:ListenForEvent("onbuilt", onbuilt) return inst end STRINGS.CHARACTERS.WILFRED.DESCRIBE.MUSICPROTOTYPER1 = "I don't actually write music on that. Just ideas for weaponised instruments." --wilfred STRINGS.CHARACTERS.GENERIC.DESCRIBE.MUSICPROTOTYPER1 = "Music isn't really my thing." --wilson and mod characters STRINGS.CHARACTERS.WAXWELL.DESCRIBE.MUSICPROTOTYPER1 = "Music... it can free the soul, or trap it forever." --maxwell --STRINGS.CHARACTERS.WILSON.DESCRIBE.MUSICPROTOTYPER1 = "Lol, wilson's quotes don't work... lmao XD lol rofl" --wilson(doesn't work) STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.MUSICPROTOTYPER1 = "Little black dots on paper always confuse Wolfgang!" --wolfgang STRINGS.CHARACTERS.WILLOW.DESCRIBE.MUSICPROTOTYPER1 = "I suppose I could burn the pages..." --willow STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.MUSICPROTOTYPER1 = "I wish I could read something other than a script." --wigfrid STRINGS.CHARACTERS.WX78.DESCRIBE.MUSICPROTOTYPER1 = "MUSIC IS JUST AN ILLUSION OF FLESHLING PERCEPTION" --wx-78 STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.MUSICPROTOTYPER1 = "The pages are covered in notes describing the construction of a death tuba." --wickerbottom STRINGS.CHARACTERS.WEBBER.DESCRIBE.MUSICPROTOTYPER1 = "I always wanted to play the guitar." --webber STRINGS.CHARACTERS.WOODIE.DESCRIBE.MUSICPROTOTYPER1 = "I should pull out the old guitar, eh?" --woodie STRINGS.CHARACTERS.WENDY.DESCRIBE.MUSICPROTOTYPER1 = "A temporary escape from sadness." --wendy return Prefab( "common/musicprototyper1", fn, assets, prefabs), MakePlacer( "common/musicprototyper1_placer", "musicprototyper1", "musicprototyper1", "idle" ) Any help would be appreciated. Link to comment Share on other sites More sharing options...
Lumina Posted May 19, 2017 Share Posted May 19, 2017 I don't have a clue about what is wrong, but does the crash happen when : - you build the structure (click on "build" button) - you place it on ground ? Also, does the same crash happen if you try to spawn the structure with console commande ? ( c_spawn("musicprototyper1") ) It could help define when the crash happen. Link to comment Share on other sites More sharing options...
myxal Posted May 19, 2017 Share Posted May 19, 2017 @NeddoFreddo, this doesn't look right: return Prefab( "common/musicprototyper1", fn, assets, prefabs), MakePlacer( "common/musicprototyper1_placer", "musicprototyper1", "musicprototyper1", "idle" ) You're either missing a parenthesis, or have an extra comma there. Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted May 19, 2017 Share Posted May 19, 2017 return Prefab("common/objects/musicprototyper1", fn, assets, prefabs), MakePlacer( "common/musicprototyper1_placer", "musicprototyper1", "musicprototyper1", "idle" ) Your missing the objects search path near the end, I got the code from my mod if you want to take a look for side by side comparison. I was a bit lazy when it came to making the hammer function. Also putting: inst.entity:SetPristine() may help in fn() just before TheWorld.ismastersim. Idk why that pristine function is needed but it does cause problems down the road without it. Here's one of my structure code feel free to do a comparison: require "prefabutil" require "modutil" local Assets = { Asset("ANIM", "anim/dust_house.zip"), } local function onbuilt(inst) inst.AnimState:PlayAnimation("idle") end local function onhammered(inst, worker) inst:Remove() end local function onfinished(inst) if not inst:HasTag("burnt") then --inst.AnimState:PlayAnimation("destroy") --inst:ListenForEvent("animover", function(inst, data) inst:Remove() end) inst.persists = false --inst:DoTaskInTime(16*FRAMES, function() inst.SoundEmitter:PlaySound ("dontstarve/common/tent_dis_twirl") end) end end local function wakeuptest(inst, phase) if phase ~= inst.sleep_phase then inst.components.sleepingbag:DoWakeUp() end end local function onwake(inst, sleeper, nostatechange) if inst.sleeptask ~= nil then inst.sleeptask:Cancel() inst.sleeptask = nil end inst:StopWatchingWorldState("phase", wakeuptest) if not nostatechange then if sleeper.sg:HasStateTag("tent") then sleeper.sg.statemem.iswaking = true end sleeper.sg:GoToState("wakeup") end if inst.sleep_anim ~= nil then inst.AnimState:PushAnimation("idle", true) end inst.components.finiteuses:Use() end local function onsleeptick(inst, sleeper) local isstarving = sleeper.components.beaverness ~= nil and sleeper.components.beaverness:IsStarving() if sleeper.components.hunger ~= nil then sleeper.components.hunger:DoDelta(inst.hunger_tick, true, true) isstarving = sleeper.components.hunger:IsStarving() end if sleeper.components.sanity ~= nil and sleeper.components.sanity:GetPercentWithPenalty() < 1 then sleeper.components.sanity:DoDelta(TUNING.SLEEP_SANITY_PER_TICK, true) end if not isstarving and sleeper.components.health ~= nil then sleeper.components.health:DoDelta(TUNING.SLEEP_HEALTH_PER_TICK * 2, true, inst.prefab, true) end if sleeper.components.temperature ~= nil then if inst.is_cooling then if sleeper.components.temperature:GetCurrent() > TUNING.SLEEP_TARGET_TEMP_TENT then sleeper.components.temperature:SetTemperature(sleeper.components.temperature:GetCurrent() - TUNING.SLEEP_TEMP_PER_TICK) end elseif sleeper.components.temperature:GetCurrent() < TUNING.SLEEP_TARGET_TEMP_TENT then sleeper.components.temperature:SetTemperature(sleeper.components.temperature:GetCurrent() + TUNING.SLEEP_TEMP_PER_TICK) end end if isstarving then inst.components.sleepingbag:DoWakeUp() end end local function onsleep(inst, sleeper) inst:WatchWorldState("phase", wakeuptest) inst.AnimState:PlayAnimation("idle", true) if inst.sleeptask ~= nil then inst.sleeptask:Cancel() end inst.sleeptask = inst:DoPeriodicTask(TUNING.SLEEP_TICK_PERIOD, onsleeptick, nil, sleeper) end local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddLight() MakeObstaclePhysics(inst, 2) inst.AnimState:SetBank("dust_house") inst.AnimState:SetBuild("dust_house") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(1.5, 1.75, 1.5) --inst.Transform:SetScale(imagewidth, z, lawn) inst.entity:SetPristine() inst:AddTag("tent") inst:AddTag("structure") inst:AddTag("nosleepanim") inst.Light:SetRadius(5) inst.Light:SetFalloff(1) inst.Light:SetIntensity(.5) inst.Light:SetColour(128/255, 255/255, 255/255) inst.Light:Enable(true) if not TheWorld.ismastersim then return inst end inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(80) inst.components.finiteuses:SetUses(80) inst.components.finiteuses:SetOnFinished(onfinished) inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(100) inst.components.workable:SetOnFinishCallback(onhammered) inst:AddComponent("inspectable") inst:AddComponent("sleepingbag") inst.components.sleepingbag.onsleep = onsleep inst.components.sleepingbag.onwake = onwake inst.components.sleepingbag.dryingrate = math.max(0, -TUNING.SLEEP_WETNESS_PER_TICK / TUNING.SLEEP_TICK_PERIOD) inst:ListenForEvent("onbuilt", onbuilt) inst.sleep_phase = "night" inst.sleep_anim = "sleep_loop" inst.hunger_tick = TUNING.SLEEP_HUNGER_PER_TICK MakeLargePropagator(inst) return inst end STRINGS.RECIPE_DESC.DUST_HOUSE = "Own a home like\nyou were suppose to." return Prefab( "common/objects/dust_house", fn, Assets), MakePlacer( "common/dust_house_placer", "dust_house", "dust_house", "idle" ) P.S I have another structure in my dust mod named dust_resurrection if you need another example. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now