• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM (SOLVED) ds_queue containing script always returning wrong value

G

gray007nl

Guest
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)
 
G

gray007nl

Guest
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.
 

Simon Gust

Member
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)
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());
 
G

gray007nl

Guest
Thanks Simon, didn't know scripts are treated as a number if you don't execute them properly, neat.
 
Top