Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell broke? #4386

Closed
c-chamb opened this issue Jan 25, 2025 · 1 comment
Closed

PowerShell broke? #4386

c-chamb opened this issue Jan 25, 2025 · 1 comment

Comments

@c-chamb
Copy link

c-chamb commented Jan 25, 2025

i have no clue what went wrong, but two things i did differently with this project than my other projects is 1) im opening a folder from my Downloads folder and 2) i installed a new module called stringcolor to, well, color strings. im using python 3 and VSCode.

error message:

Last 119 Keys:
 & Space C : / U s e r s /*******/ A p p D a t a / L o c a l / P r o g r a m s / P y t h o n / P y t h o n 3 1 2 / p y t h o n . e x e Space " c : / U s e r s / ******* / D o w n l o a d s / p y t h o n - g a m e Space ( 1 ) / g a m e . p y " Enter

Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
Actual value was -2.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

my code:

#-imports

import sys
import os
#from stringcolor import *
import time

#-functions

#--backend functions

def assignData(fileLoc):
    fileTemp = open(fileLoc, "r")
    data = fileTemp.readlines()
    fileTemp.close()

    for i in range(len(data)):
        data[i] = data[i].replace("\n","")

    return data

def inventoryLoad(item):
    for i in range(15):
        inventory.append(dataLines[i+invStart])
    return inventory

def twEffect(text,delay):
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(delay)
    print()

def dataCompiler(data):
    data2 = ""

    for i in data:
        data2 = data2+i+"\n"

    return data2

def inp(currentF,text=""):
    if text != "":
        print(text)
    ans = input()
    if ans.find("/cmd") != -1:
        ans = ans.replace("/cmd ","")
        try:
            commands.index(ans)
        except:
            exec(currentF)
        else:
            exec(commands[commands.index(ans)+1].replace("(","('"+currentF+"'"))
            return ""
    else:
        return ans

def saveData(currentF):
    fileTemp = open(os.path.join(fileLocation, "data/data.dat"),"w")
    fileTemp.write(dataCompiler(dataLines+inventory))
    fileTemp.close()

    exec(currentF)

def quitGame(currentF):
    pass
    
def resetData(currentF):
    pass

def openInventory(currentF):
    pass

def openStats(currentF):
    pass

#--gameplay functions

def intro():

    os.system('cls||clear')

    twEffect("You wake from the sunlight penetrating the pink and black cherry tree foliage above you... the creek trickles beside you, as you see the lilies and their pads gently moving along with it. You stand up and look around, curious of your location and what had happened last night... but you can't remember anything. You can't remember your house, your family, or what you had for breakfast yesterday. All that remains is you and a sense of divine intervention as the one successful grasp of rememberance hits you.\n",0.025)

    #print(cs("What is your name?\n","#00FFFF"))

    name = inp("intro()")

    dataLines[1] = name

    os.system('cls||clear')

    #print(cs("\nA sense of rightouesness imbues itself in your being as the name " + name + " hits you.\n","#FF69B4"))

    time.sleep(0.5)

    twEffect("You should probably get yourself set up for tonight. Hunger tugs at your stomach, so with only fourteen hours before nightfall, you decide to scout your surroundings.\n",0.025)

    twEffect("You look out into the distance. Empty ocean looks back at you as you observe the sun rising from the east. To the North lies a plains with a small village in it. You can see the residents doing their daily buisness up from your cherry wood cove upon a mountain. To the west lies a massive stone wall as you can see the taller side of the mountain you are upon scaling upwards as far as you can see. And behind you to the South is a densely packed forest. You can't make out the details of what is in it, besides it being very dark from the shade of the plethra of trees.",0.025)

#-variables

fileLocation = os.getcwd()
#fileLocation = os.path.join(os.getcwd(),"python-game")
dataLines = assignData(os.path.join(fileLocation, "data/data.dat"))

commands = ["save","saveData()","quit","quitGame()","reset","resetData()","inventory","openInventory()","stats","openStats()"]

invStart = 5 #where players inv starts in data.dat
inventory = ["pocketKnife","","","","","","","","","","","","","","",] #inventory contents
location = "cherryGrove"
health = 100 #player health
turn = True #if true, the player is able to perform an action. If false, the oppenent performs an action.

#-gameplay

if dataLines[0] == "0":

    dataLines = ["1","","","",""]

    intro()

i honestly have no clue whats going on, but my best guess is that the stringcolor module messed up powershell somehow and now powershell is just screwed over on my pc

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jan 25, 2025
Copy link

This issue was already fixed (see #1306). Please upgrade to the 2.3.5 version of PSReadLine from PowerShell Gallery.
See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant