0 votes

I'm rigging the clock to display the number textures on the scoreboard and basket models

          var score_clock_texture := 
        {
            var 1 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_1.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_1.png"),
            var 2 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_2.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_2.png"),
            var 3 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_3.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_3.png"),
            var 4 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_4.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_4.png"),
            var 5 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_5.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_5.png"),
            var 6 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_6.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_6.png"),
            var 7 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_7.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_7.png"),
            var 8 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_8.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_8.png"),
            var 9 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_9.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_9.png"),
            var 0 = basketball_goal_gameclock = preload("res://Textures/Basketball/Basketball Goal/game_clock_number_0.png") : scoreboard = preload("res://Textures/Basketball/Scoreboard/digit_0.png")
        }

func _ready() -> void:
    timer.connect("_on_Timer_timeout", label, "toggle_visibility")

    game_clock = minutes = 12
    shot_clock = seconds = 24

        func _format_seconds(time : float, use_milliseconds : bool) -> String:
        var minutes := time / 60
        var seconds := fmod(time, 60)
        if not use_milliseconds:
            return "%02d:%02d" % [minutes, seconds]
        var milliseconds := fmod(time, 1) * 100

        if minutes:
            $sports_arena/basketball_goal.get_mesh().get_surface_material(1).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal.get_mesh().get_surface_material(2).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal2.get_mesh().get_surface_material(1).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal2.get_mesh().get_surface_material(2).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/scoreboard.get_mesh().get_surface_material(8).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/scoreboard.get_mesh().get_surface_material(9).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
        if seconds:
            $sports_arena/basketball_goal.get_mesh().get_surface_material(4).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal.get_mesh().get_surface_material(5).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal2.get_mesh().get_surface_material(4).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/basketball_goal2.get_mesh().get_surface_material(5).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/scoreboard.get_mesh().get_surface_material(10).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)
            $sports_arena/scoreboard.get_mesh().get_surface_material(11).set_texture(SpatialMaterial.TEXTURE_ALBEDO, texture)


        return "%02d:%02d:%02d" % [minutes, seconds, milliseconds]




    func _on_Timer_timeout() -> void:
        emit_signal("counted_down", _count)
        _count -= 1
        if _count < 0:
            stop()
        pass # Replace with function body.

but I got this error on the scoreclocktexture
Parse Error: Error parsing expression, misplaced: '\n'

whats causing the error?

Godot version 3.4
in Engine by (55 points)

Lots of problems here.
As timothybrentwood said a variable name cannot begin with a number var 1 =
Before you even get there, gdscript is not going to let you break the line up as you have:

 var score_clock_texture := 
        {  

The line continuation character for gdscript is \:

 var score_clock_texture :=  \
        {

This code is defining a dictionary.
When you are defining a dictionaries data you can omit the line continuation character as so:

var d = \
    {
        "my key":10}

A dictionary contains keys and their associated values.
A dictionary does not contain variable definitions so var 1 = or var anything = can never be inside a dictionary.
These errors are basic programming fundamentals and as such I recommend that you take some gdscript tutorials before you go any further.

1 Answer

+1 vote

var 1 - I don't think you're allowed to name your variables with leading numbers.

by (3,882 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.