Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[XP] Putting conditional branch "Button x being pressed?" on manually?

Do you know where (in the scripts) the part is that controls the conditional branch "if Button x is being pressed"? Because I'm using Pathfinding, and have edited it so that a variable is on if the character is moving in a certain direction through the Pathfinding. But conditional branch events for e.g. "if Down is being pressed" wouldn't work then, if the player walks down over it. So I'm looking to edit the conditional branch to include "or $variable == true".

Thank you!
 
you'd probably be looking at "if Input.press?(Input::button)"
where button is DOWN,LEFT,RIGHT,UP,A,B,C,X,Y,Z,L,R,SHIFT,ALT,CTRL,F5,F6,F7,F8 or F9
hope that helps(custom input modules often have more keys if you're using one)
also, you don't actually have to write "or $variable == true" just "if $variable" will do the same thing, and "if !$variable" is the same as "if $variable == false"
just in case you didn't know :P
 
@Beran: Hmm, nope. I found that, but it's for movement only. Like, "if input blabla left" then move left. Can you edit conditional branches? Or is that not even possible?

@Wyatt: Hmm, that wouldn't work. Because it's for movement like ladders and moving around round balconies. So then the player would just keep moving and moving. : >
 
You want to have 'or $variable' in the conditional branch. Well, this is possible, though to prevent it from running in every single branch, you're gonna have to make a switch that turns it on.

In Interpreter 3, you will find (starting at line 267):
Code:
    # If determinant results are true
    if @branch[@list[@index].indent] == true
      # Delete branch data
      @branch.delete(@list[@index].indent)
      # Continue
      return true
    end
Replace this entirely with:
Code:
    # If determinant results are true
    if $game_switches[1]
      if @branch[@list[@index].indent] == true or $variable
        # Delete branch data
        @branch.delete(@list[@index].indent)
        # Continue
        return true
      end
    else
      if @branch[@list[@index].indent] == true
        # Delete branch data
        @branch.delete(@list[@index].indent)
        # Continue
        return true
      end
    end
This should work, though to enable the 'or $variable' handler, you must turn switch 1 ON. You can change the switch number to whatever you prefer.

Just a side note:
Can you edit conditional branches? Or is that not even possible?
Under command_111 in the Interpreter class, you can edit everything for conditional branches, but not the editor's choices and values. Also note that finding out what each parameter does is useful before messing with it.

Hope this helps.
 
I think I misunderstood your request lol. To include variables that aren't numbers in conditional branches you can just use a script and make it
Code:
$game_variables[var number]
or
!$game_variables[var number]
as for or, you can use "||" that symbol
i.e.
Code:
some code || $game_variables[1]
 
@FireRaven: Hmm, well, having to turn on a switch before the conditional branches kind of takes away my original intention, which is avoid having to add more things for each conditional branch. Like, I could make two conditional branches and in the 2nd do a script like "$game_variables[1] == true", but as I do this a LOT it would save me a great deal of time if I could just edit it in. But thanks for pointing out where the Interpreter for conditional branches is! ^^ I'll take a look at it.

@Beran: I think you misunderstood my request again. ^^; But FireRaven already pointed out to me where I can find the conditional branch interpreter..

I found this:

    when 11  # button
      result = (Input.press?(@parameters[1]))

Now I have to change this. I want to make it, so that it checks if certain variables are true, let's say, $a, $b, $c and $e. If $a is true, it changes @parameters[1] into what it is for if the Down button is pressed. $b for left, $c for right and $e for up.

So basically what I have to know and hopefully you know, is what @parameters[1] is for if the Left / Right / Down / Up button is pressed. Is it a number (2 / 4 / 6 / 8) or a word like "LEFT"?

Thanks again!! :)
 
The left, right, down and up from the Input module are constants. This is:

Down = 2
Left = 4
Right = 6
Up = 8

This means even if it's written as a word, the actual value you will see when printing etc. is the value, a number. Providing either results in the same.

Now this might be different in the branch, so basically, what you would want to do, is to make an event using a branch with these conditions. Right after this 'result = (Input.press?(@parameters[1]))', insert:
Code:
print "Button to be pressed: " + @parameters[1].to_s
This is going to allow you to check the actual values, then work with them afterwards.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top