Issues with Save/Load System in a Text Based Adventure game made with ScriptableObjects in Unity

Issues with Save/Load System in a Text Based Adventure game made with ScriptableObjects in Unity

By : user3099010
Date : January 11 2021, 03:26 PM
This might help you Take a look at the documentation for Unity's built-in JsonUtility:
code :

Share : facebook icon twitter icon
python 3.x - text based adventure game, save game function

python 3.x - text based adventure game, save game function

By : Abd-Elmlik Abd-Elsam
Date : March 29 2020, 07:55 AM
I wish this help you You seem to have some things that define state like : self.__player_health, self.__player_name, self.__health_potion, self.__big_wrench, self.__blue_keycard. I need to read more carefully, but couldn't find a state that defines progression. With everything that defines the state you can save and read from a text file - if you are aiming at simplicity.
One way to go would be having a dict structure to store text, time to wait and function (if available, like the fighting ), like pages. Then using an array to store these pages, which would be your book. If you have a loop to keep reading those pages - reading would be another function. Then since the story is indexed, you now know where you are, so just save the states and position.
code :
import sys, traceback
import json

userQuited = False

def _quit(dummy):
    global userQuited
    userQuited = True

def _save(dummy):
    json.dump(states, f)

def _continue(dummy):
    states = json.load(f)

def user(name):
    states["player_name"] = name

states = {
    "player_health" : 100,
    "player_name" : "",
    "health_potion" : 0,
    "big_wrench" : 0,
    "blue_keycard" : 0,
    "current_page" : "page1"

book = { 
    "page1": {
        "text": """You are in an underwater research facility that has been
attacked by unknown assailants. As the assistant to the head
researcher, you were hired in to assist Dr. Weathers with
the Lightning Sword project. Project Lightning Sword still
remains in large a mystery to you. Although you worked closely
with the doctor you were never allowed to see the big picture.
Right now that's the least of your worries, as chaos ensues around you.
Alarms were triggered a while ago. As you sit in your room,
you hear short bursts of automatic rifle fire and only one
thing is for certain, you have to survive.\n """,
        "inputText": "What would you like your player to be named?",
        "function": user,
        "next": "page2"
    "page2": {
        "text": "Welcome, %(player_name)s please choose what you would like to do",
        "inputText": "0 = Quit, 1 = Start New Game, 2 = Continue",
        "choices": {
            "0" : "Quit",
            "1" : "page3",
            "2" : "Continue"
    "page3" : {
        "text" : """You are standing in your room, door is locked and you're wondering
if you will get out of this alive. The gunfire keeps getting closer and you know that you
can't stay here, you have to make a move and try and get out. Otherwise it's just a matter
of time before they find you and that option doesn't look very promising.\n\n

You are ready to try your escape but first you should try and get any useful
things from your room to use along the way. Your room-office is a bit bigger than a walk in closet,
textile flooring and gray walls encompas your view and the only things in the room are the bed you
are sitting on (not very comfortable, looks more like a prisoners bed), a framed picture on the wall
and your work desk which has barely enough space for your equipment and computer.""",
        "inputText": "1 = Walk over to the picture frame, 2 = Walk over to the desk, 3 = Exit the door",
        "choices": {
            "1" : "page4",
            "2" : "page5",
            "3" : "page7"

    "Quit" : {
        "text": "goodbye!",
        "inputText": "",
        "function" : _quit
    "Continue" : {
        "text": "welcome back!",
        "inputText": "",
        "function" : _continue

def processPage(page):
    answer = ""
    print(page["text"] % states)
    if len(page["inputText"]) > 1 :
        answer = raw_input(page["inputText"] % states)
    if "function" in page:
    if "next" in page:
        return page["next"]
    if "choices" in page:
        for choice in page["choices"]:
            if choice == answer:
                print page["choices"][choice]
                return page["choices"][choice]
    return ""

def main():
    global userQuited
        states["current_page"] = processPage(book[states["current_page"] ])
        if (states["current_page"] != "Quit" and states["current_page"] != "Continue"):

Having issues with State changes in a Text Adventure in Unity 4.6

Having issues with State changes in a Text Adventure in Unity 4.6

By : coolfun
Date : November 04 2020, 04:05 PM
This might help you You should create two states for Cell, first one listens to C and changes the state to second, second one listens to B and changes the state to Bed.
The reason is that state machines do not follow after where they left in the middle of the code inside one state. You need to be more specific when you are defining your states.
code :
bool c_pressed = false;
void state_Cell () {
        if (c_pressed || Input.GetKeyDown (KeyCode.C)) {            
           c_pressed = true;
            if (Input.GetKeyDown (KeyCode.B)) {
               c_pressed = false;
                MyState = States.Bed;
             c_pressed = false;
Item/Ability system using scriptableobjects in Unity

Item/Ability system using scriptableobjects in Unity

By : Sidharth Mishra
Date : March 29 2020, 07:55 AM
help you fix your problem If your question is "how do I create an instance of an Item in my project", you do that by right clicking in your Project view, then selecting Create -> Item. Then drag the Item asset that you created from your Project view into the ItemDisplay scene object's item field in the Inspector.
Regarding how to pick up the item, you would pass the item to your Player script from your ItemDisplay script. You've got most of that already wired up.
code :
public class ItemDisplay : MonoBehaviour
   void OnTriggerEnter(Collider other)
      if (other.gameObject.tag == "Player")
         var playerPickUp = other.gameObject;

         var playerScript = playerPickUp.GetComponent<Player>();
         var playerItem = playerScript.playerItem;

         // This is where you would pass the item to the Player script

         bool isActive = true;

public class Player : MonoBehaviour
   public void PickUpItem(Item item)
      this.playerItem = true;
      this.itemInHand = item;
      Debug.Log(string.Format("You picked up a {0}.", item.name));

   public void UseItem()
      if (this.itemInHand != null)
         Debug.Log(string.Format("You used a {0}.", this.itemInHand.name));
public abstract class Item : ScriptableObject
   // Properties that are common for all types of items
   public int weight;
   public Sprite sprite;

   public virtual void UseItem(Player player)
      throw new NotImplementedException();

[CreateAssetMenu(menuName = "Items/Create Potion")]
public class Potion : Item
   public int healingPower;
   public int manaPower;

   public override void UseItem(Player player)
      Debug.Log(string.Format("You drank a {0}.", this.name));

      player.health += this.healingPower;          
      player.mana += this.manaPower;

[CreateAssetMenu(menuName = "Items/Create Summon Orb")]
public class SummonOrb : Item
   public GameObject summonedCreaturePrefab;

   public override void UseItem(Player player)
      Debug.Log(string.Format("You summoned a {0}", this.summonedCreaturePrefab.name));

public class Player : MonoBehaviour
   public void UseItem()
      if (this.itemInHand != null)
Text-based adventure game, attacking causes game to crash

Text-based adventure game, attacking causes game to crash

By : user3102696
Date : March 29 2020, 07:55 AM
should help you out It would be better if you added the get_available_actions(arg1, arg2) function. It appears that this function does not return a value or returns None (which is the same this).
If you can add more of your code we can analyze this error further. Otherwise, you should try to change the return to something can use the method .get(arg1, arg2).
code :
def get_available_actions(room, player):
    actions = OrderedDict()
    print("Choose an action: ")
    if player.inventory:
        action_adder(actions, 'i', player.print_inventory, "Print inventory")
    if isinstance(room, world.EnemyTile) and room.enemy.is_alive():
        action_adder(actions, 'a', player.attack, "Attack")
        if world.tile_at(room.x, room.y - 1):
            action_adder(actions, 'n', player.move_north, "Go north")
        if world.tile_at(room.x, room.y + 1):
            action_adder(actions, 's', player.move_south, "Go south")
        if world.tile_at(room.x + 1, room.y):
            action_adder(actions, 'e', player.move_east, "Go east")
        if world.tile_at(room.x - 1, room.y):
            action_adder(actions, 'w', player.move_west, "Go west")
        if player.hp < 100:
            action_adder(actions, 'h', player.heal, "Heal")

    return actions
Text Based Adventure Game

Text Based Adventure Game

By : Cosmin Gabriell
Date : March 29 2020, 07:55 AM
Hope this helps I'll try to help as best I can a piece at a time. My line numbers might be slightly different from yours, so feel free to look around a bit.
Related Posts Related Posts :
  • Passing enum type to Converter with integer value
  • Pool of objects with objects that are already on the scene in advance
  • StatusBar text fade-out when binding using Caliburn.Micro
  • Queryfilter on ApplicationUser in OnModelCreating in ApplicationDbContext creates StackOverflowException
  • How to get record form a different table based on a value from first table with linq expression?
  • Show data in Grid from returned model
  • Using Attributes to Override Data Model Conventions
  • Basic OOP console calculator, result Error
  • Compositon and Repository pattern
  • Multiple using statements with if condition
  • How do i increase a number by 1 in every line that contain the number 1
  • Add binding to elements that are created in codebehind
  • How to add a column in an existing AspNetUsers table
  • Order a list of elements with another list of doubles
  • How to setup a NuGet package to copy content files to output build directory?
  • In SignalR Core using ChannelWriter: Do I need to call TryComplete twice if there's an exception?
  • C# GetProcessesByName: issue with colon
  • c# wpf | create complex object with user-defined name to Serialize into JSON
  • How can I get a instance of a generic list with reflection?
  • WPF XAML - Design time and visibility of textbox
  • EF Core and MySql query is too slow
  • Getting Registered App Display Name from an App Id
  • How to get all variables from a string
  • Delete entity with all childs connected
  • Azure Build agent cant´t find class library referance
  • Initialize Nested Dictionaries in c#
  • .Net Core Binding
  • Loading a pop up page in ASP.net through a js file
  • How to pass alert or notification message from controller to View?
  • C# to pause, turn on ssas server, backup cube.... how to?
  • How to execute DataTable.Select() for a column of custom class type for a particular element in that C#
  • how to connect mysql8.0 with C#
  • Passing incorrect values into MultiValueConverter by MultiBinding
  • Can i use IEnumerator as Update func?
  • How to convert API Json response to C# Array?
  • Blazor Textfield Oninput User Typing Delay
  • Performing both layout and render transform results in wrong output
  • uwp beforetextchanged cursor moving in front of text
  • How to keep duplicates from a string[] exclude words from a List and print them out
  • .Net Core Strings.Asc/Mid/Chr/Len missing even after importing Microsoft.VisualBasic
  • How to return to previous search page without being asked to Confirm Form Re-submission and keeping the results on ASP.N
  • How set a identity scaffolding item/page how initial page in asp.net MVC core?
  • LINQ isn't calling Dispose on my IEnumerator when using Union and Select, expected behavior or bug?
  • What is "ByteArray.uncompress()" in AS3 equivalent to in C#?
  • Getting a specific letter from a string variable for my simple guessing game for clues
  • Send an email with Outlook without a subject --- dialog box issue
  • passing List<MyModel> from my controller in the "WebInterfaceProject" to the processor method in "D
  • How to convert Word document created from template by OpenXML into MemoryStream?
  • How can I make a single slider that changes the color of an object?
  • Remap JSON parameter in c#
  • What is the difference between "this ref" and "ref this" when talking about C# 7.2 ref extension met
  • Convert OpenSSL encryption into native C#
  • Accessing Properties in Razor Pages
  • How to get SOAP element value
  • Projection after Group
  • C# error cannot convert sytem.text.regularexpressions.match to string
  • VS2019 MSBuild.exe - ASP .Net MVC project fails to publish when using PublishProfile, but works when using OutDir parame
  • Does <pages validateRequest="false" /> in Web.config still matter?
  • How to send new request to redirect URL with new access token
  • Attempt to invoke virtual method on a null object reference Xamarin LockScreen
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org