GM:S 1.4 (SOLVED) ds_queue containing script always returning wrong value

Discussion in 'Legacy GameMaker Community Tech Support' started by gray007nl, Jan 8, 2019.

  1. gray007nl

    gray007nl Member

    Joined:
    May 25, 2017
    Posts:
    9
    So I read on the help page that ds_queue's can contain scripts, so I decided to test it out. I put a laughably simple script of
    name = "hello";
    return name;​
    into the queue, but when I dequeue it onto a different valuable and print it as text, it for some reason prints 10? (as in the number, not 10 times). Even when I change the script so it should theoretically return a number rather than a string it returns 10.

    global.test = ds_queue_dequeue(queue_testy);​
    ^ how I attempt to use the script from the queue, nothing else should affect the global.test value outside of it being set once when the game boots (and even then it's set to 7 not 10)
     
  2. gray007nl

    gray007nl Member

    Joined:
    May 25, 2017
    Posts:
    9
    Whoops, figured it out on my own, turns out I'm dumb and didn't put () behind the script when I put in the queue, still confused as to why it was giving me a value of 10 rather than an error.
     
  3. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,088
    Is your script in the 11th place of your script resources?

    Well, doesn't really matter. I'm pretty sure what's happening is that the script does not get executed but the number (scripts are numbered from 0 onward) gets returned instead.
    To fix this, I think you have to add the brackets on the script like this
    Code:
    global.test = ds_queue_dequeue(queue_testy());
    
     
  4. gray007nl

    gray007nl Member

    Joined:
    May 25, 2017
    Posts:
    9
    Thanks Simon, didn't know scripts are treated as a number if you don't execute them properly, neat.
     

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