Fluxistence Posted September 18, 2018 Share Posted September 18, 2018 I've created two sets of trinket-like items: toys and plushies. First I made the toys, for which I made a single Spriter project with all of them and created a generic generation function for the prefabs. These work 100%. Then I made a copy of this file for the plushies and created a new Spriter project for them in a similar fashion. For some reason, only the first item in the plushies list (bunny) has the correct image when dropped on the ground. The second item (elephant) has the image of the bunny, and the rest are invisible. This is despite the fact that there is absolutely no special treatment for any of them. I.e. the code simply has a list of IDs, of which "bunny", "elephant" and "fox" are three, and the Spriter project has an entity for each plush with its name and an "idle" animation with the still image. Here is a screenshot with three plushies and three toys, both in the inventory and on the ground: You can see the name of the second bunny on the floor is "Plush Elephant", which in the inventory does show up as an elephant (second item on the left). And here is a screenshot of the Spriter project. I have closed the Spriter project, deleted the anim file, exited the game, invoked the autocompiler manually, saw it export the plushies, ran the game again and checked once more and it's still like this, so I know for sure that what I'm seeing in-game represents the current state of the code and the Spriter project. All the inventory images work fine, the names are good, just the images for when the items are on the ground are wrong in this weird fashion. And once again, I use the same exact mechanism for the toys and they work just fine. I'm really stumped here. Here is the code for the plushies (plushies.lua): local PLUSHNAMES = { bunny = "Plush Bunny", elephant = "Plush Elephant", fox = "Plush Fox", kitty = "Plush Kitty", lion = "Plush Lion", puppy = "Plush Puppy", raccoon = "Plush Raccoon", trex = "Plush T-Rex", turkey = "Plush Turkey", } local assets = { Asset("ANIM", "anim/plushies.zip"), } for id, name in pairs(PLUSHNAMES) do local prefabid = "plush_"..id table.insert(assets, Asset("ATLAS", "images/inventoryimages/"..prefabid..".xml")) table.insert(assets, Asset("IMAGE", "images/inventoryimages/"..prefabid..".tex")) end local function MakePlush(id, name) local prefabid = "plush_"..id local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank(id) inst.AnimState:SetBuild("plushies") inst.AnimState:PlayAnimation("idle") inst:AddTag("plush") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/"..prefabid..".xml" MakeHauntableLaunchAndSmash(inst) return inst end STRINGS.NAMES[string.upper(prefabid)] = name return Prefab(prefabid, fn, assets, prefabs) end local ret = {} for id, name in pairs(PLUSHNAMES) do table.insert(ret, MakePlush(id, name)) end return unpack(ret) And for reference, here is the code for the toys (toys.lua): local TOYNAMES = { cube = "Rubik's Cube", ball = "Toy Ball", -- legopieces = "Lego Pieces", -- Commented out for manual insertion as a repairer vroom = "Toy Car", tablet = "Tablet", bucket = "Bucket and Shovel", duck = "Rubber Duck", frisbee = "Frisbee", armymen = "Army Men", } local assets = { Asset("ANIM", "anim/toys.zip"), } for id, name in pairs(TOYNAMES) do local prefabid = "toy_"..id table.insert(assets, Asset("ATLAS", "images/inventoryimages/"..prefabid..".xml")) table.insert(assets, Asset("IMAGE", "images/inventoryimages/"..prefabid..".tex")) end local function MakeToy(id, name, repairer) local prefabid = "toy_"..id local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank(id) inst.AnimState:SetBuild("toys") inst.AnimState:PlayAnimation("idle") inst:AddTag("molebait") inst:AddTag("cattoy") inst:AddTag("toy") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/"..prefabid..".xml" if repairer then inst:AddComponent("repairer") inst.components.repairer.repairmaterial = MATERIALS.PLASTIC inst.components.repairer.healthrepairvalue = TUNING.REPAIR_CUTSTONE_HEALTH end MakeHauntableLaunchAndSmash(inst) return inst end STRINGS.NAMES[string.upper(prefabid)] = name return Prefab(prefabid, fn, assets, prefabs) end local ret = {} for id, name in pairs(TOYNAMES) do table.insert(ret, MakeToy(id, name)) end table.insert(ret, MakeToy("legopieces", "Lego Pieces", true)) return unpack(ret) Any help would be greatly appreciated. Thanks in advance. Link to comment Share on other sites More sharing options...
JohnWatson Posted September 22, 2018 Share Posted September 22, 2018 (edited) There are two solutions for this. The first method is to create a Spriter project for each different plushie. The second, and my preferred, method is to create separate animations for each plushie in one Spriter project. For the first method, you need to separate them into nine Spriter projects for each plushie. Assume that you name them as bunny.scml, elephant.scml, fox.scml, and so on. You'll have to replace this part of fn() : inst.AnimState:SetBank(id) inst.AnimState:SetBuild(id) inst.AnimState:PlayAnimation("idle") For the second method, you just need to have separate animations for each of them in plushies.scml, like so: And then they just need to play the animation: inst.AnimState:SetBank("plushies") inst.AnimState:SetBuild("plushies") inst.AnimState:PlayAnimation(id) Edited September 22, 2018 by JohnWatson Link to comment Share on other sites More sharing options...
Fluxistence Posted September 22, 2018 Author Share Posted September 22, 2018 Thank you very much; using different animations under the same bank solved the issue and now they render properly. =) I still don't understand why what I did didn't work, though. And especially why the bunny and elephant worked different from the others. It's no longer an issue to solve, but I'm really curious to know that. Do you have any idea? Link to comment Share on other sites More sharing options...
JohnWatson Posted September 22, 2018 Share Posted September 22, 2018 I'm going to assume it's because Klei's scml compiler doesn't like Spriter 'entities' (which you make with this button ) I've never personally used them and I don't know really know anybody else that uses them, so I'll just assume that's where the problem is Link to comment Share on other sites More sharing options...
Fluxistence Posted September 22, 2018 Author Share Posted September 22, 2018 Oh, I didn't know that. I'll be sure to avoid that from now on. Thanks again. ^_^ 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