Jump to content

Trying to combine a Build-Furniture-Script and a color-changing Script - Ideas?


Recommended Posts

Posted
 
I'm trying to give players the option to build a piece of furniture, and then, once it is built, give the ability to swap out the mesh for an alternative.
 
This is the build-furniture-script I am using, taken from Darkfox127:
 
*************************************
Scriptname JasperSimpleBuildHomeAndColor extends ObjectReference
 
ObjectReference Property CompletedArchitecture Auto
 
ObjectReference Property ColorSwitcher Auto
 
Message Property BuildMessage Auto
 
GlobalVariable Property GameHour Auto
 
Float Property Time Auto
 
MiscObject Property CraftItem Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
 
Game.FadeOutGame(false, true, 2.0, 3.0)
 
GameHour.SetValue(GameHour.GetValue()+Time)
 
CompletedArchitecture.enable()
 
ColorSwitcher.enable()
 
BuildMessage.show()
 
Game.GetPlayer().RemoveItem(CraftItem,1,True)
 
EndEvent
 
***************************************
 
"ColorSwitcher.enable()" refers to a second trigger-script, that simply enables one mesh and disables another, and vice-versa. It looks like this:
 
***************************************
 
Scriptname JasperSwitchStatic extends ObjectReference
 
ObjectReference Property Static1DISABLED Auto
 
ObjectReference Property Static2SHOWING Auto
 
Event OnActivate (ObjectReference akActionRef)
if (Static1DISABLED.IsDisabled())
Static1DISABLED.Enable()
Static2SHOWING.Disable()
elseif (Static2SHOWING.IsDisabled())
Static2SHOWING.Enable()
Static1DISABLED.Disable()
Endif
Endevent
*******************************************
 
This combination works well, up to a point. When the bed is built, it enables the "original" version of the bed, and the color-switcher. I can now hit the color switch, and swap between the original model and the alternative.
The problem is that the recipe for the bed has a Match Condition (as per the instructions from DarkFox) that appears only if the original model is disabled. Hitting the color-switcher will make the original bed disabled, so the recipe for "build a bed" shows up again at the workbench. If it is built a second time, both versions of the bed are now visible.
 
So, as you can see, it kinda turns into a "neverending loop" when I only need it to fire once. The "build furniture" script appears to spawn new versions of the mesh, rather than just enable/disable it. 
 
What I am trying to do is find a way for the recipe to only be active once, and then remove itself completely. Once the bed is built, the color-switcher is enabled, and the recipe is no longer visible on the workbench.
 
If you have an idea how to accomplish this using a modification of this script, or if you have an alternative solution altogether, please tell me.
 
The in-depth explanation of "build-a-house-script" is here, so you can see the fine details.
 
 
Feel free to ask any questions. I'm learning the scripting part on my own, so some of this might look a little unorthodox or cobbled together. I don't have a ton of experience in this realm. There are probably better ways of accomplishing this, like having both the build-recipe AND the switch-color function all contained neatly at the workbench.
 
My way of doing it is disguising the switch-color trigger with a sack or something, and naming it "Change bed textiles", for example, and placing it near the bed. I used to have one master lever to change all the pillows, beds, armors, scarfs in a house, but since the build script AND the color script both uses x-markers for enable parent, there is a conflict. So if I have a section with lots of different meshes, who all need to change color, I have to make them into one, single mesh. 
 
Not very elegant, but what can you do. 
 
Cheers!

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...