How do I translate this:
"<NSLayoutConstraint:0x60000194c3c0 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x15bd7ecb0.bottom == _UIKBCompatInputView:0x1555f1750.top (active)>",
"<NSLayoutConstraint:0x6000019219a0 'assistantHeight' SystemInputAssistantView.height == 45 (active, names: SystemInputAssistantView:0x156314d60 )>",
"<NSLayoutConstraint:0x600001959770 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x1555f1750.top (active, names: SystemInputAssistantView:0x156314d60 )>",
"<NSLayoutConstraint:0x600001959950 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x15bd7ecb0]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x156314d60 )>"
into understandable information?
Related
I'm new to Godot programming, just to preface this. I'm trying to make it so that when you fall off of a platform without jumping you start accelerating downwards rather than just going down at a fixed speed. I almost have that, but my elif statement is happening every frame rather than the frame you leave the ground.
I've tried changing things, but I'm stuck at a logical dead end where any option I think of or find has resulted in the same or worse behavior.
extends KinematicBody2D
const UP_DIRECTION = Vector2.UP #up is up and down is down
# Declare member variables here.
var speed = 200 #speed of walk
var velocity = Vector2() #movement Vectors
var gravity = 1000 #gravity, it's real
var jump = 0 #jumping speed
var canjump = 0 #jumps left
var jumpcount = 1 #times you can jump
var nojump = false #did you fall or did you jump?
# Called every physics update.
func _physics_process(delta):
#jumping
if (canjump > 0 && Input.is_action_just_pressed("Jump") || is_on_floor() && canjump > 0 && Input.is_action_pressed("Jump")):
jump = -2000
canjump -= 1
nojump = false
#falling without jumping first
elif not (is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false):
jump = -gravity
canjump -= 1
nojump = false
#decelerating jumps
if (jump < 0):
jump += 45
#grounding jump variables
if(is_on_floor()):
canjump = jumpcount
nojump = true
#setting x and y
velocity.x = (Input.get_action_strength("Right") - Input.get_action_strength("Left")) * speed
velocity.y = gravity + jump
#using found inputs
velocity = move_and_slide(velocity, UP_DIRECTION)
pass
Here's my code, it tried commenting in the tdlr of what things are supposed to do. Again all I'm looking for is the reason why my elif statement is being applied every frame and how to fix that.
If you have a conditional that looks like this:
if condition:
prints("Something")
The execution flow would enter it when the condition is true.
Let us look at this as example:
if is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false:
prints("Something")
The above conditional requires three things:
is_on_floor() must be true.
Input.is_action_just_pressed("Jump") must be true.
nojump == false must be true. I mean, nojump must be false.
I think we can agree that does not happen all the time.
Now, if I negate the conditional:
if not condition:
prints("Something")
The execution flow would enter when the condition is false.
So, in a case like the one on your code:
if not (is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false):
prints("Something")
The conditional has one requirement:
not (is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false)`
Must be true. I mean:
is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false
Must be false. Double check D'Morgan's Law if you need to.
It is false when either:
is_on_floor() is false.
Or Input.is_action_just_pressed("Jump") is false.
Or nojump == false is false.
In other words, only one of these being false is sufficient.
To restate that. This condition:
not (is_on_floor() && Input.is_action_just_pressed("Jump") && nojump == false)`
Is equivalent to the following condition (by D'Morgan's law):
not is_on_floor() or not Input.is_action_just_pressed("Jump") or not nojump == false
By the way, using and and or is idiomatic in GDScript.
Wait, I can simplify that a bit:
not is_on_floor() or not Input.is_action_just_pressed("Jump") or nojump`
Thus, the execution flow will enter if either:
not is_on_floor() is true. I mean, if is_on_floor() is false.
not Input.is_action_just_pressed("Jump") is true. I mean, if Input.is_action_just_pressed("Jump") is false.
nojump is true.
And I reiterate that is either of them. Only one is sufficient. And I believe most of the time you haven't just pressed "Jump", also being on the air is enough. And I suspect nojump is false most of the time.
So, we can conclude that the execution flow will enter most of the time.
Write what you mean. You say in comments:
#falling without jumping first
Let us do that. What does falling mean? Does it mean on the air?
var falling := not is_on_floor()
Or do you also mean going down?
var falling := not is_on_floor() and velocity.dot(Vector2.DOWN) > 0.0
Alright, your pick. What does jumping first mean? Does it mean the player got in the air as a result of a jump? Ok... So you would do this when the player jumped:
jumped = true
Which I believe is this:
if canjump > 0 && Input.is_action_just_pressed("Jump"):
jumped = true
And reset it on the ground:
if is_on_floor():
jumped = false
Now we can say "falling without jumping first":
if falling and not jumped:
prints("something")
Almost as if it were the comment, but unlike the comment it can be executed.
Earlier today I was looking at https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/v2.77.0/main.tf to look deeper into how the VPC module for AWS works behind the scenes.
One thing that I am struggling with is the count conditional such as the one in the aws_internet_gateway resource.
Can someone explain and translate what the count defined in this resource is actually doing? It's very confusing to me at the moment.
resource "aws_internet_gateway" "this" {
count = var.create_vpc && var.create_igw && length(var.public_subnets) > 0 ? 1 : 0
vpc_id = local.vpc_id
tags = merge(
{
"Name" = format("%s", var.name)
},
var.tags,
var.igw_tags,
)
}
It uses ternary operation in the general form of:
CONDITION ? TRUEVAL : FALSEVAL
In the module, the
CONDITION is var.create_vpc && var.create_igw && length(var.public_subnets) > 0
TRUEVAL is 1
FALSEVAL is 0
This translates to the following: If both create_vpc and create_igw are true as well as public_subnets has been defined, then count will be 1 (TRUEVAL) and exactly one aws_internet_gateway.this will be created.
In contrast if the CONDITION is not satisfied, count will be 0 (FALSEVAL) and no aws_internet_gateway.this will be created.
In general, it is a common pattern to conditionally create resources in terraform:
resource "type" "name" {
count = CONDITION : 1 ? 0
}
I am trying to do an if statement to test whether the variable m is equal to game1 or game2 and if it is show it as a two move game and if its game3 or game4 show it as a one move game.
game1 = Image[]
game2 = Image[]
game3 = Image[]
game4 = Image[]
The above 4 variables are assigned to 4 different images.
m := RandomChoice[{game1, game2, game3, game4}];
If[m === game1 || game2 , InputString["This is a two move game"],
InputString["This is a one move game"]]
This is totally failing. the 4 game variables are assigned to images and we need to show the image and have a input box pop up
This is another alternative I came up with that also failed.
m := RandomChoice[{game1, game2, game3, game4}];
If[m == game1 || game2 , InputString["This is a two move game"]];
If[m == game3 || game4 , InputString["This is a one move game"]]
Any help would be much appreciated.
You can't use this syntax: m === game1 || game2
For example instead of 1 == 2 || 3 you should use 1 == 2 || 1 == 3
However, you are using m multiple times, and each time it is used it will change. So you need to fix m, e.g.
m := RandomChoice[{game1, game2, game3, game4}];
a = m;
If[a == game1 || a == game2 , InputString["This is a two move game"]];
If[a == game3 || a == game4 , InputString["This is a one move game"]]
moves01 = Thread[{game3, game4} -> "one move game"]
moves02 = Thread[{game1, game2} -> "two move game"]
moves = Association#Catenate[{moves01, moves02}]
m := RandomChoice[{game1, game2, game3, game4}];
moves[m]
I use boost log and want to define a composed filter. I use boost::log::init_from_streamto read the configuration from a stream. Filtering on single conditions works fine. I can do
Filter = "%Channel% = A"
to get only log entries from channel A. I can do
Filter = "%Severity% >= warn"
to get only log entries that have a severity which is warning or above.
Here comes the question: I want to do someting like
Filter = " (%Channel% = A AND %Severity% >= warn)
OR (%Channel% = B AND %Severity% >= info)"
I was not able to find any documentation regarding such a combination of filters. Is there a way to do this when using boost::log::init_from_stream?
I've found this documentation page which documents the grammar:
Filter and formatter parsers
filter:
condition { op condition }
op:
&
and
|
or
condition:
!condition
not condition
(filter)
%attribute_name%
%attribute_name% relation operand
relation:
>
<
=
!=
>=
<=
begins_with
ends_with
contains
matches
Using this, the example given in the question can be expressed as follows:
Filter = "(%Channel% = A & %Severity% >= warn) | (%Channel% = B & %Severity% >= info)"
I am using this statement
if ((pm && pn) || (pm == false && pn == false))
it is supposed to return true only if both pm and pn are true or if both are false. But this is also returning true if only only first one (pm) is true.
So now it is acting like this:
0 0 = 1
0 1 = 0
1 0 = 1
1 1 = 1
but I need it to work like this:
0 0 = 1
0 1 = 0
1 0 = 0
1 1 = 1
can you tell me where am I making mistake?
What you want is simply:
if (pm == pn)
You are checking if pm is true twice. You also need to check if both are the same, not whether they are both true. So,
if ((pm == pn)
^^ ^^
pm && pm
should be
pm && pn
^
The whole expression can be simplified to
pm == pn
if the variables already have bool type.
Why not try xor?
if (!(pm ^ pn)) { /*...*/ }
Or simply equal?
if (pm == pn) { /*...*/ }
if ((pm && pm) || (pm == false && pn == false))
it is supposed to return true only if both pm and pn are true or if both are false. But this is also returning true if only only first one (pm) is true.
Because you made a typo. You meant pm && pn.
Instead just write if (pm == pn), which is equivalent along as the only semantic values are indeed true and false for both variables.
Plus, consider making your variable names clearer and more distinct.
Note that operator precedence has nothing to do with this.
Since the question's title asks about precedence, note that || has lower precedence than &&. So the two sets of inner parentheses are redundant, and the original expression is just a longer way of saying
if (pm && pm || pm == false && pn == false)
Now, fixing the obvious typo:
if (pm && pn || pm == false && pn == false)
Removing the unneeded explicit comparisons:
if (pm && pn || !pm && !pn)
And, finally, a less obvious transformation, which others have suggested:
if (pm == pn)