Hey I'm relatively new to javascript programming and I'm working on a javascript game and I need help with this script:
a = (); //a is the number of the quest completed e.g. 3 would be Quest3
Quest1 = "Hello1"
Quest2 = "Hello2"
Quest3 = "Hello3"
Quest4 = "Hello4"
Quest5 = "Hello5"
Quest6 = "Hello6"
Quest7 = 0 //This is just a placeholder for the end of the list
This is a script for a list of quests in chronological order of when they were recieved. That the player needs to complete. When a quest is completed it is removed from the list and the list is moved up to fill in the space The way I was doing this was, even though there is probably a better way to do it (If anyone knows of a better way let me know). So say if Quest3 was completed then the following code would execute to make the list move up starting at the quest completed:
Quest3 = Quest4;
Quest4 = Quest5;
Quest5 = Quest6;
That script is starting at Quest3, but I need that script to be able to start at any point and I wanted to use 'a' for that. So if a = 4 then the script would start at Quest4:
Quest4 = Quest5
Quest5 = Quest6
This script would go backwards if a new quest was added so, since new quests added will always go to Quest1 then the following script would execute:
Quest6 = Quest7 //Get rid of quest 6
Quest5 = Quest4
Quest4 = Quest3
Quest2 = Quest1
Quest1 = "The New Quest"
So the maximum amount of quests the player could have could be 6 (much higher in the actual game so the player never reaches the limit.
So if anyone knows how to have the starting point for the script to add a new quest, dynamic and or a better way to move the list up of down to fill in the gap, let me know.
key= quest number andvalue= your string or function.