MF99K Posted April 15, 2016 Share Posted April 15, 2016 (edited) I guess the main problem here is that my logs don't seem to work at all game crashes, only thing the log says is that it detected a bad load I'm pretty sure it's an asset issue since that was the last problem I fixed before the crash and I fixed it in a really disorganized way. either way I have no idea how to fix it birds.zip Edited April 15, 2016 by mf99k Link to comment Share on other sites More sharing options...
Aquaterion Posted April 15, 2016 Share Posted April 15, 2016 (edited) I didn't run the code but i dont see why you're using; Asset("ANIM", "anim/"..name.."/anim.bin"), because first of all, you have to call the whole .zip which you already are doing, and second, anim.bin is basically the bank, and for each bird, you use the "crow" bank, so you don't even need the anim.bin in each of the bird files. Also, unless you're replacing the current birds.lua, I don't see why you're recreating the old birds. Edited April 15, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
MF99K Posted April 16, 2016 Author Share Posted April 16, 2016 (edited) 7 hours ago, Aquaterion said: I didn't run the code but i dont see why you're using; Asset("ANIM", "anim/"..name.."/anim.bin"), because first of all, you have to call the whole .zip which you already are doing, and second, anim.bin is basically the bank, and for each bird, you use the "crow" bank, so you don't even need the anim.bin in each of the bird files. Also, unless you're replacing the current birds.lua, I don't see why you're recreating the old birds. That's what I figured, but I wasn't the one who put the asset/bin stuff there so I wasn't sure if it was something I really needed. edit: just tried it and it's still having the same problem Edited April 16, 2016 by mf99k Link to comment Share on other sites More sharing options...
Aquaterion Posted April 16, 2016 Share Posted April 16, 2016 (edited) By removing the bird_build.zips from modmain.lua and removing the 3 default birds from extrabirds.lua, I was able to load in without a crash, phoebe works fine, magpie has no build and hoopoe crashes me with some sort of stategraph issue. The 2 birds I was able to spawn didn't drop anything, so you probably need to add; inst.components.lootdropper.numrandomloot = 1 , to each bird, or move it to below or above the "if" statement and have only 1. As for magpie not having a build, I saw that you have 2 magpie builds, mag_build and magpie_build, changing the birds name to "mag" made the textures work. The problem with hoopoe is quite simple, you have a "return" in his "randomloot table", so once the table is loaded, the rest of the code is being ignored. As for resizing phoebe, your code is fine, except you were missing an '=' in the "if" statement: local scalephi = 0.8 if name == "phoebe" then inst.Transform:SetScale(scalephi, scalephi, scalephi) end If you want I have a working version here, which I modified to use parameters in the MakeBird function rather than doing thing in the main "fn" depending on bird names; --[[ birds.lua This assumes the bird already has a build, inventory icon, sounds and a feather_name prefab exists ]]-- local brain = require "brains/birdbrain" local function ShouldSleep(inst) return DefaultSleepTest(inst) and not inst.sg:HasStateTag("flying") end local function OnAttacked(inst, data) local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, 30, {'bird'}) local num_friends = 0 local maxnum = 5 for k,v in pairs(ents) do if v ~= inst then v:PushEvent("gohome") num_friends = num_friends + 1 end if num_friends > maxnum then return end end end local function OnTrapped(inst, data) if data and data.trapper and data.trapper.settrapsymbols then data.trapper.settrapsymbols(inst.trappedbuild) end end local function OnDropped(inst) inst.sg:GoToState("stunned") end local function SeedSpawnTest() return not TheWorld.state.iswinter end local function makebird(name, soundname, loottable, psprefab, foodtype, scale) local assets= { Asset("ANIM", "anim/crow.zip"), Asset("ANIM", "anim/"..name.."_build.zip"), Asset("SOUND", "sound/birds.fsb") } local prefabs = { "cookedsmallmeat", } prefabs[2] = psprefab or "seeds"-- add the periodspawnprefab to "prefabs" list if loottable ~= nil then-- -- add all loot to "prefabs" list for key, loot in pairs(loottable) do key = tonumber(key) prefabs[key+2] = loot[1]--key+2 is due to the fact that "prefabs" list already has 2 values in it end end local function fn() local inst = CreateEntity() --Core components inst.entity:AddTransform() inst.entity:AddNetwork() inst.entity:AddPhysics() inst.entity:AddAnimState() inst.entity:AddDynamicShadow() inst.entity:AddSoundEmitter() --Initialize physics inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS) inst.Physics:ClearCollisionMask() inst.Physics:CollidesWith(COLLISION.WORLD) inst.Physics:SetSphere(1) inst.Physics:SetMass(1) inst:AddTag("bird") inst:AddTag(name) inst:AddTag("smallcreature") scale = scale or 1 inst.Transform:SetTwoFaced() inst.AnimState:SetBank("crow") inst.AnimState:SetBuild(name.."_build") inst.AnimState:PlayAnimation("idle") inst.DynamicShadow:SetSize(scale, scale - 0.25) inst.DynamicShadow:Enable(false) inst.Transform:SetScale(scale, scale, scale) MakeFeedablePetPristine(inst) if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst.sounds = { takeoff = "dontstarve/birds/takeoff_"..soundname, chirp = "dontstarve/birds/chirp_"..soundname, flyin = "dontstarve/birds/flyin", } inst.trappedbuild = name.."_build" inst:AddComponent("locomotor") -- locomotor must be constructed before the stategraph inst.components.locomotor:EnableGroundSpeedMultiplier(false) inst.components.locomotor:SetTriggersCreep(false) inst:SetStateGraph("SGbird") if loottable ~= nil then inst:AddComponent("lootdropper") inst.components.lootdropper.numrandomloot = 1 for key, loot in pairs(loottable) do inst.components.lootdropper:AddRandomLoot(loot[1], loot[2])--loot[1] is prefab, loot[2] is rarity end end inst:AddComponent("occupier") inst:AddComponent("eater") inst.components.eater:SetDiet({ foodtype or FOODTYPE.SEEDS }, { foodtype or FOODTYPE.SEEDS }) inst:AddComponent("sleeper") inst.components.sleeper:SetSleepTest(ShouldSleep) inst:AddComponent("inventoryitem") inst.components.inventoryitem.nobounce = true inst.components.inventoryitem.canbepickedup = false inst.components.inventoryitem.imagename = name inst.components.inventoryitem.atlasname = "images/inventoryimages/"..name..".xml" inst:AddComponent("cookable") inst.components.cookable.product = "cookedsmallmeat" inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "crow_body" --inst.components.combat.canbeattackedfn = canbeattacked inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.BIRD_HEALTH) inst.components.health.murdersound = "dontstarve/wilson/hit_animal" inst:AddComponent("inspectable") inst:SetBrain(brain) MakeSmallBurnableCharacter(inst, "crow_body") MakeTinyFreezableCharacter(inst, "crow_body") inst:AddComponent("hauntable") inst.components.hauntable:SetHauntValue(TUNING.HAUNT_TINY) inst:AddComponent("periodicspawner") inst.components.periodicspawner:SetPrefab(psprefab or "seeds")--set to psprefab or "seeds"(it will be set to "seeds" if psprefab is nil) inst.components.periodicspawner:SetDensityInRange(40, 2) inst.components.periodicspawner:SetMinimumSpacing(7) inst.components.periodicspawner:SetSpawnTestFn( SeedSpawnTest ) inst:ListenForEvent("ontrapped", OnTrapped) inst:ListenForEvent("attacked", OnAttacked) local extrabirdspawner = TheWorld.components.extrabirdspawner if extrabirdspawner ~= nil then inst:ListenForEvent("onremove", extrabirdspawner.StopTrackingFn) inst:ListenForEvent("enterlimbo", extrabirdspawner.StopTrackingFn) --inst:ListenForEvent("exitlimbo", extrabirdspawner.StartTrackingFn) extrabirdspawner:StartTracking(inst) end MakeFeedablePet(inst, TUNING.BIRD_PERISH_TIME, nil, OnDropped) return inst end return Prefab("forest/animals/"..name, fn, assets, prefabs) end --TEMPLATE --makebird("prefabname", "soundname", {loottables}, "periodcspawnprefab", FOODTYPE.TYPE, scale) --- HOOPOE --- return makebird( "hoopoe", "junco", {{"smallmeat", .5}, {"orangegem", .5}} ),-- since the other 3 variables left are default, we stop at loottable --- MAGPIE --- makebird( "mag", --prefabname "crow", --soundname {{"feather_crow", .3}, {"goldnugget", .1}, {"flint", .1}}, --loots "goldnugget", --period spawn prefab FOODTYPE.ELEMENTAL ), --foodtype --- PHOEBE --- makebird( "phoebe", "robin", {{"feather_crow", .5}}, nil,-- we dont need periodic spawn prefab or foodtype nil,-- since "phoebe" uses the default ones. 0.8-- scale ), --- BLUEBIRD --- makebird( "bluebird", "robin", {{"smallmeat", .5}, {"berries", .5}, {"feather_robin_winter", .1}} ), --- WAXWING --- makebird( "waxwing", "crow", {{"smallmeat", .5}, {"berries", .5}, {"feather_robin", .1}}, "berries", FOODTYPE.VEGGIE )--, Edited April 16, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
MF99K Posted April 17, 2016 Author Share Posted April 17, 2016 21 hours ago, Aquaterion said: By removing the bird_build.zips from modmain.lua and removing the 3 default birds from extrabirds.lua, I was able to load in without a crash, phoebe works fine, magpie has no build and hoopoe crashes me with some sort of stategraph issue. The 2 birds I was able to spawn didn't drop anything, so you probably need to add; inst.components.lootdropper.numrandomloot = 1 , to each bird, or move it to below or above the "if" statement and have only 1. As for magpie not having a build, I saw that you have 2 magpie builds, mag_build and magpie_build, changing the birds name to "mag" made the textures work. The problem with hoopoe is quite simple, you have a "return" in his "randomloot table", so once the table is loaded, the rest of the code is being ignored. As for resizing phoebe, your code is fine, except you were missing an '=' in the "if" statement: local scalephi = 0.8 if name == "phoebe" then inst.Transform:SetScale(scalephi, scalephi, scalephi) end If you want I have a working version here, which I modified to use parameters in the MakeBird function rather than doing thing in the main "fn" depending on bird names; Reveal hidden contents --[[ birds.lua This assumes the bird already has a build, inventory icon, sounds and a feather_name prefab exists ]]-- local brain = require "brains/birdbrain" local function ShouldSleep(inst) return DefaultSleepTest(inst) and not inst.sg:HasStateTag("flying") end local function OnAttacked(inst, data) local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, 30, {'bird'}) local num_friends = 0 local maxnum = 5 for k,v in pairs(ents) do if v ~= inst then v:PushEvent("gohome") num_friends = num_friends + 1 end if num_friends > maxnum then return end end end local function OnTrapped(inst, data) if data and data.trapper and data.trapper.settrapsymbols then data.trapper.settrapsymbols(inst.trappedbuild) end end local function OnDropped(inst) inst.sg:GoToState("stunned") end local function SeedSpawnTest() return not TheWorld.state.iswinter end local function makebird(name, soundname, loottable, psprefab, foodtype, scale) local assets= { Asset("ANIM", "anim/crow.zip"), Asset("ANIM", "anim/"..name.."_build.zip"), Asset("SOUND", "sound/birds.fsb") } local prefabs = { "cookedsmallmeat", } prefabs[2] = psprefab or "seeds"-- add the periodspawnprefab to "prefabs" list if loottable ~= nil then-- -- add all loot to "prefabs" list for key, loot in pairs(loottable) do key = tonumber(key) prefabs[key+2] = loot[1]--key+2 is due to the fact that "prefabs" list already has 2 values in it end end local function fn() local inst = CreateEntity() --Core components inst.entity:AddTransform() inst.entity:AddNetwork() inst.entity:AddPhysics() inst.entity:AddAnimState() inst.entity:AddDynamicShadow() inst.entity:AddSoundEmitter() --Initialize physics inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS) inst.Physics:ClearCollisionMask() inst.Physics:CollidesWith(COLLISION.WORLD) inst.Physics:SetSphere(1) inst.Physics:SetMass(1) inst:AddTag("bird") inst:AddTag(name) inst:AddTag("smallcreature") scale = scale or 1 inst.Transform:SetTwoFaced() inst.AnimState:SetBank("crow") inst.AnimState:SetBuild(name.."_build") inst.AnimState:PlayAnimation("idle") inst.DynamicShadow:SetSize(scale, scale - 0.25) inst.DynamicShadow:Enable(false) inst.Transform:SetScale(scale, scale, scale) MakeFeedablePetPristine(inst) if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst.sounds = { takeoff = "dontstarve/birds/takeoff_"..soundname, chirp = "dontstarve/birds/chirp_"..soundname, flyin = "dontstarve/birds/flyin", } inst.trappedbuild = name.."_build" inst:AddComponent("locomotor") -- locomotor must be constructed before the stategraph inst.components.locomotor:EnableGroundSpeedMultiplier(false) inst.components.locomotor:SetTriggersCreep(false) inst:SetStateGraph("SGbird") if loottable ~= nil then inst:AddComponent("lootdropper") inst.components.lootdropper.numrandomloot = 1 for key, loot in pairs(loottable) do inst.components.lootdropper:AddRandomLoot(loot[1], loot[2])--loot[1] is prefab, loot[2] is rarity end end inst:AddComponent("occupier") inst:AddComponent("eater") inst.components.eater:SetDiet({ foodtype or FOODTYPE.SEEDS }, { foodtype or FOODTYPE.SEEDS }) inst:AddComponent("sleeper") inst.components.sleeper:SetSleepTest(ShouldSleep) inst:AddComponent("inventoryitem") inst.components.inventoryitem.nobounce = true inst.components.inventoryitem.canbepickedup = false inst.components.inventoryitem.imagename = name inst.components.inventoryitem.atlasname = "images/inventoryimages/"..name..".xml" inst:AddComponent("cookable") inst.components.cookable.product = "cookedsmallmeat" inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "crow_body" --inst.components.combat.canbeattackedfn = canbeattacked inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.BIRD_HEALTH) inst.components.health.murdersound = "dontstarve/wilson/hit_animal" inst:AddComponent("inspectable") inst:SetBrain(brain) MakeSmallBurnableCharacter(inst, "crow_body") MakeTinyFreezableCharacter(inst, "crow_body") inst:AddComponent("hauntable") inst.components.hauntable:SetHauntValue(TUNING.HAUNT_TINY) inst:AddComponent("periodicspawner") inst.components.periodicspawner:SetPrefab(psprefab or "seeds")--set to psprefab or "seeds"(it will be set to "seeds" if psprefab is nil) inst.components.periodicspawner:SetDensityInRange(40, 2) inst.components.periodicspawner:SetMinimumSpacing(7) inst.components.periodicspawner:SetSpawnTestFn( SeedSpawnTest ) inst:ListenForEvent("ontrapped", OnTrapped) inst:ListenForEvent("attacked", OnAttacked) local extrabirdspawner = TheWorld.components.extrabirdspawner if extrabirdspawner ~= nil then inst:ListenForEvent("onremove", extrabirdspawner.StopTrackingFn) inst:ListenForEvent("enterlimbo", extrabirdspawner.StopTrackingFn) --inst:ListenForEvent("exitlimbo", extrabirdspawner.StartTrackingFn) extrabirdspawner:StartTracking(inst) end MakeFeedablePet(inst, TUNING.BIRD_PERISH_TIME, nil, OnDropped) return inst end return Prefab("forest/animals/"..name, fn, assets, prefabs) end --TEMPLATE --makebird("prefabname", "soundname", {loottables}, "periodcspawnprefab", FOODTYPE.TYPE, scale) --- HOOPOE --- return makebird( "hoopoe", "junco", {{"smallmeat", .5}, {"orangegem", .5}} ),-- since the other 3 variables left are default, we stop at loottable --- MAGPIE --- makebird( "mag", --prefabname "crow", --soundname {{"feather_crow", .3}, {"goldnugget", .1}, {"flint", .1}}, --loots "goldnugget", --period spawn prefab FOODTYPE.ELEMENTAL ), --foodtype --- PHOEBE --- makebird( "phoebe", "robin", {{"feather_crow", .5}}, nil,-- we dont need periodic spawn prefab or foodtype nil,-- since "phoebe" uses the default ones. 0.8-- scale ), --- BLUEBIRD --- makebird( "bluebird", "robin", {{"smallmeat", .5}, {"berries", .5}, {"feather_robin_winter", .1}} ), --- WAXWING --- makebird( "waxwing", "crow", {{"smallmeat", .5}, {"berries", .5}, {"feather_robin", .1}}, "berries", FOODTYPE.VEGGIE )--, Thanks for helping me with that the only problem is that the spawner doesn't seem to be working and the waxwing's inventory image doesn't seem to be working either. any ideas? Link to comment Share on other sites More sharing options...
Aquaterion Posted April 17, 2016 Share Posted April 17, 2016 (edited) for the spawner you had 2 lines of code removed for some reason in here: local function PickBird(spawnpoint) local tile = _map:GetTileAtPoint(spawnpoint:Get()) local bird = GetRandomItem(BIRD_TYPES[tile] or { "crow" }) -- this line was removed return _worldstate.iswinter and bird == "robin" and "robin_winter" or bird -- so was this 1 end as for waxwing, my waxwing inventory image seems to be working just fine. you sure it's not commented in modmain.lua? Btw, I was messing around trying to get the new birds to spawn without adding a new component, and this seems to work fine; (NOTE: this is the whole modmain.lua) IF YOU'RE GONNA USE THIS, MAKE SURE YOU CHANGE EVERY "extrabirdspawner" TO "birdspawner" IN extrabirds.lua PrefabFiles = { "extrabirds", } Assets= { Asset("ATLAS","images/inventoryimages/phoebe.xml"), Asset("ATLAS","images/inventoryimages/mag.xml"), Asset("ATLAS","images/inventoryimages/waxwing.xml"), Asset("ATLAS","images/inventoryimages/hoopoe.xml"), Asset("ATLAS","images/inventoryimages/bluebird.xml"), } local STRINGS = GLOBAL.STRINGS local RECIPETABS = GLOBAL.RECIPETABS local Recipe = GLOBAL.Recipe local Ingredient = GLOBAL.Ingredient local TECH = GLOBAL.TECH STRINGS.NAMES.PHOEBE="BlackPhoebe" STRINGS.CHARACTERS.GENERIC.DESCRIBE.PHOEBE="He'salldressedup!" STRINGS.NAMES.MAG="Magpie" STRINGS.CHARACTERS.GENERIC.DESCRIBE.MAG="Ahoarderofshinythings" STRINGS.NAMES.HOOPOE="Hoopoe" STRINGS.CHARACTERS.GENERIC.DESCRIBE.HOOPOE="That'sanoddlookingbird" STRINGS.NAMES.WAXWING="Waxwing" STRINGS.CHARACTERS.GENERIC.DESCRIBE.WAXWING="HelookslikequitetheBohemian." STRINGS.NAMES.BLUEBIRD="Bluebird" STRINGS.CHARACTERS.GENERIC.DESCRIBE.BLUEBIRD="Ahoarderofshinythings" AddComponentPostInit("birdspawner", function(self) function self:SpawnBird(spawnpoint, ignorebait) local EXTRABIRD_TYPES = { --[GROUND.IMPASSABLE] = { "" }, --[GROUND.ROAD] = { "bluebird" }, [GROUND.ROCKY] = {"crow", "mag", "hoopoe"}, [GROUND.DIRT] = {"crow", "mag", "phoebe"}, [GROUND.SAVANNA] = {"robin", "crow", "mag", "phoebe"}, [GROUND.GRASS] = {"robin", "phoebe", "hoopoe"}, [GROUND.FOREST] = {"robin", "crow", "mag", "phoebe"}, [GROUND.MARSH] = {"crow", "phoebe"}, [GROUND.DESERT_DIRT] = {"mag", "hoopoe"}, [GROUND.DECIDUOUS] = {"mag", "phoebe"}, } local function PickFromAllBirds(spawnpoint) local tile = GLOBAL.TheWorld.Map:GetTileAtPoint(spawnpoint:Get()) local bird = GLOBAL.GetRandomItem(EXTRABIRD_TYPES[tile] or { "bluebird" }) -- "bluebird" is default bird if none are found return GLOBAL.TheWorld.state.iswinter and bird == "robin" and "robin_winter" or bird end local function IsDangerNearby(x, y, z) local ents = TheSim:FindEntities(x, y, z, 8, { "scarytoprey" }) return GLOBAL.next(ents) ~= nil end local prefab = PickFromAllBirds(spawnpoint) if prefab == nil then return end local bird = GLOBAL.SpawnPrefab(prefab) if math.random() < .5 then bird.Transform:SetRotation(180) end if bird:HasTag("bird") then spawnpoint.y = 15 end --see if theres bait nearby that we might spawn into if bird.components.eater and not ignorebait then local bait = TheSim:FindEntities(spawnpoint.x, 0, spawnpoint.z, 15) for k, v in pairs(bait) do local x, y, z = v.Transform:GetWorldPosition() if bird.components.eater:CanEat(v) and v.components.bait and not (v.components.inventoryitem and v.components.inventoryitem:IsHeld()) and not IsDangerNearby(x, y, z) then spawnpoint.x, spawnpoint.z = x, z bird.bufferedaction = GLOBAL.BufferedAction(bird, v, GLOBAL.ACTIONS.EAT) break elseif v.components.trap and v.components.trap.isset and (not v.components.trap.targettag or bird:HasTag(v.components.trap.targettag)) and not v.components.trap.issprung and math.random() < TUNING.BIRD_TRAP_CHANCE and not IsDangerNearby(x, y, z) then spawnpoint.x, spawnpoint.z = x, z break end end end bird.Physics:Teleport(spawnpoint:Get()) return bird end end) Edited April 17, 2016 by Aquaterion 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