Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:02:32+00:00 2026-05-27T22:02:32+00:00

Hey I’m relatively new to javascript programming and I’m working on a javascript game

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:02:33+00:00Added an answer on May 27, 2026 at 10:02 pm

    You should use Arrays no matter what language you use in this case:

    This is example in javascript:

    var maxQuests = 6;
    var quests = new Array();
    var activeQuests = 0;
    
    function addQuest(questName) {
        if (activeQuests >= maxQuests) return;
        activeQuests++;
        quests.push(questName);
    }
    
    function completeQuest(questName) {
        if (!quests.contains(questName)) return;
        activeQuests--;
        quests.splice(quests.indexOf(questName), 1);
    }
    

    http://jsfiddle.net/xguwk/

    It’s the way it should be programmed. You can change the number of quests as a parameter, you don’t need to rewrite your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I'm working on a project for school where I need to pass
Hey guys, I'm working on a project. I need to use the function cvFindHomography
Hey I am a java programmer working on a HTML/CSS/JavaScript project. At the moment,
Hey I need a little help with unsigned char bit access. I need to
hey i guys i want help from you. i am working on website project,
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey, in the Programming Pearls book, there is a source code for setting, clearing
Hey guys I need to send the content of an NSMutableArray through email. I
Hey, I need to do my drawing over a panel in C# but without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.