set custom function true or false how to do it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thoma

Hi, I have two function one it reload and another it shoot but thing is I do not know how I can set my reload function false when the player do the function shoot. I try few thing but it did not work and I am stuck whit a player can soot and reload at the same time
here the code:

shoot:

func shoot():
if ammo !=0:
		ammo-=1
		emit_signal("ammo_changed",ammo *150/max_ammo)

		
		can_shoot = false
		$timer.start()
	
		$Player/anime.play("shoot")
		yield($Player/anime,"animation_finished")
		$Player/pewpewpew.play()
		var pew = pewSCN.instance()
		get_parent().add_child(pew)
	
		pew.position =$Player/Position2D.global_position
		pew.rotation = $Player/Position2D.global_rotation

function reload:

func reload_true():
ammo=max_ammo

and my Input use this two function:

func _physics_process(delta):
if Input.is_action_just_pressed("reload"):
	reload_true()#set the shoot function false
	emit_signal("ammo_changed",ammo *150/max_ammo)
if (Input.is_action_just_pressed("shoot")&&can_shoot):
	shoot()#set the reload function false

Thank for helping me :slight_smile:

:bust_in_silhouette: Reply From: Turnovus

In _physics_process, replace the second if with elif. elifis a combination of the operators if and else. Because of this, if the first if is false, then it will check if the player is pressing the shoot button. However, if the first if is true, then it won’t check at all.