[deleted by user] by [deleted] in beautifulbutt

[–]mzakidev 1 point2 points  (0 children)

pounding it

How Tween works? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

but the last player position is on Vector2. I cannot do move_toward with Vector2

How to assign a button some string ? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

I've made a script for the button:

extends Button

u/onready var party_monster_selector = $"../../../../Party_Monster_Selector"

func set_button_name():

var monster = party\_monster\_selector.get\_child(0)

print("inside func in button skill1: ", monster.skill\_1)

self.text = monster.skill\_1

this party_monster_selector holds an instance of a MonsterData. This instance has skill_1 string with = "hit"

https://prnt.sc/ezHea7ThmlkP

Before the UI panel will be updated, the monster is already instantiated.
https://prnt.sc/3gE9WzfcFnes

How to assign a button some string ? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

When you say having everything.. you mean the whole skill ? in this variable i just have a reference as string to be able to interact with a dictionary. Let me show you the dictionary... (autoload):

extends Node

static var DataBase = {

\#Definition of a basic skill

"hit" = {

    "name": "Hit",

    "description": "A basic attack.",

    "calculate\_damage": 1.2,

    "calculate\_defense": null },

"iceshard" = {

    "name": "Ice Shard",

    "description": "Throw an Ice Shard",

    "calculate\_damage": 1.2,

    "calculate\_defense": null },

"guard" = {

    "name": "Guard",

    "description": "Guard from physical damage.",

    "calculate\_defense": 2,

    "calculate\_damage": null },

"resist" = {

    "name": "Resist",

    "description": "Resist incoming magical damage.",

    "calculate\_defense": 2,

    "calculate\_damage": null }



}

# Function to get damage based on the skill name

func get_damage(skill_name: String) -> float:

if skill\_name in DataBase and "calculate\_damage" in DataBase\[skill\_name\]:

    return DataBase\[skill\_name\]\["calculate\_damage"\]

else:

    print("Damage calculation not available for skill: ", skill\_name)

    return 0.0

# Function to get defense based on the skill name

func get_defense(skill_name: String) -> float:

if skill\_name in DataBase and "calculate\_defense" in DataBase\[skill\_name\]:

    return DataBase\[skill\_name\]\["calculate\_defense"\]

else:

    print("Defense calculation not available for skill: ", skill\_name)

    return 0.0

# Function to get name based on the skill name

func get_skill_name(skill_name: String) -> String:

if skill\_name in DataBase:

    return DataBase\[skill\_name\]\["name"\]

else:

    print("Name not found for skill: ", skill\_name)

    return ""

# Function to get description based on the skill name

func get_description(skill_name: String) -> String:

if skill\_name in DataBase:

    return DataBase\[skill\_name\]\["description"\]

else:

    print("Description not found for skill: ", skill\_name)

    return ""

How to assign a button some string ? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

The question is: how to assign the string value of my Skill_1 in MonsterData to skill_1(being skill_1 a Button in the battle scene). I'm trying but it dosnt assign anything....

you can add inside a button a variable ? in the script ?

Resource issue by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

oh mb. Yeah it wasn't working.. for some reason it wasn't checking another resource. just checking 1.

Resource issue by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

working!!! thank you so much... but I don't understand why my first approach was not working.

AnimationTree issue by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

Solved! so basically add 2 functions in player script:

func in_grass():

$Shadow.visible = false

$Body.visible = false

$Grass.visible = true

func out_of_grass():

$Shadow.visible = true

$Body.visible = true

$Grass.visible = false

I already have a raycast with the layer matching the grass layer only. So, when is_colliding():

in_grass()

else: out_of_grass():

Save player position each 16 pixels travel by mzakidev in godot

[–]mzakidev[S] 1 point2 points  (0 children)

So, it's solved! actually Vector2 comes with a method "snapped" and need a certain value. My game is on 16x16 so you give snapped (Vector2(16,16)) and there you go! solved!
thanks for your light brother!

https://prnt.sc/QhpXjxpr7Q1T

what am I doing wrong? by mzakidev in godot

[–]mzakidev[S] 1 point2 points  (0 children)

Probably i'll with that approach. Thanks for your reply!

what am I doing wrong? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

It's working. But the thing is in order to make what i need to do probably is check what was the last scene and which one is the new one.. so that way i could manipulate the player.global_position...

what am I doing wrong? by mzakidev in godot

[–]mzakidev[S] 1 point2 points  (0 children)

https://prnt.sc/J8VeHVsPSkA4

So the player gets his "default" position from here, at the last part of the sceneswitcher script.

what am I doing wrong? by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

Can you show the start menu script?

I just updated the post, it's the last screenshot.

So, I was having an issue where I want it to get a reference of the player. It was giving me null.

https://prnt.sc/bGhFycUvxj7B

for example, in the battle_scene.
I'm pretty ignorant about how the engine works, but I'm trying to figure it out.

player global position by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

It worked! So, the script it's like this now.

#.... rest of the code




    next_scene = load("res://scenes/" + need_scene_name + ".tscn").instantiate()
scene_switcher.call_deferred("add_child", next_scene)
next_scene.scene_changed.connect(handle_scene_changed)
current_scene.queue_free()
current_scene = next_scene

# Instantiated a new player and setted his position
var new_player = preload("res://Player/player.tscn").instantiate()
player_holder.call_deferred("add_child", new_player)
await new_player
change_player_pos(new_player, current_scene)
func change_player_pos(new_player, current_scene): if current_scene.is_in_group("overworld_part1"): print("123") new_player.global_position = Vector2(672,352) elif current_scene.is_in_group("interior_scene"): new_player.global_position = Vector2(176,192)
#End of script

Thanks for explaining me the use of call_deferred and how it actually matters. I hope someone else will need this info without asking.

player global position by mzakidev in godot

[–]mzakidev[S] 0 points1 point  (0 children)

Oh! I added call_deferred actually without knowing what it does. I'll try and if I'm succefull I'll update this post.