1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 unable to convert string " " to bool

Discussion in 'Programming' started by Elgarion, Mar 28, 2019.

  1. Elgarion

    Elgarion Member

    Joined:
    Apr 12, 2018
    Posts:
    62
    Hi everybody,

    I'm quite worried and I need your help... :(

    I just opened GMS2 this morning and discovered a strange mistake where everything ran fine yesterday, as soon as I launch my game. Same with all backups I made of my program : as soon as I launch one of them, I have this mistake. They all ran perfectly fine before :

    Code:
    ___________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of  Step Event0
    for object Obj_Player:
    
    unable to convert string " " to bool
     at gml_Script_Scr_IA_Agent_IA3 (line 22) -         if IAdv_debut_cycle && !IAdv_Action_type == "safe_place"
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Script_Scr_IA_Agent_IA3 (line 22)
    called from - gml_Object_Obj_Player_Step_0 (line 263) -               Scr_IA_Agent_IA3()
    Did it happen to someone before me? Is there a solution? Thank you so much in advance for your help !

    Edit : very strange ! Indeed, of course I had to write
    Code:
    if IAdv_debut_cycle && !IAdv_Action_type != "safe_place"
    - silly me! - but it worked perfectly before and suddenly it breaks the all thing. I'm going to correct this basic mistake, but does someone has a clue for this change of behaviour of GM?
     
    Last edited: Mar 28, 2019
  2. CloseRange

    CloseRange Member

    Joined:
    Jul 2, 2016
    Posts:
    903
    not sure why it worked before but try changing the line of code to this
    Code:
    if IAdv_debut_cycle && IAdv_Action_type != "safe_place"
    All I did was move the '!'
     
  3. dialgpalkia

    dialgpalkia Member

    Joined:
    Jan 2, 2019
    Posts:
    57
    Try some parentheses; && !(IAdv_Action_type == "safe_place") or what close said. It's the same idea.
     
  4. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,709
    This is caused by the type-casting consistency change in 2.2.2: https://forum.yoyogames.com/index.php?threads/gml-consistency-in-gms2-v2-2-2.59856/

    By the way, that should have never worked, even before the consistency change. !IAdv_Action_type would have been evaluated first to true or false, then compared to "safe_place" second. That check won't ever work out, at least not in the way you'd expect.

    2.2.2 is definitely starting to punish sloppy coders for their indiscretions, but bringing those bugs into the clear now is better than pandering to them forever.
     
  5. Elgarion

    Elgarion Member

    Joined:
    Apr 12, 2018
    Posts:
    62
    I totally agree with you, as I said in my edit it was a silly mistake (I have thousands lines of code now and sometimes -for me- it's difficult :) ).

    Thank you for explanations! (I get some strange behaviours in my AI, so I guess I made more mistakes elsewhere...)
     
  6. Elgarion

    Elgarion Member

    Joined:
    Apr 12, 2018
    Posts:
    62
    Thank you all for your kind answers. Silly me and silly mistake!
     
  7. Ax8472

    Ax8472 Member

    Joined:
    Jul 15, 2016
    Posts:
    76
    I don't suppose anyone could be find enough to help me with this, also? I get the same error code.

    Since the update, my game won't play sound when a new letter appears on the screen. I've checked the notes above but I simply can't figure out what I'm doing wrong (I'm just not smart enough to get it, unfortunately).

    Here's the code I use...

    Code:
            //------PLAY THE NOISE
            if !string_char_at(text[text_page],text_count) == " " && noisecool<=0 && text_page<=tmax
                {
                audio_play_sound(snd_textnoise,1,0)   
                noisecool=5
                }
    I removed the code and it all works fine, albeit without the noise.

    Any help much appreciated.
     
  8. Ax8472

    Ax8472 Member

    Joined:
    Jul 15, 2016
    Posts:
    76
    Got it! Changed it to
    if string_char_at(text[text_page],text_count) != " " && noisecool<=0 && text_page<=tmax

    Perfect! Thanks for those that looked anyway! ;)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice