1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GML Problem to add something at the end of a list

Discussion in 'Programming' started by Tarte, Feb 10, 2019.

  1. Tarte

    Tarte Member

    Joined:
    Jan 10, 2019
    Posts:
    30
    Hi ! I have a problem, in my game, the items bought at the shop arrive in a list. When looking at purchased items, the list is read and items are placed (in order). But I would like the items purchased last to be first. For that I would like them to be added at the end. Thank you for your answers in advance ;)
     
  2. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    920
    Use ds_stack instead of ds_list. Or alternatively, read the list from the end upwards rather than from the start downwards.
     
  3. Tarte

    Tarte Member

    Joined:
    Jan 10, 2019
    Posts:
    30
    Oh sorry Isn't a list is a array.
     
  4. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    3,591
    Then read your array from the back to the front. Arrays do not automatically resize down the way lists do, so you need to keep a separate variable indicating where the last inserted value is.
     

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