Jump to content

Need help for multibutton switch


Recommended Posts

Hi all,



Don't really know how to set the good title so...



I wish to use multiple button in order to set an activator or another.



By now, i wish to learn with three button, so 8 possibilities.


I know how to use the "enable parents", but i do not know how to use the three button state in order to produce one result.



By exemple, with a specific selection, i wish to have a banner, with another selection : another banner



So 8 possibilities to 8 different banner.



Anybody could tell me how to do please ?


Link to comment
Share on other sites

Several ways you could do something like this

 

Have you considered one button that simply cycles? I will demonstrate that route. Up to preference if you want another route

 

While you cannot declare digits as states in the CK, in-game, you can go to a numeral-only state all day long

;=================================================================
Event OnInit()
  GotoState("0")
EndEvent
;=================================================================
Event OnActivate(ObjectReference akActionRef)
  Bool ProceedToChange = akActionRef.GetFormID() == 0x14; && AnyOtherCriteriaYouMayWant()
  If ProceedToChange
   Int CurrBanner = GetState() as Int
   Int NextBanner = CurrBanner + 1
   If NextBanner > 8
    NextBanner = 1
   EndIf
   GotoState(NextBanner as String)
   ; DoWhateverIsApplicableHere(NextBanner)
  EndIf
EndEvent
;=================================================================

As for refs themselves, this again, is preference and depends on what your goals are. You could have eight refs set as linked refs to the button ref. Or you could have one linked ref, which changes its look depending on the choice made. The way you change it can vary, and again is up to preference. I imagine a common route is to just enable the desired ref, and ensure all the others are disabled. EnableParent may or may not really be wanted or necessary here. Again, depends what you are doing

Link to comment
Share on other sites

Hi and thank you for your answer.

 

As i begin in script, i may not understand everything but i think your code will switch from banners on each use of a button isn't it ?

I mean at first use you get banner 1, second, banner 2 and so. with a reset when you get more than 8.

 

Does i understand well ?

 

 

Not sure to understand what does "ProceedToChange".

Maybe i did not clearly expose what i am working on. Sorry.

 

 

I am looking on a way to get that :

 

Three buttons : Button A, Button B, Button C

 

With the following A = activated and a = not activated

 

In my mind i think about :

 

a b C does enable Banner 1 (Banner or whatever activator to enable)

a B c does enable Banner 2

a B C does enable Banner 3

and so

 

Also, each time i enable one banner, i disable the other in order to have only one (or zero) banner enable at a time.

 

 

Do i explain better ?

Link to comment
Share on other sites

If I understand correctly, you want one button to choose a banner to display? This is how I would do it:

 

Int iBannerSelected = 0

;this is an array of you banners. Add banner ObjectReference's to it in the creation kit by clicking the properties tab for this script.
ObjectReference[] Property Banners Auto 

Event OnActivate(ObjectReference akActionRef)
    If akActionRef == Game.GetPlayer() ;did the player activate this? 
        int i = 0 
        int L = Banners.length 
        While i < L ;first, disable all banners
            Banners[i].disable()
            i += 1
        EndWhile
        
        iBannerSelected += 1 ;add 1 to iBannerSelected 
        If iBannerSelected >= L ;if iBannerSelected is greater than the max index of Banners array, set back to 0
            iBannerSelected = 0 
        Endif
        Banners[iBannerSelected].enable() ;enable next banner in the array list.
    Endif
EndEvent
Link to comment
Share on other sites

If I on the other hand understand this correctly, what the user wants is a kind of 'Puzzle Activator' where you have 3 activators / buttons and depending with which button or combination of buttons is activated the corresponding banner is enable.

If this is the case then one way to do it is by creating a 'Master Controller' that will be listening for those activators and their combinations.

* Which it's kind of a headache to create.... if the activators and the number of banners is big.

Edited by maxarturo
Link to comment
Share on other sites

Exactly Maxaturo.

 

I search how to enable an activator with a specific combination of three button.

Another activator with a different combination and so.

 

I know how to do for one button to one or more marker but i don't know how to do the inverse...

Link to comment
Share on other sites

You could set invisible activators above the buttons, making the player think to use buttons while its an inv.Activator. (create them and give them a button sound).

That way you can enable/disable these activators without the player recognizing. And whatever inv.Activator is enabled it can have different outcomes.

Link to comment
Share on other sites

Ok I think I understand now. I agree with Maxaturo, you should have a main controller script that sets the banners, and a button script on an activator. Something like this.

 

The script on your button activators:

Scriptname TM_ButtonScript extends ObjectReference 

Bool Property IsPressed Auto Hidden
TM_MainScript Property MainScript Auto ;your main contoller script

Event OnActivate(ObjectReference akActionRef)
    IsPressed = !IsPressed ;toggle IsPressed 
    ;also do something else here to show that the button is pressed or not visually
    MainScript.SetBanners()
EndEvent

Then your main script:

 

Scriptname TM_MainScript extends Quest

;In the CK, fill these properties with your button activators that have the TM_ButtonScript attached.
TM_ButtonScript Property Button1 Auto 
TM_ButtonScript Property Button2 Auto 
TM_ButtonScript Property Button3 Auto 

ObjectReference Property Banner0 Auto
ObjectReference Property Banner1 Auto
ObjectReference Property Banner2 Auto
ObjectReference Property Banner3 Auto
ObjectReference Property Banner4 Auto
ObjectReference Property Banner5 Auto
ObjectReference Property Banner6 Auto
ObjectReference Property Banner7 Auto

Function DisableAllBanners()
    Banner0.Disable()
    Banner1.Disable()
    Banner2.Disable()
    Banner3.Disable()
    Banner4.Disable()
    Banner5.Disable()
    Banner6.Disable()
    Banner7.Disable()
EndFunction

Function SetBanners()
    DisableAllBanners() ;disable all banners first
    
    If Button1.IsPressed && Button2.IsPressed && Button3.IsPressed
        Banner0.Enable() 
        
    Elseif Button1.IsPressed && Button2.IsPressed 
        Banner1.Enable() 
        
    Elseif Button1.IsPressed && Button3.IsPressed 
        Banner2.Enable() 
        ;ect....
    Endif
EndFunction
Link to comment
Share on other sites

Ok i understand the way you say it

 

So i set three Button with each his own script to emulate his on/off state.

And a last main Button with the main script which will enable/disable banners regarding of the buttons states.

 

Fine.

 

I did not know the IsPressed keyword before. Thank for the tips.

 

I will try it asap and come back here to tell the result.

 

Thank you all for your help and Time.

Link to comment
Share on other sites

The logic is pretty much what dylbill developed further above.
But, there is an issue with it, the "Main Script' needs some kind of timer where it will be listening only in that timer time for the buttons and their combination, otherwise it will always fire the first 'ElseIf' with only 1 of the buttons.
* Also 3 buttons = 6 possible combinations.
* I've a 'kind' of a similar idea on my last quest mod, an activator that it's listening for a 15-digit alphanumeric code and you have each time you enter a group of digits to choose from 9 different possibilities each time, if you choose wrong you get punished and it resets.
The only thing I can tell you is that: IT WAS A F****** PAIN IN THE A** TO MAKE IT WORK CORRECTLY!!!!, 15 digits with 9 possibilities each time... now do the math.... i ended up with a huge headache that lasted for weeks!!!
I was thinking something like this, but I haven't though of it all the way through, and bare with me one this one... I haven't sleep and I've a terrible headache that I can't even open my eyes or look at the monitor.
So here is a set up for this:
1) You first palce somwhere an 'xMarkerAcrivator' and in the 'Reference Editor ID' name it 'MyMasterController' and you add this script which plays the role of the 'Master Controller':
* Attention: the name of the script must be the same as bellow ( MyMasterControllerScript ), if you give the script another name then it should also change in the script further down, in the button script.
Scriptname MyMasterControllerScript extends ObjectReference
 
ObjectReference Property Banner1 Auto
ObjectReference Property Banner2 Auto
ObjectReference Property Banner3 Auto
ObjectReference Property Banner4 Auto
ObjectReference Property Banner5 Auto
ObjectReference Property Banner6 Auto
 
Bool Property ButtonA = Fasle Auto Hidden
Bool Property ButtonB = Fasle Auto Hidden
Bool Property ButtonC = Fasle Auto Hidden
 
 
Function CountButton01()
   If ( ButtonA == False )
        ButtonA = True
 Else
        ButtonA = False
EndIf
        Self.Activate(Self)
EndFunction
 
Function CountButton01()
   If ( ButtonB == False )
        ButtonB = True
 Else
        ButtonB = False
EndIf
        Self.Activate(Self)
EndFunction
 
Function CountButton01()
   If ( ButtonC == False )
        ButtonC= True
 Else
        ButtonC = False
EndIf
        Self.Activate(Self)
EndFunction
 
Function DisableAllBanners()
    Banner0.Disable()
    Banner1.Disable()
    Banner2.Disable()
    Banner3.Disable()
    Banner4.Disable()
    Banner5.Disable()
    Banner6.Disable()
EndFunction
 
AUTO STATE SEQ01
Event OnActivate(ObjectReference akActionRef)
         RegisterForSingleUpdate(5.0)
         GoToState("SEQ02")
         Self.Activate(Self)
EndEvent
ENDSTATE
 
STATE SEQ02
Event OnActivate(ObjectReference akActionRef)
            DisableAllBanners()
     If ( ButtonA == True ) && ( ButtonB == False ) && ( ButtonC == False )
             Banner1.Enable() 
 ElseIf ( ButtonA == False ) && ( ButtonB == True ) && ( ButtonC == False )
             Banner2.Enable() 
 ElseIf ( ButtonA == False ) && ( ButtonB == False ) && ( ButtonC == True )
             Banner3.Enable() 
 ElseIf ( ButtonA == True ) && ( ButtonB == True ) && ( ButtonC == False )
             Banner4.Enable() 
 ElseIf ( ButtonA == True ) && ( ButtonB == False ) && ( ButtonC == True )
             Banner5.Enable() 
 ElseIf ( ButtonA == False ) && ( ButtonB == True ) && ( ButtonC == True )
             Banner6.Enable() 
 EndIf
EndEvent
ENDSTATE
 
Event OnUpdate()
        GoToState("SEQ01")
EndEvent
2) And this one goes on the buttons.
* Attention you need to select for each button a different bool property ( isButton01 ), the first will be 'isButton01', the second 'isButton02', the third isButton03'.
ObjectReference Property MyMasterController Auto
Bool Property isButton01 = False Auto
Bool Property isButton02 = False Auto
Bool Property isButton03 = False Auto
 
Event OnActivate(ObjectReference akActionRef)
       If ( isButton01 == True )
              ( MyMasterController as MyMasterControllerScript ).CountButton01()
   ElseIf ( isButton02 == True )
              ( MyMasterController as MyMasterControllerScript ).CountButton02()
   ElseIf ( isButton03 == True )
              ( MyMasterController as MyMasterControllerScript ).CountButton03()
   EndIf
EndEvent
Maybe someone with a clearer head can develop this further or check it for any mistakes, sorry but my head is really killing me...

 

EDIT: Why every time i post a script is all F***** UP??!! and i need every time to edit it to get it in order!!. Does this thing happens to everybody or is just me??

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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