Jump to content

Script Compiles, Doesn't Work as Intended (noob)


CompGuyJMB

Recommended Posts

Thanks ThoraldGM, I had just assumed that the timer would cancel itself when the cell unloads. Thanks for the tip, I will have to add that!

 

Kitkat81, that is a much more straightforward way of doing things, and avoids the timer all together. I was worried about what kind of performance impact a timer would have. I definitely want to take a look at that. I looked around, have you found a source that explains what some of the different keywords mean / how to use them? Creation kit documentation is somewhat lacking, IMO.

I have not seen any lists like this so I guess it's just your logic+intuition+try and error. It's easier to find some working examples of what you need and check what keywords they use. The keyword I mentioned adds the workshop power icon to the object so you can see if it's powered or not. I copied it from some workshop lamp. This keyword will make your object powered when placed not far from any generator. No wires. If you want it to be wired , you might look into other objects that require to be wired. Then copy keywords and actor values related to power to your object.

 

For wired objects you additionally need to add one more keyword :WorkshopPowerConnection

And Actor Value : PowerRequired X (Replace X with power value your object should consume)

 

Unless you add a special CPA to the nif, the wire will go from the middle bottom point of the object ( zero ninode)

Edited by kitcat81
Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Glad to help! Note , if you your radio is not going to be a craftable object, the script I posted before is enough. But if you want the radio to be movable in workshop mode, you need to change the script. This is because OnPowerOff and On can fire while you are dragging the object away or closer to a generator. And the game dislikes some changes made while the object is grabbed. So in this case is should be something like this :

Bool  myStateOn

Event OnInit()
If !IsPowered()
    BlockActivation(true)
EndIf
EndEvent

Auto State Waiting
Event OnPowerOn(ObjectReference akPowerGenerator)
    BlockActivation(false)
    If myStateOn==true
        SetRadioOn(true)
    EndIf    
EndEvent

Event OnPowerOff()
    BlockActivation(true)
    if  IsRadioOn()
        SetRadioOn(false)
    EndIf
EndEvent

Event OnActivate(ObjectReference akActionRef)
If IsPowered()
    If IsRadioOn()==true
        myStateOn=true
    Else
        myStateOn=false
    EndIf
Else
    ; do my stuff (i.e. show a message that we need to be powered)
EndIf
EndEvent
EndState

Event onWorkshopObjectGrabbed(ObjectReference akReference)
    GoToState ("Paused")
EndEvent

State Paused  
Event onWorkshopObjectMoved(ObjectReference akReference)
    If   !IsPowered()
        BlockActivation()
        If myStateOn==true
            SetRadioOn(false)
        EndIf
    Else  
        If myStateOn == true
            SetRadioOn(true)
        EndIf                
        blockActivation(false)            
    EndIf
    GoToState("Waiting")
EndEvent
EndState
Link to comment
Share on other sites

 

OnPowerOff and On can fire while you are dragging the object away or closer to a generator.

 

Heh. Learn something new every day. I'm still trying to wrap my brain around "radio". We are talking about the little radios next to workbenches that play DCR or classical, right? And you are making them require power instead of the assumed batteries? Lol it's been a loooong week.

Link to comment
Share on other sites

Yes. I'm building a "bunker" behind the player home in Sanctuary. My premise is that he built this in anticipation of the war. He arrives home to find the place mostly untouched and a small stock of resources. Everything is dormant waiting on him to fire up the backup generator.

 

My goal was to have a script I could attach to multiple items (lights, the small radio, ham radio, tv etc) that would require this generator to be running. Otherwise, just some "emergency lights" would be on. It would be a player home, so I don't intend much to be moved around in workshop mode.

 

A lot of work for this small bit of immersion. But hey, it's a learning experience too!

Edited by CompGuyJMB
Link to comment
Share on other sites

 

 

OnPowerOff and On can fire while you are dragging the object away or closer to a generator.

 

Heh. Learn something new every day. I'm still trying to wrap my brain around "radio". We are talking about the little radios next to workbenches that play DCR or classical, right? And you are making them require power instead of the assumed batteries? Lol it's been a loooong week.

 

:) Yes. But you can make a huge radio too. This is more like immitating power dependence.

 

 

Yes. I'm building a "bunker" behind the player home in Sanctuary. My premise is that he built this in anticipation of the war. He arrives home to find the place mostly untouched and a small stock of resources. Everything is dormant waiting on him to fire up the backup generator.

 

My goal was to have a script I could attach to multiple items (lights, the small radio, ham radio, tv etc) that would require this generator to be running. Otherwise, just some "emergency lights" would be on. It would be a player home, so I don't intend much to be moved around in workshop mode.

 

A lot of work for this small bit of immersion. But hey, it's a learning experience too!

Got the idea. If your generator generates some power like a usual workshop generator, then I guess it should work fine with the radio. Lights don't work the same as radio. The script depends on the object original behavior that is defined inside the nif file and the type of the object. Obviously you can't use 'SetRadioOn' for lights. To create a universal script that would work for all objects more info is required. A list of all objects and nif files that should be powered. More info aboiut your generator. Is it supposed to be turned only once or should it be able to be turned on and off at any time etc.

Link to comment
Share on other sites

Hey kitkat81,

 

I tried replace my entire script with what you posted (non-craftable script), and added the WorkshopCanBePowered keyword, and I'm still failing the IsPowered() check when the generator is on. I tried placing a generator in game from the workshop right next to it, and it made no difference.

 

I've attached a photo of the Activator dialog box, in hopes I simply have something set wrong:

RadioEditBase.png

 

https://www.dropbox.com/s/uo5dp8vxt57itkn/RadioEditBase.png?dl=0

Edited by CompGuyJMB
Link to comment
Share on other sites

Hey kitkat81,

 

I tried replace my entire script with what you posted (non-craftable script), and added the WorkshopCanBePowered keyword, and I'm still failing the IsPowered() check when the generator is on. I tried placing a generator in game from the workshop right next to it, and it made no difference.

 

I've attached a photo of the Activator dialog box, in hopes I simply have something set wrong:

RadioEditBase.png

 

https://www.dropbox.com/s/uo5dp8vxt57itkn/RadioEditBase.png?dl=0

 

I'm a bit confused. What did you attach the script to? The image you posted doesn't show any scripts on it. So therefore activating it won't cause a power check. Also unless it has a script attached to handle the power changes just adding the keyword won't do anything to it either.

Link to comment
Share on other sites

The script is attached to the Reference box, under the Scripts tab. When you double-click the item in the Render Window, and scroll to the last tab. It's the box before you click the Edit Base button (which is the image shared above)

 

Photo below:

 

https://www.dropbox.com/s/i7vhquang5xxcjn/ReferenceBox.png?dl=0

ReferenceBox.png?dl=0

 

Is this the wrong location to attach the script?

Edited by CompGuyJMB
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...