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

In postgres I am fairly sure you can do something like this SELECT authors.stage_name,
This is a fairly trivial matter, but I'm curious to hear people's opinions on
This is a fairly basic question, which for some reason, a proper solution escapes
This is a fairly involved bug, and I've tried looking around to find other
Okay this is a fairly broad question. This is my first App and I'm
While I understand this question is fairly vague since I'm not giving you all
This question may sound fairly elementary, but this is a debate I had with
I am fairly new to programming and while doing a lot of reading this
I'm fairly new to C# but I will try to make this quick! ;)
I'm fairly new to deploying desktop applications, so this is the first time I'm

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.