Major - `Switch_Device` Turn On/Off functions don't do anything

Explain the issue: Switch_Device Turn On/Off functions don’t do anything
Evidence:

If replicable, how:

  1. Setup verse script with an editable Switch_Device
  2. Attempt to Turn On/Off the switch (also happens with the delay game start fix)

What’s the severity on this one, @RayBenefield?

Sorry, updated the title. I was going to put Normal, but honestly Switch is a pretty essential device so I decided on Major instead.

Thank you!

Hello, did you find a fix to this?

I am trying to do something similar, was about to create a post but then I saw you had the same issue

My code is:

    @editable
    BuyButton1:button_device = button_device{} 
    @editable
    BuyButton2:button_device = button_device{}
    @editable
    BuyButton3:button_device = button_device{} 

    @editable
    SwitchWall1:switch_device = switch_device{}
    @editable
    SwitchWall2:switch_device = switch_device{}
    @editable
    SwitchWall3:switch_device = switch_device{}

        Button1.InteractedWithEvent.Subscribe(ActivateWall1) 
        Button2.InteractedWithEvent.Subscribe(ActivateWall2) 
        Button3.InteractedWithEvent.Subscribe(ActivateWall3) 

    ActivateWall1(Player:player):void=
        Logger.Print("F: ActivateWall1 activated!")

        SwitchWall1.TurnOn
        SwitchWall2.TurnOff
        SwitchWall3.TurnOff

    ActivateWall2(Player:player):void=
        Logger.Print("F: ActivateWall2 activated!")

        SwitchWall1.TurnOff
        SwitchWall2.TurnOn
        SwitchWall3.TurnOff

    ActivateWall3(Player:player):void=
        Logger.Print("F: ActivateWall3 activated!")

        SwitchWall1.TurnOff
        SwitchWall2.TurnOff
        SwitchWall3.TurnOn

I notice you have () after TurnOn - when I do this I get errors, but it does not work either way :person_shrugging:
Any advice appreciated :slight_smile:

Hi @KyleDev !

I’ll chase this up today, but I’m pretty certain this should be working.

WRT the errors with the posted verse snippet - I expect the problem you are hitting is that the TurnOn/TurnOff functions require a missing instigating player parameter:

So likely requires:

ActivateWall1(Player:player):void=
Logger.Print(“F: ActivateWall1 activated!”)

    SwitchWall1.TurnOn(Player)
    SwitchWall2.TurnOff(Player)
    SwitchWall3.TurnOff(Player)

ActivateWall2(Player:player):void=
    Logger.Print("F: ActivateWall2 activated!")

    SwitchWall1.TurnOff(Player)
    SwitchWall2.TurnOn(Player)
    SwitchWall3.TurnOff(Player)

ActivateWall3(Player:player):void=
    Logger.Print("F: ActivateWall3 activated!")

    SwitchWall1.TurnOff(Player)
    SwitchWall2.TurnOff(Player)
    SwitchWall3.TurnOn(Player)
1 Like

Thank you! I initially made the mistake of trying…

SwitchWall1.TurnOn(Player.player)

… as the API says:

 TurnOn<public>(Player:player):void = external {}

:slight_smile:

Ah - Yes that makes sense, I can see the confuslon!

The part after the ‘:’ player (lowercase ‘p’) is the variable type, the prefix is the variable name as used internally by that function (‘Player’ upper case P).

The variable name is somewhat redundant information in this case of course, but in others the name can often give additional information/context on how it’s expected to be used where perhaps the type is some common type used in varying ways e.g.

SomeFunction<public>(AttackingPlayer:player) = external {} 
SomeFunction<public>(VictimPlayer:player) = external {}

When you are invoking the function from your calling code, provided you provide any instance that matches the required type, it should compile.

Glad its up and running now!

1 Like