It’s a good start but you should consider trying to move to making a bit more difficult programs.
You are going to have a fun time with C# where everything is a reference (a fancy pointer), except when the type is a struct.
So for example if you have a function like:
public void DoSomethingWithAnObject(SomeType a){
a.Property = 1;
}
Depending on if SomeType is a class or struct the effect is different.
Classes are always passed as reference so if you call that function with an instance of a class, the object will get modified.
But if SomeType is a struct, it is passed by value (not by reference which is a disguised pointer) , so in that case your instance that you pass to the function is not modified.
I realize I might not be the best at trying to explain this. I just wanted to highlight a difference between C++ where you explicitly know if multiple variables actually are connected to the same object (SomeType*
and SomeType&
versus SomeType
), but in C# you just have to know if the type is a reference (class) or a value type (struct) in order to figure out if your changes to an object might interfere with other codes’ use of the same object.
(In C# of course)
Well, explicitly you won’t. But instead you’ll always be using the equivalent of pointers.
And that makes it easy to make bugs due to random functions changing the properties of objects they shouldn’t. To fight that you need to understand the semantics of pointers (ie. multiple variables that access the same object).
Did you do like a 1-to-1 following of the tutorial, or close to it? If you did that, then you might want to next try to add some small new features to the project you made to make sure you truly understood what the code does.
Update: Now, I’ll be working on my gamemode on Garry’s Mod.
I’ll try out later.
Perhaps you could look at an existing gamemode that adds stamina. I’m sure I’ve seen gmod mods that add a sprinting stamina bar.
I have finished the barebones (like 4%) of the Formicarium Project. It has a run time of 18 seconds, the link below has the Python file and incase you don’t trust me (you shouldn’t download python files from people you don’t trust) I have all the code in ‘formicarium_project_non_pyhton.txt’ that you can read and paste into a Python Shell. I have caught some errors and I am using one to cause Python to crash as a way to quit.
This link lasts one week.
If this is against the rules, feel free to smite this post that breaks the rules off the forum.
What is this? was this discussed before?
You can exit with sys.exit(exit_status)
in python. Import the sys
module to use it (which you didn’t do if I’m reading it correctly. Put import sys
somewhere on the top of the file.).
enterinput.lower()
will return enterinput
in lowercase. str.upper
is also a thing.
If one types in BACKGROUND
you will still get the message used for unexpected input. That’s because the user didn’t write HELP
, which means that the else after the help check fires. Use elif
for the checks between the first if and the else so that once one check fires, the others don’t. Also, the check for unexpected input should be at the bottom of that if-elif chain.
e.g:
if enterinput == "QUIT":
#blabla
elif enterinput == "BACKGROUND":
#blabla
elif enterinput == "HELP":
#blabla
elif enterinput == "ENTER":
#blabla
else:
#unexpected input
The user is also very unlikely to write sentences like «I get a Syntax Error when trying to run this» without differences. The in
keyword can be used to search for elements in an array (such as strings or lists), if you still want to do it the way you are doing it.
The help section are all placeholders as, unlike most of the updated code, there is nothing printed to the user. Once I’ve finished at least one country then I’ll revise the more confusing parts of the code. Thanks for the help!
It the product that the massive, failure, flowchart produced.
I think that this discussion fits better in this thread, to show off small coding learning projects.
Don’t often check development help, thought it was help for making mods for Python. Thanks for merging, would’ve never known this thread existed.
UPDATE: Changed.
I made a non functioning Hangman. It makes a loop because it isn’t finished. Will be finished (hopefully) on Monday.
Filebin of the .py file (lasts 1 week):
https://filebin.net/nsyk2ttk3zx9fjyp
Source Code
import random
Game = True
while Game == True:
word = [“Array”, “Steam”, “Random”, “Import”, “Empires”, “Of”, “The”, “Undergrowth”, “Spore”, “Myrmecologist”, “Deoxyribonucleic”, “Plague”, “Pulsar”, “Ant”, “Thrive”, “Evolution”, “Ecosystem”, “Genetic”, “Microbe”, “Multicellular”, “Slug”, “Disco”, “Beetle”, “Uprising”, “Paradox”, “Star”, “Emperor”, “Espionage”, “Nemesis”, “Behaviour”, “Interactive”, “Dead”, “By”, “Daylight”, “Trapper”, “Wreith”, “Hag”, “Huntress”, “Myers”, “Shape”, “Nurse”, “Blight”, “Twins”, “Legion”, “Ghost”, “Face”, “Nightmare”, “Spirit”, “Executioner”, “Executioner”, “Pyramid”, “Head”, “Silent”, “Hill”, “Fallout”, “Elder”, “Scrolls”, “Ancestors”, “Humankind”, “Odyssey”, “Human”, “Revolutionary”, “Games”, “Studios”, “Aware”, “Awakening”, “Space”, “Ascended”, “Stage”, “Electronic”, “Arts”, “Hangman”, “Syntax”, “Error”, “Dungeon”, “Community”, “Biology”, “Xenophobia”, “Bacteriophage”, “Prion”, “Virus”, “Bacteria”, “Parasite”, “Agent”, “Gene”, “Disease”, “Microscopic”, “Transmission”, “Symptom”, “Infection”, “Infectivity”, “Lethality”, “Severity”, “Vector”, “Antibody”, “Antibiotics”, “Vaccine”, “Pandemic”, “Epidemic”]
#These are the words that’ll be used
lives = 10
#How many guesses you have
guessedletter = []
#Letters that the user has inputted
wordguess = []
#Shows player how long the word is
playerguess = “”
ChosenWord = random.choice(word).lower()
#The word
joinedWord = “”
for i in ChosenWord:
wordguess.append("?")
#Main
while (lives != 0 and “?” in wordguess):
joinedWord = “”.join(wordguess)
print(joinedWord)
print(“Please input a letter”)
letterinput = input().lower
if letterinput == wordguess:
print(“You got a correct letter, well done.”)
print(wordguess)
letterinput.append(playerguess)
for x in range(len(ChosenWord)):
if playerguess == ChosenWord[x]:
wordguess[x] = playerguess
if playerguess not in ChosenWord:
lives = lives - 1
print(“Do you want to play again? Y or N”)
responce = input()
if responce == “N”:
Game = False
else:
Game = True
The only difference is I fixed a Spelling mistake in the source code but not the file.