Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
2
Indexable
Never
extends Node2D

var current_question
var client_id = multiplayer.get_unique_id()


func _on_button_1_pressed():
	$Button1.modulate = Color.YELLOW
	rpc_id(1, "player_send_answer", $Button1.text)

func _on_button_2_pressed():
	$Button2.modulate = Color.YELLOW
	rpc_id(1, "player_send_answer", $Button2.text)

func _on_button_3_pressed():
	$Button3.modulate = Color.YELLOW
	rpc_id(1, "player_send_answer", $Button3.text)

func _on_button_4_pressed():
	$Button4.modulate = Color.YELLOW
	rpc_id(1, "player_send_answer", $Button4.text)



@rpc("any_peer")
func show_answer(correct_answer):
	for i in range(4):
		var button = get_node("Button" + str(i + 1))
		if button.text == correct_answer:
			button.modulate = Color.GREEN
	


@rpc("any_peer")
func import_question(question, answers):
	var current_question = question
	rpc_id(1, "player_got_question", client_id)
	

@rpc("any_peer")
func show_question():
	$Button1.modulate = Color.WHITE
	$Button2.modulate = Color.WHITE
	$Button3.modulate = Color.WHITE
	$Button4.modulate = Color.WHITE
	$QuestionLabel.text = current_question["question"]
	$Button1.text = current_question["answers"][0]
	$Button2.text = current_question["answers"][1]
	$Button3.text = current_question["answers"][2]
	$Button4.text = current_question["answers"][3]
	


@rpc("any_peer")
func player_got_question(client_id):
	pass
	

@rpc("any_peer")
func player_send_answer(answer):
	pass


Leave a Comment