forked from interstellar_development/freettrpg
Implemented Character creator
This commit is contained in:
parent
4224f4f755
commit
0ca7c9ac13
2 changed files with 47 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://b6t6yd7qnid1i"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b6t6yd7qnid1i"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/createStats.gd" id="1_xsj3b"]
|
||||
|
||||
[node name="character_creator" type="Control"]
|
||||
layout_mode = 3
|
||||
|
@ -7,3 +9,37 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_xsj3b")
|
||||
|
||||
[node name="input_name" type="TextEdit" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 16.0
|
||||
offset_top = 16.0
|
||||
offset_right = 272.0
|
||||
offset_bottom = 56.0
|
||||
placeholder_text = "Name"
|
||||
|
||||
[node name="input_hp" type="TextEdit" parent="."]
|
||||
offset_left = 16.0
|
||||
offset_top = 72.0
|
||||
offset_right = 272.0
|
||||
offset_bottom = 112.0
|
||||
placeholder_text = "HP"
|
||||
|
||||
[node name="input_level" type="TextEdit" parent="."]
|
||||
offset_left = 16.0
|
||||
offset_top = 128.0
|
||||
offset_right = 272.0
|
||||
offset_bottom = 168.0
|
||||
placeholder_text = "Level"
|
||||
|
||||
[node name="button" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 512.0
|
||||
offset_top = 400.0
|
||||
offset_right = 638.0
|
||||
offset_bottom = 435.0
|
||||
scale = Vector2(2, 2)
|
||||
text = "Send"
|
||||
|
||||
[connection signal="pressed" from="button" to="." method="_on_button_pressed"]
|
||||
|
|
|
@ -4,7 +4,9 @@ var save_path = "user://player_data.json"
|
|||
|
||||
func saveJSON():
|
||||
var data := {
|
||||
"name": "test",
|
||||
"name": $input_name.text,
|
||||
"hp": $input_hp.text,
|
||||
"level": $input_level.text
|
||||
}
|
||||
|
||||
var json_string = JSON.stringify(data)
|
||||
|
@ -31,8 +33,13 @@ func loadJSON():
|
|||
return
|
||||
|
||||
var data:Dictionary = json.data
|
||||
var test = data.get("name")
|
||||
var charName = data.get("name")
|
||||
var charHP = data.get("hp")
|
||||
var charLevel = data.get("level")
|
||||
print(charName)
|
||||
print(charHP)
|
||||
print(charLevel)
|
||||
|
||||
func _on_pressed():
|
||||
func _on_button_pressed():
|
||||
saveJSON()
|
||||
loadJSON()
|
||||
|
|
Loading…
Reference in a new issue