Legacy GM [SOLVED] Developer Console issue (Icarus Tree, spawning item)

Dr_Nomz

Member
I really need a dev console to test things in my game, like entering specific commands that are returned and fed into a script to give a certain result.

I looked in the marketplace for a good one to use in GMS 1.4 and I found one that seemed promising, but I can't seem to get the most basic thing functioning, which is getting the value I need from what I typed.

Before I go further, here's the code I'm using:
https://marketplace.yoyogames.com/assets/1356/developer-console
http://gmc.yoyogames.com/index.php?s=05262c8b7b936271d972f73b0814bfe5&showuser=460509

Unfortunately I can't seem to reach him because his site no longer exists, and in turn neither does his email.
That's why I'm asking here, so if anyone knows how to contact him, let me know.

On to my problem though:
Code:
var c=argument0,n=argument1;

if !is_undefined(c[? "arguments"]) {
    var a = c[? "arguments"];
    if c[? "count"] >= n {
        if string_letters(a[n]) = "" {
            return real(a[n]);
        } else return a[n];
    }
}
This script is called "console_value" and the comment in it reads: "console_value(console,value[n])"
Basically it checks the value the console received to see what it was, and translates that into whatever the step event needs:
Code:
   if console_value_count(my_console) == 3 {
     var obj_1 = console_value(my_console,1);
     var xx = console_value(my_console,2);
     var yy = console_value(my_console,3);
   
     //if obj_1 == object4 var obj_777 = object4;
     //add object4 500 500
     //instance_create(xx,yy,object2);
     if is_real(xx) and is_real(yy){
      instance_create(xx,yy,obj_1);
     }
   }
So if I type "add object4 500 500" and the instance create has "object2" in place of that variable, it'll spawn the object no problem, and in whatever part of the room I want.

Funny thing is it does not seem to need the "is_real" function, since it seems to work perfectly fine even without it.

However, no matter how many different things I've tried to get the object spawned that I choose, it doesn't work. The only thing that makes it work is if I manually set it with "if obj_1 == object4 var obj_777 = object4;

The problem is that would be a huge waste of time to manually add every single object name this way, so that's what I'm here to ask:


How do I get it to spawn the object I want based on the name that's been entered? just typing out it's name based on the resource tree and having it spawn in the world is all I really need it to do.

Currently I'm only using basic "object2" and 3/4 names for now.


EDIT: Nevermind, my friend helped me out. Solution:
Code:
     var obj_1 = asset_get_index(console_value(my_console,1));
     var xx = console_value(my_console,2);
     var yy = console_value(my_console,3);
  
     if(obj_1 > -1){
It accesses the INDEX to find the object when setting the variable, based on what text was entered. However, if the var doesn't exist, it'll throw an error and crash the game. That's why you need the "if obj > -1" code, since it goes through the list to make sure it actually exists and if not, it doesn't run the code.
 
Last edited:
Top