# \[AGMaker に挑戦\] スクリプトの要約 - 変数とスイッチの表示

**URL:** https://guild.rpgmakerofficial.com/t/topic/174
**Category:** 一般
**Tags:** tutorial, english
**Created:** [2025 年 6 月 12 日午前 2:41 UTC](https://guild.rpgmakerofficial.com/t/topic/174 "2025-06-12T02:41:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Justus](https://sea2.discourse-cdn.com/flex002/user_avatar/guild.rpgmakerofficial.com/justus/32/55_2.png) [@Justus](https://guild.rpgmakerofficial.com/u/Justus)
#### Post date: [2025 年 6 月 12 日午前 2:41 UTC](https://guild.rpgmakerofficial.com/t/topic/174/1 "2025-06-12T02:41:44Z")

</div>

## スクリプト効果

`Label` ノードを作成し、毎フレーム特定の `GameObject` のすべての変数を `Label` ノードに出力します。  
注：ゲームオブジェクト `var v = prototype_player.velocity` の速度を出力する方法も併せて示します。

## 重要なポイント

1. このスクリプトは独立した `Control` ノードにアタッチする必要があります。
2. `prototype_player` へのパスは、ゲームオブジェクトの実際のノードに応じて変更する必要があります。
3. `variable_settings` は、実際の設定ノードの名前に指定する必要があります（一部のユーザーは事前にこの名前を変更している可能性があります）。

## コア

```python
extends Control

@onready var prototype_player: GameObject = $\"../..\"
@onready var variable_settings: VariableSettings = $\"../../VariableSettings\"
@export var label: Label

func _ready() -> void:
	if not label:
		print_rich(\"[color=red][b]please assign label![/b][/color]\")

func _process(_delta: float) -> void:
	if not label:
		return
	
	var v = prototype_player.velocity
	var new_text = \"\"
	new_text += \"velocity : %s\" % [v]
	new_text += \"\\n\"
	
	var all_variables = variable_settings.get_variables()
	for i:VariableData in all_variables:
		new_text += \"%s: %s \\n\" % [str(i._variable_name),str(i.get_value())]
		pass
	
	label.text = new_text

```
