+2 votes

Hello there. I'm trying to do the in-game menu for different settings, and one of them is using the vsync.
It works perfectly in the editor, but when I try to run the builded binary, at least on linux, I get the following errors in the console:

SCRIPT ERROR: _ready: Invalid call. Nonexistent function 'is_vsync_enabled' in base 'Object'.
   At: <built-in>:6.
SCRIPT ERROR: save_config: Invalid call. Nonexistent function 'is_vsync_enabled' in base 'Object'.
   At: <built-in>:19.

And 'cause of this, the game fails to save the stuff :<
Is this works how it's intented to work, or did I miss something.
The code for the scripts is:

extends Button

onready var anim = get_parent().get_node( "anim" );
onready var vsync = OS.is_vsync_enabled();

func _ready():

func update_text():
    if( vsync ):
        set_text( "VSync [X]" );
        set_text( "VSync [ ]" );

func _on_vsync_pressed():
    music.sfx_play( "hit5" );
    vsync = !vsync;
    OS.set_use_vsync( vsync );

func _on_vsync_focus_enter():
    music.sfx_play( "hit1" );


extends Button

onready var anim = get_parent().get_node( "anim" );
var timeout = 1.0;

func _ready():

func _fixed_process( delta ):
    timeout -= delta;
    if( timeout <= 0 ):
        get_tree().change_scene( "res://menu/menu.tscn" );
        set_fixed_process( false );

func save_config():
    var config = ConfigFile.new()
    config.set_value( "video", "fullscreen", OS.is_window_fullscreen() );
    config.set_value( "video", "vsync", OS.is_vsync_enabled() );
    config.set_value( "audio", "sound_volume", AudioServer.get_fx_global_volume_scale() );
    config.set_value( "audio", "music_volume", AudioServer.get_stream_global_volume_scale() );
    config.save( "user://settings.cfg" )

func _on_back_pressed():
    music.sfx_play( "hit5" );
    anim.play( "end" );
    set_fixed_process( true );

func _on_back_focus_enter():
    music.sfx_play( "hit1" );

UPD: also, the At: <built-in>:6. is actually line 4, I just have two empty lines in the beginning of that script, if it has some importance or something

in Engine by (25 points)
edited by

Please log in or register to answer this question.

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.