Skip to content
Sign UpLog In
Profile icon

Pan Cake

@ElijahNarvaez
Discord: myyummydino#5054 I'm young and stupid (15)
  • TEXT RPG GAME

    Cover page
    Made with Python
    Recent comments (0)
Repls
Community
ElijahNarvaez
ElijahNarvaez
shared a Post
1 year ago
I need python help
Me again, hello. In the m.py file I want the clear to happen before my place holder, its doing it after, even tho its in the order I want. How do i fi
Coder100
Coder100
that's not correct. The file actually gets executed when you import it, not when you try to access a variable. What you want to do instead is to make functions that return input, instead of making variables.1 year ago
ElijahNarvaez
ElijahNarvaez
shared a Post
1 year ago
yes, its your boy back at it again to ask more stupid questions. anyway, how would i go about using the variables in coolfile.py. also am i importing
ElijahNarvaez
ElijahNarvaez
Thanks, both or you1 year ago
Coder100
Coder100
no you are not importing the file correctly. You are running coolfile.py, but remember, because you are running it, main.py can't use the variables. You can import variables, or import them all. To import all the variables, from coolfile import * to import them all, but you have to reference them like: coolfile.x import coolfile and lastly, to import only specific ones, like the var x from coolfile import x i recommend using the second option.1 year ago
CosmicBear
CosmicBear
To import it use import coolfile. This will run the file "coolfile.py" which creates the variables inside "main.py". EDIT: That is actually incorrect use from coolfile import variable instead.1 year ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
My text rpg game (I don't have a name yet) With some help from my mini "help the eli" series cough @RYANTADIPARTHI, cough @JBYT27 (Sorry for the ping)
TEXT RPG GAME
Python
MMansoori
MMansoori
thTs fun 2 years ago
Dunce
Dunce
very cool game, I especially like the combat menu, but I think it would be nice if the menu were you decide if you want to attack or run was combined with the combat menu, also I think the yes or no test was confusing.2 years ago
IAmLufffy
IAmLufffy
Pretty good2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
How do I get the program to restart if something happens? Ex. y = "y" n = "n" test = input("pick y or n") if test == y: #the program resets else: #t
RYANTADIPARTHI
RYANTADIPARTHI
Solution you can ask the question, like this. y = "y" n = "n" test = input("pick y or n") if test == y: d = input('again ? ') if d == y: code for continuing else: exit() else: #the program continues none like that. It should work2 years ago
SixBeeps
SixBeeps
That's a while loop: while (test != 'y'): do something test = input('y/n') Do more stuff when not Y `2 years ago
TsunamiOrSumth
TsunamiOrSumth
sys.exit()?2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
In spawn_slime I want the ehealth and edamage variables to be replaced with a random number each time it is "spawned". This is python btw.
Text Rpg
Python
JBloves27
JBloves27
So do the following: import random ... ehealth=random.randint(0,100)#switch the last number to any int edamage=random.randint(0,100)#same as ^ I hope this helps!2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
Solution like this. import random ehealth = random.randint(1, 10) print(ehealth) # to see That should work2 years ago
ObiVibKenobi
ObiVibKenobi
ehealth = random.randint(min, max) Use this to generate random health, put nums where min and max are2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
How do I subtract/add from a variable in python. Ex. number = 20 test = input("y is +1 and n is -1: ") y = "y" n = "n" if test == y: #put how to add
RYANTADIPARTHI
RYANTADIPARTHI
Solution do +=. IT will work then. number = 20 test = input("y is +1 and n is -1: ") y = "y" n = "n" if test == y: number += 1 print(number) elif test == n: number -= 1 print(number) else: none like that. That should work2 years ago
ElijahNarvaez
ElijahNarvaez
I want it to only happen if something else happens2 years ago
JBloves27
JBloves27
So if you want it permanent, do number - 1 but if you want it only on the time that the person runs the program, do number-=1. You can change the 1 to any int btw. I hope this helps!2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
how do i get something to do nothing in python Ex. while thing != 0: if thing == 0: print("sample text") else: #do nothing or continue `
angrydoge
angrydoge
None or pass are nothing. They have a null value.2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
Is there a way center text in python. I'm assuming there's a file to do this or something. Ex. print("centered text") I want this to be in the center
RYANTADIPARTHI
RYANTADIPARTHI
Solution yes there is. Use the center() method. Like this. string = "something" new_string = string.center(50) print(new_string) like that. Change the numbers for more centering That should work2 years ago
JBloves27
JBloves27
No, you cannot. If you want, you can make it approx., which you could use \t or tabs and spaces. I hope this helps! Edit: i was wrong2 years ago
ElijahNarvaez
ElijahNarvaez
like the center text part , not the print part too btw.2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
I did part 5 before part 4 (shhh). Anyway how do I get it to wait for a while before continuing
JBloves27
JBloves27
To do this, import the time module. Do the following: import time ... time.sleep(0)#switch this to any int #you can use this any amount of time I hope this helps!2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
How do I get stats() to work. Also how does Int work?
Text Rpg
Python
RYANTADIPARTHI
RYANTADIPARTHI
Solution you are assigning stats() to a function. So in order to work, you have to call it. also, you have to make the vars global. like this. def stats(): global health, damage, mp print ("----Stats----") print ("Health: " +str(health)) print ("Damage: " +str(damage)) print ("Mp: " +str(mp)) stats() and the int() is to make something an integer. Like if you want an input to only be numbers, put int. If someone puts str, it gives an error. d = int(input("number : ")) print(d) lik2 years ago
JBloves27
JBloves27
So to make it work, do the following: def stats(): print("----Stats----") print("Health: "+str(health))#do the same to the others print("Damage: "+str(damage)) print("Mp: "+str(mp)) I hope this helps!2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
Well the stored package doesn't work anymore, whats the next best thing?
Text Rpg
Python
ElijahNarvaez
ElijahNarvaez
thanks you everyone who answered2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
Solution you are trying to access something from a file. So use from. Also, try removing the if. Cause, that's a keyword, and remove the apostrophe. Maybe it will work then. from if import if0, if1 or everything from if import * like that. That should work2 years ago
JBloves27
JBloves27
You want to import you .py file, right? If you want to do that, rename the file. You cant have a ' in a .py file, so an example could be: from if import * #and rename the file as if I hope this helps!2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
How does the global command work.
IntellectualGuy
IntellectualGuy
The global command is used to declare a variable inside of a function. When you declare a variable outside a function then it's automatically global Let's say that you are making an add function for a calculator. Here's how you would use it. This is how to use it when declaring the variables inside the function. #Declaring the function def add(): #Declaring the first number you want to add global number1 = 5 #Declaring the second number you want to add global number2 = 5 #Assing2 years ago
MocaCDeveloper
MocaCDeveloper
Global just allows you to work with variables outside of the current scope. Example. Lets say we have a variable a outside of a function, and we want to assign and keep an assigned value of that variable within the function and outside of the function, we'd then use the global keyword! Ex: age = 0 def get_age(): global age age = int(input('What is your age: ')) The above makes the variable age "global", or accessible, in the function get_age. But yeah. Technically all it does is al2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
Well, I'm going to start a series. I'm going to slowly learn by asking people. Anyway how would I get my stored code to work in the file "stored_code.
Coder100
Coder100
#main.py import stored stored.hello() you need to actually import the file. Also, change your stored.py to: def hello(): print("hello") print("hello") I don't think you understand what global actually does. https://www.programiz.com/python-programming/global-keyword2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
I'm on python. How do you run other files? Whats the command and how does it work?
littlepenguin
littlepenguin
import os os.system("language your using filename.py") You can also import your file like this: import file file.function(params) `2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
I learn by copying code and figuring out what does what. Im slowing making edits to a program I found. I don't know why this doesn't work. I'm using p
ElijahNarvaez
ElijahNarvaez
I feel dumb as I still don't understand.2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
Looks like pygame.display.init() has a error. Maybe try calling it somewhere else, instead of over there.2 years ago
programmeruser
programmeruser
Apparently it's trying to initialize sound which doesn't work. Try calling pygame.display.init() and pygame.image.init().2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
If anyone knows what im talking about how do I use pip or/and pygame. I want to use it but I don't know how to open it.
RYANTADIPARTHI
RYANTADIPARTHI
You don't have to install pygame. You can just open up a pygame repl, and do all your pygame stuff in there.2 years ago
Coder100
Coder100
pip is a package manager. It will install pygame for you. Of course, that's a lot of setup, so you can just create a pygame repl: https://repl.it/l/pygame and then try the examples.2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
@jamer101 here's my program, I suck so if it breaks or isn't good o well.
ElijahNarvaez
ElijahNarvaez
https://repl.it/talk/ask/my-own-jam-for-people-to-join/808982 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
What does it mean by invalid syntax?
PattanAhmed
PattanAhmed
@ElijahNarvaez Hi, It's just because you have break thing out of the If statement. So, just add indent it a little bit. and there is another error, Guess yourself:- Change your lines 73-82 like this:- update = input("Wanna conutine? ") while update != yes: if update in no: print("oh") break elif update == yes: print("lets go then") else: print("wa?") That's it Thanks! Hope this helps2 years ago
Bookie0
Bookie0
Hi, Invalid syntax means that you most likely made a typo or something; Python doesnt know how to execute that line. > An invalid syntax error means that there is a line that python doesn't know what to do with. The last common type of syntax error you will likely encounter has to do with indention. You may see unindent does not match any outer indention level unexpected indent. Examples: print "hello world. For your case, on line 78 you wrote this: Screen Shot 2020-09-23 at 10.43.12 AM but 2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
Its your boy back at it again needing more help cause I stink. Why wouldn't the break work?
PattanAhmed
PattanAhmed
@ElijahNarvaez Hi again, This error says that:- 'break' outside loop Which means break statement is outside of loop. For that, fix your indentations. Fixed code:- Replace this code from line 54 till 63:- while True: number = random.randrange(1, 10) guess = input("Try again: ") #game answers if guess != number: print("Try again: ") elif guess == int(guess): print("You got it, " + name) break That's it Thanks! Hope this helps2 years ago
Coder100
Coder100
You forgot to indent. import random while True: number = random.randrange(1, 10) guess = input("Try again: ") #game answers if guess != number: print("Try again: ") elif guess == int(guess): print("You got it, " + name) break Remember to indent!2 years ago
ElijahNarvaez
ElijahNarvaez
Y is it outside of the loop 2 years ago
ElijahNarvaez
ElijahNarvaez
shared a Post
2 years ago
At the end it says I did something wrong I don't know what tho.
PattanAhmed
PattanAhmed
@ElijahNarvaez Hi, Here is your fixed code:- This will not give any errors from now on:- #name name = input("Whats your name: ") print("Hello " + name) #mood variables good_mood = "good","nice","pretty good","it was pretty good","Good","Nice","Pretty good","It was pretty good" bad_mood = "bad", "it sucked", "really bad", "BAD","Bad", "It sucked", "Really bad" ok_mood = "ok", "not bad", "fine","Ok", "Not bad", "Fine" #mood anwsers mood = input("How was your day: ") if mood in good_mood: 2 years ago
Coder100
Coder100
On line 34, do: global bored = input ("Wanna play a game? " ) because the variable is inside the if statements and will not be outside and defined on line 462 years ago