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 1081789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:12:47+00:00 2026-05-16T22:12:47+00:00

This is fairly difficult to explain. I am working on a text adventure at

  • 0

This is fairly difficult to explain. I am working on a text adventure at the moment and I am parsing input from a player.

When a player enters input, there can be two possible subjects (let’s call them subject1 and subject2). For example, in the following: “hit door with stick”, subject1 is “door” and subject2 is “stick”.

In this case, both door and stick are of the type “Item”. There can also be subjects of the type “Character”.

The problem is that if I parse items, then characters, the item parse will find the item as subject1 even if it’s actually the second subject. The code I am using looks like this:

public static void ParseForSubjects(string Input, Player CurrentPlayer, ref object Subject1, ref object Subject2)
{
    // This method doesn't really work properly, as it looks up Inventory items, Environment items and then Characters in order
    // when it may well be that a character is subject1 and an item is subject2, but they will be reversed because of the parsing order
    Input = Input.ToLower();

    // Parse items in Player inventory
    foreach (Item InventoryItem in CurrentPlayer.Inventory)
    {
        if (Input.Contains(InventoryItem.Name.ToLower()))
        {
            if (Subject1 == null)
            {
                Subject1 = InventoryItem;
            }
            else
            {
                Subject2 = InventoryItem;
            }
        }
    }

    // Parse items in environment
    foreach (Item EnvironmentalItem in CurrentPlayer.CurrentArea.Items)
    {
        if (Input.Contains(EnvironmentalItem.Name.ToLower()))
        {
            if (Subject1 == null)
            {
                Subject1 = EnvironmentalItem;
            }
            else
            {
                Subject2 = EnvironmentalItem;
            }
        }
    }

    // Parse present characters
    foreach (Character PresentCharacter in CurrentPlayer.CurrentArea.Characters)
    {
        if (Input.Contains(PresentCharacter.Name.ToLower()))
        {
            if (Subject1 == null)
            {
                Subject1 = PresentCharacter;
            }
            else
            {
                Subject2 = PresentCharacter;
            }
        }
    }
}

I’m sure if this is really clear enough. Basically regardless of the type, I need subject1 to be the first subject in the Input string and subject2 to be the second subject in the Input string.

Feel free to ask questions, this probably isn’t 100% clear.

  • 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-16T22:12:48+00:00Added an answer on May 16, 2026 at 10:12 pm

    Just check Input.IndexOf(Subject1.Name.ToLower()) < Input.IndexOf(Subject2.Name.ToLower()) and if false, then switch them.

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

Sidebar

Related Questions

I thought this would be fairly trivial but it's turned out be more difficult
I realize there are other threads addressing this problem but as I am fairly
This is a bit difficult to explain, so I apologize if this doesn't make
I'm trying to use this fairly standard line of code in my app: [[UIApplication
I'm a beginner at SQL and have this fairly easy conditional problem: Every installation
Say I am storing addresses in a DB table, in this fairly common break
This is fairly simple but I cant work it out. I'm building a wordpress
This is fairly simple in Windows, but a little tricky in Linux. I am
I know this is fairly subjective, but I'm diving into testing and learning about
I guess this is fairly simple for you but i cant wrap my head

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.