QuickShot010 Posted February 4, 2015 Share Posted February 4, 2015 Ok, so a while back i added Cave Paintings to my mod, Drok the Caveman. The cave paintings are randomized, just like the flowers are. But i want a way to choose which cave paintings you are going to place without spamming the crafting tab. Maybe something like when you are placing it you can press a key or mouse button to change the 'random' art. This is the paintedrock.lua at the moment: local Assets = { Asset("ANIM", "anim/paintedrock.zip"), Asset("ATLAS", "images/inventoryimages/paintedrock.xml"), } local names = { "prock1", "prock2", "prock3", "prock4", "prock5", } local INTENSITY = .5 local function onsave(inst, data) data.anim = inst.animname end local function onload(inst, data) if data and data.anim then inst.animname = data.anim inst.AnimState:PlayAnimation(inst.animname) end end local 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() end local function onhit(inst, worker) inst.AnimState:PlayAnimation("hit" .. inst.animname) inst.AnimState:PushAnimation(inst.animname) end local function fn(Sim) local inst = CreateEntity() inst.entity:AddSoundEmitter() local light = inst.entity:AddLight() light:SetFalloff(1) light:SetIntensity(INTENSITY) light:SetRadius(1) light:SetColour(180/255, 195/255, 150/255) light:Enable(false) inst.entity:AddTransform() inst.entity:AddAnimState() MakeObstaclePhysics(inst, .5) inst:AddComponent("fader") 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 if GetWorld():IsCave() then STRINGS.CHARACTERS.DROK.DESCRIBE.PAINTEDROCK = "It so beautiful it shine!" STRINGS.CHARACTERS.GENERIC.DESCRIBE.PAINTEDROCK = "I'm not sure what makes it shine..." end return inst end STRINGS.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" ) I hope someone can help! Link to comment https://forums.kleientertainment.com/forums/topic/50540-choosing-between-prefab-art-when-building-something/ Share on other sites More sharing options...
Blueberrys Posted February 4, 2015 Share Posted February 4, 2015 (edited) @QuickShot010, I understand your issue, but I'm not sure what you're expecting. Do you want to know how to use the mouse/keyboard inputs? Are you unsure how to change the painting's texture? For the first, see "..\scripts\input.lua". It contains various functions to aid you in accessing user input.You can call them through the global TheInput table. For the second, I think you can just change inst.animname and call the animation again.inst.animname = "prock2"inst.AnimState:PlayAnimation(inst.animname) Edited February 4, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/50540-choosing-between-prefab-art-when-building-something/#findComment-609832 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