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

GM:S 1.4 Can you unstring()?

Discussion in 'Programming' started by feminist52, Aug 24, 2017.

  1. feminist52

    feminist52 Member

    Joined:
    Jun 24, 2017
    Posts:
    44
    Is it possible to unstring a string variable? I am making a list of 3D array variables. For example:

    Code:
    ///array list
    MaxStuff[room_Russia1]=4 //number of files to load
    //type of asset
    File[room_Russia1,-1,1]="bg"
    File[room_Russia1,-1,2]="bg"
    File[room_Russia1,-1,3]="bg"
    File[room_Russia1,-1,4]="bg"
    //name of variable
    File[room_Russia1,0,1]="global.LOAD_bg_Russia1_1"
    File[room_Russia1,0,2]="global.LOAD_bg_Russia1_2"
    File[room_Russia1,0,3]="global.LOAD_bg_Russia1_3"
    File[room_Russia1,0,4]="global.LOAD_bg_Russia1_final"
    //name of file in Included Files
    File[room_Russia1,1,1]="image.jpg"
    File[room_Russia1,1,2]="image2.jpg"
    File[room_Russia1,1,3]="image3.jpg"
    File[room_Russia1,1,4]="imagefinal.jpg"
    
    
    
    ///loading code
    level=room
    
    stuff=0
    repeat MaxStuff[level]
        {
        stuff+=1
        File[room_Russia1,stuff]
      
      
        prefix=File[level,-1,1]
      
      
      
        if prefix="spr"
        {var t_spr = sprite_add(File[level,1,stuff], 0, 0, 0, 0, 0)
        sprite_assign(File[level,0,stuff], t_spr)}
      
        if prefix="bg"
        {var t_spr = background_add(File[level,1,stuff], 0, 0)
        background_assign(File[level,0,stuff], t_spr)}
    The problem is if I use sprite_assign(File[level,0,stuff], t_spr), the id will go to File[level,0,stuff], and not into the variable's string. I could load them one by one, but the problem is that the code from the array list is only a fraction of the whole code including all the levels. btw the global variables stored in the array variables are blank and they are suppose to be filled with the id's of sprites/backgrounds.
     
  2. Tthecreator

    Tthecreator Your Creator!

    Joined:
    Jun 20, 2016
    Posts:
    757
    you can use real() to turn any string into a number if that is what you needed.
     
  3. dannyjenn

    dannyjenn Member

    Joined:
    Jul 29, 2017
    Posts:
    569
    Just pointing out, GameMaker doesn't have 3D arrays.

    But as for your question, if I understand what you're asking, what you want is global_variable_set().
    edit - Oh, didn't see that you're using GMS1.4, so what I said won't work.
     
  4. dannyjenn

    dannyjenn Member

    Joined:
    Jul 29, 2017
    Posts:
    569

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