ImPrettyFamous's Recent Forum Activity

  • Hey gang!

    So, I've gotten a pretty good handle on integrating simple JavaScript functions into my project. I'm now trying to use JavaScript in conjunction with an Array I have in my project...

    Here's what's going down:

    I have an array (ARR_SongRelease) that stores generated songs: X[0] = Artist Name, X[1] = Song Name, X[2] = Streams Generated For That Song. Whenever a new song is generated in the game, it adds a new entry on the Array's 'Y' access. The array is saved in local storage! This all works great :)

    However, I'm trying to display the top 15 songs (based on the Streams, or X[2] value).

    Here is what my main.js function is looking like:

    And here is what's happening in the event sheet:

    From a little bit of debugging, I've concluded that the issue has something to do with how ARR_SongRelease is being requested, because the code works perfectly fine in VS Codium using a test array. I'm wondering if I have a simple syntax issue somewhere (as I've never tried to call upon a Construct array in JS before), or if the issue is deeper, like my Local Storage, and it's trying to run this function before the data from the Array is even loaded?

    Any and all help would be greatly appreciated :)

  • You do not have permission to view this post

  • tarek2 wow, after years of Construct...I had absolutely no idea you could do that. What a brain bender...

    Thanks for all your help; you saved the day! Arrays are kind of an intense animal for me, I was struggling with this for days. I totally appreciate the examples and help you gave!!!

  • tarek2 you're flippin awesome. I copied whatcha did, threw it in my game, and the sorting works!! I'm fumbling on the text part though. I had to adjust the "create object" parameters of the the Table Grid to fit the viewport of the game. Perhaps I'm losing it, 'cause in your demo it works, but I don't see where/how the text is being binded to the table grid??

  • Here's a diagram to better visualize what I'm trying to get across.

    So, the upper half of the image is a visual representation of what my Array is doing. Every time a new song is generated, the array adds a new Y column, and logs the artist(X=0), song title(X=1), and plays(X=2).

    The lower half of the image is what I'm trying to achieve in my layout. My diagram example stops at 4, but I want to showcase the top 10 songs based off their plays.

    I wish to know how to cycle through the array, and show via text the most-played songs that have come out.

  • Thanks tarek2 for the reply!

    This sounds like it is for a single song but you are using "Cur.Y" which is used on "Array For Loop" which it will loop through all the Y

    Sorry, I'll condense what I'm looking for. There can be, in theory, hundreds of songs generated in "ArraySongRelease."

    I want to show the top 10 on my layout, based off the value stored on X(2).

    How can I go about doing this? "Array For Loop?" Is there a manual/guide somewhere where I can learn more about "Array For Loop"? ◡̈

  • Heya all.

    I'm sucking at this...and need some major help ◡̈...I'm desperate.

    I have a music career simulator game in the works. There are AI-controlled artists who'll randomly write songs. I have 2 arrays thus far for storing data: "ArrayAIStats" and "ArraySongRelease."

    "ArrayAIStats" stores and updates information as the game progresses -- information such as the artists' names, their total number of fans, etc..

    "ArraySongRelease" is choosing an AI-controlled artist at random, and based off their current number of fans, is generating a total number of plays which their new song will receive.

    It's being logged as:

    x(0) = artist name

    x(1) = song name

    x(2) = plays generated

    whenever a new song is released, the array adds a new Y entry, and repeats the process.

    ^ all of this works great.

    The issue I'm having is:

    I'm trying to create a "Top Songs" layout/event sheet where I display the songs stored in "ArraySongRelease," and sort them in ranking order based off their plays (X=2).

    I have 2 texts, and I'm trying to have Text1 show the name and song title, like:

    Array.SongRelease.at(0, cur.Y) & " - " & Array.SongRelease.at(1, cur.Y)

    and have Text2 show the total number of plays, like:

    Array.SongRelease.at(2, cur.Y)

    I can't seem to figure it out myself, and would love love love some help!!!

  • For the past year now, I've been working on a music career simulator. In a basic sense, you sign an artist, choose their artist name, and through quick minigames, write songs and play shows to grow a fanbase! You're competing against 10 AI controlled artists who are all competing for the same thing.

    In a deeper sense: I've tried to build a lively little world filled with fun NPC's and events (like interviews, press shoots, etc). You can make friends, enemies, unlock skins, become "Artist of the Year," and eventually, make it into the music Hall of the Fame. There's even an annual end-of-the-year tournament where you'll go head-to-head against the other artists in Guitar Hero-like fashion.

    No release date yet, but it's coming along ◡̈ if anyone's interested, I started a discord server! I'm always open to ideas, and have fun plans to include community art!

  • I have a music career simulator in the works! Here's a screenshot from one of the performances ◡̈ very Guitar Hero-esque

    if any of you would like to pop in the discord, by all means -boop-!

  • If that is happening I would move the AJAX request to a 'local storage save is missing' condition, not 'on start of layout'. So the flow is only to check if your save exists, if it doesn't then load those default values and if it does then load the save data.

    You, my friend, are a godsend. This worked perfectly! It's always the littlest of things give you the biggest hiccups, I swear. Thanks Lionz!! After hours spent finagling my local storage issues, you made my day!

  • Looks like the screenshots are from two different event sheets which is concerning. Depends on the order of events, can't tell from these screenshots. From what I can see loading that AJAX request doesn't depend on if you already have save data so it would always run it. My best guess is that you could be loading correctly from local storage then overwriting with the AJAX request.

    Heya lionz! Yes, the screenshots are from two different event sheets, as mentioned :)

    First screenshot is of my local storage event sheet.

    The second screenshot is for my array event sheet, which is populating it's data from the AJAX request.

    ^ I included this one because I also have a hunch that the AJAX request is messing things up. The local storage could definitely be getting overwritten by the AJAX request. Any idea how to fix it? LOL

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey gang!

    Please help :)

    I have an array (called ArrayAIStats), populated by an array file (called Stats.json).

    On start of layout — AJAX| Request Stats.json (tag "")

    AJAX| On "" completed — ArrayAIStats| Load from JSON string AJAX.LastData

    This works totally awesomely. I have a visual array graph, where I can easily change and add values.

    The problem, however, is the values in this array change throughout the game; the stats change. I can't seem to get my local storage save function to save this array in particular; it always resets back to the default values. I'm not sure if it's because the data is being pulled from the Stats.json file? I have a different array that saves, and loads perfectly fine, even as new data gets added onto it. I'm not sure where I'm going wrong :(...

    I attached some screenshots; one of my 'Local Storage' event sheet, the other is of the event sheet for my ArrayAIStats. In my Local Storage event sheet, I underlined in red the array that's giving me problems.

    Thanks in advance!

ImPrettyFamous's avatar

ImPrettyFamous

Member since 30 Oct, 2018

None one is following ImPrettyFamous yet!

Trophy Case

  • 5-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

8/44
How to earn trophies