Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

no you didn't discourage me, I am actually very greatful you and others here have helped me with habits I hadn't thought about. This is just a lot to take in at once, and I am unsure of how and when I will improve these habits. That shouldn't be my focus right now, I am only 2 or so weeks into python, with a few years of bgt experience. But I am just hoping I live up to the expectations of other coders when I ask for their help in the future. I do not plan on using programming as a career, I just do it for fun in spare time, but I don't want to use bad habits either if I can help it.

URL: https://forum.audiogames.net/post/542531/#p542531




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

no you didn't discourage me, I am actually very greatful you and others here have helped me with habits I hadn't thought about. This is just a lot to take in at once, and I am unsure of how and when I will improve these habits. That shouldn't be my focuus right now, I am only 2 or so weeks into python. But I am just hoping I live up to the expectations of other coders when I ask for their help in the future. I do not plan on using programming as a career, I just do it for fun in spare time, but I don't want to use bad habits either if I can help it.

URL: https://forum.audiogames.net/post/542531/#p542531




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@40I think I did say, somewhere here, that if you can't get rid of globals now, that's fine, you should just be aware that it's bad to have them and try to get rid of them.  But maybe it's worth saying that explicitly.  But what throws most people is that there's not really just an answer to your question in programming.  There's 5 or 10 answers at least, usually more.  And which is best depends only on what you're doing.  SO even among programmers who aren't learning, discussions look like my answers to you, with equally wordy clarifications.Also I have been programming for more than 10 years.  It depends if you count Braille 'N Speak 2000's variant of GWBasic when I was 12, whether or not you can put the more than on my resume, but if we count that it's something like 15.  But I usually stop at 10, because anything older than that is hard to explain to employers.  I feel like I've made you feel discouraged or something.  In actuality I'm one of the oldest people on this site, and I got my start almost before this site even existed.

URL: https://forum.audiogames.net/post/542513/#p542513




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@39 aaa!So much my brain can't compute. I need more growth before I understand a lot of this. Of course I am going to try understanding but I don't think I will get these concepts down correctly until my brain physically ages more. I am not quitting programming, I just can't promise to have a good structure and/or programming mindset yet. I think this is something everyone goes through when starting out. Some advance faster than others, there is nothing wrong with that, I am just slower than some. I want to have a good enough structure to where my credibility and habits are acceptable, but I do not want to expect too much from myself. You are giving me ways things can be done, not saying that I should immediately be doing them, just remember that there are much better ways when I am ready to do them.

URL: https://forum.audiogames.net/post/542503/#p542503




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@39 aaa!So much my brain can't compute. I need more growth before I understand a lot of this. Of course I am going to try understanding but I don't think I will get these concepts down correctly until my brain physically ages more. I am not quitting programming, I just can't promise to have a good structure and/or programming mindset yet. I think this is something everyone goes through when starting out. Some advance faster than others, there is nothing wrong with that, I am just slower than some.

URL: https://forum.audiogames.net/post/542503/#p542503




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@39 aaa!How much my brain can't compute. I need more growth before I understnd a lot of this. O course I am going to try understanding but I don't think I will get these concepts down correctly until my brain physically ages more. I am not quitting programing, I just can't promise to have a good structure and/or programing mindset yet. I think this is something everyone goes through when starting out. Some advance faster than others, there is nothing wrong with that, I am just slower than some.

URL: https://forum.audiogames.net/post/542503/#p542503




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@38Settings probably belong on Game, assuming you have a Game object.  Alternatively they belong on Player.  It depends how you set things up.I wouldn't say that you "put things in a dependency injection".  Dependency injection is a design pattern--it's like saying that you rode in the car factory.  Better to say "I created a Game class".  Don't make classes just so you can do the dependency injection design pattern either: that's like saying you built a skyscraper so you could have a ground floor apartment.  I am not judging in any way, just telling us how to give us more useful information, and how not to end up in a hell of little classes everywhere that each have a couple variables on them that you use once and throw away.  Saying you did a dependency injection sounds cool but says nothing concrete--it's like saying you hammered some nails.  Into what?  For what purpose? What kind of nail? What kind of hammer?A really good model for this is to think about ownership.  Settings "belong" to the class that "owns" them.  For single-player games this could reasonably be the game or the player.  But like, okay, let's say I'm making an online card game.  Online card games aren't simple but they give us enough interesting things that it makes a good thing to talk about.  I might have:An engine, which knows how to make games (and owns the games it makes), offering functionality like listing all in progress games and letting a user connect to one.Users, owned by games, which represent a unique real world person, with things like your name and password.The game, which owns players and holds whose turn it is, and owns a card deck.Card decks, which can have cards drawn from and returned to it, and maintain a count of how many kinds of each card are left.Players, which own a hand and the player's network connection, and have things like the player's name and a link to the user that the player represents.Hands, which own cards, and can do interesting things like tell us whether it contains a 4 of hearts.Cards, which own nothing, but have useful card things on them, like suit and number.In this model, you'd put settings on user because they don't go with games individually.  You'd probably also put a different kind of settings on games because games have settings (like what kind of card game it is, max number of players, etc).  You'd wire everything up so that you give cards the hand they're in, the hand the player it's for, etc.  WHich is the dependency injection design pattern.  This may seem a little confusing in that the things that the hand owns depend on the hand too, but the idea is that you probably always want to ask your parent for things and/or tell your parent about stuff, like letting games ask the engine to stop them and disconnect all the players, for example.The day you get thinking about ownership right, you'll know it.  It's really, really obvious the first time you think through a project and can lay out what the entities are and what thing owns what other thing.  Thing about ownership-style thinking is that once you get it right you have lots of little tiny pieces that can all be worked on individually: in the above example each of the things I listed is a file, and each of the things I listed only needs to know about two other things at most.  Then you can ask a question like "I'm doing this new thing, where do i need to put it so that all the things lower down can get access?" and that's where you put it, and if you're thinking about ownership right it's almost not a question because often there's only a couple right answers.Think about it this way.  For things like coding, you have less memory than your computer.  In college psychology, I was told that you can only remember 7 things in your short term memory at once.  I don't know how true that is, but it still works for this point.  Your job, and what leads to success, is working out how to let you work on part of your program at a time without having to remember that the rest of it exists.For actually loading and saving settings, you will go very far with dictionaries and the json module.  json.dumps can turn dicts into strings, and json.loads can go the other way (plus, once you learn files, there's json.dump and json.load, which take open files instead).

URL: https://forum.audiogames.net/post/542493/#p542493




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be. For reference, the options will load when the main function is called, that is the only place for now. The user will be able to configure them in a menu only accessible via the main menu. But a few options will be able to be changed in game. I may split the options into 2 dictionaries, one for host options when hosting a game, and another for options that won't be related to hosting. Keep in mind this game is not online yet and I do not plan to make it online for awhile, but I will still use the host settings when starting an offline game. Either I could do 2 dictionaries, or make 2 save functions, one that doesn't interfeer with host values. My aim here is for the host of the game to set the settings for everyone else, but of course we don't want to accidentally overwrite everyone else's host settings if at any point they save options. I may also call a load options or load host options function after the online game or when exiting or disconnecting. If I am making this more complicated than i should be let me know.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be. For reference, the options will load when the main function is called, that is the only place for now. The user will be able to configure them in a menu only accessible via the main menu. But a few options will be able to be changed in game. I may split the options into 2 dictionaries, one for host options when hosting a game, and another for options that won't be related to hosting. Keep in mind this game is not online yet and I do not plan to make it online for awhile, but I will still use the host settings when starting an offline game. Either I could do 2 dictionaries, or make 2 save functions, one that doesn't interfeer with host values. My aim here is for the host of the game to set the settings for everyone else, but of course we don't want to accidentally overwrite everyone else's host settings if at any point they save options.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be. For reference, the options will load when the main function is called, that is the only place for now. The user will be able to configure them in a menu only accessible via the main menu. But a few options will be able to be changed in game. I may split the options into 2 dictionaries, one for host options when hosting a game, and another for options that won't be related to hosting. Keep in mind this game is not online yet and I do not plan to make it online for awhile, but I will still use the host settings when starting an offline game. Either I could do 2 dictionaries, or make 2 save functions, one that doesn't interfeer with host values. My aim here is for the host of the game to set the settings for everyone else, ut of course we don't want to accidentally overwrite everyone else's host settings.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be. For reference, the options will load when the main function is called, that is the only place for now. The user will be able to configure them in a menu only accessible via the main menu. But a few options will be able to be changed in game. I may split the options into 2 dictionaries, one for host options when hosting a game, and another for options that won't be related to hosting. Keep in mind this game is not online yet and I do not plan to make it online for awhile, but I will still use the host settings when starting an offline game.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be. For reference, the options will load when the main function is called, that is the only place for now. The user will be able to configure them in a menu only accessible via the main menu. But a few options will be able to be changed in game.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-17 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I have put all of my global variables in a dependency injection. I hope that will do the trick for now. I should focus on settings next. I know they are going to be a dictionary, but should the dictionary be global? Or in its own class? I know how to save and load them, but I am not sure where the best place to put the dictionary would be.

URL: https://forum.audiogames.net/post/542490/#p542490




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@36A module is literally just putting code in another file and importing it.

URL: https://forum.audiogames.net/post/542050/#p542050




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@32 yes but don't use the current one I have provided. I am going to take the advice I have received on this thread and make one that won't result in conflicts later down the line, um hopefully. I feel most comfortable with classes and just making an instance of the class. Better than a module but still not complex. Wish me luck

URL: https://forum.audiogames.net/post/542044/#p542044




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

To hopefully help, and not make things more of a mess, I've made some changes to Lucia's bass_example.py found in examples/3D. All you need to run this are Lucia, a file called audio.ogg and paste this into a file. If you have lucia from git, you can just plop this in if you want, but change the name so you can study them side by side to see what I did.There are probably some better practices than what I've done here, so maybe some critique from others and we can fabricobble something together here. I'm really not much of a coder but this seemed more sensible than what they had.# note> This example needs an @audio.ogg@ file placed in the same directory to run.
import sys, os

sys.path.append(".")

from math import radians
import time
import lucia
import lucia.utils


class Player():
"""
Represents the player in this example.
"""

def __init__(self):
self.direction = 0 # north if this shit ain't weird
self.vector = lucia.utils.rotation.Vector()

def get_coords(self):
return self.vector.coords

def get_direction(self):
return self.direction

def turn_left(self, amt):
"""
Turns the player left the specified amount.
"""

self.direction = lucia.utils.rotation.turnleft(self.get_direction(), amt)

def turn_right(self, amt):
"""
Turns the player right the specified amount.
"""

self.direction = lucia.utils.rotation.turnright(self.get_direction(), amt)

def move(self, desired_direction):
"""
Move player.

Call this as you would lucia.utils.rotation.move()
but without the tuple representing the current coordinates.

"""

self.vector = lucia.utils.rotation.move(self.get_coords(), desired_direction)

player = Player()

def main():
lucia.initialize(audiobackend=lucia.AudioBackend.BASS)

window = lucia.show_window()
current_direction = 0
pool = lucia.audio_backend.SoundPool()


s = pool.play_3d(

os.path.join(os.getcwd(), "audio.ogg"), 5, 5, 0, 10, 10, 0, looping=True
)

# Main Loop
while True:
lucia.process_events()
handle_inputs(current_direction)
listener_x, listener_y, listener_z = player.get_coords()
pool.update_listener_3d(listener_x, listener_y, listener_z, player.get_direction())
time.sleep(0.005)

def handle_inputs(dir):
if lucia.key_pressed(lucia.K_LEFT):
player.turn_left(5)
if lucia.key_pressed(lucia.K_RIGHT):
player.turn_right(5)
if lucia.key_pressed(lucia.K_w):
player.move(player.get_direction())
if lucia.key_pressed(lucia.K_a):
player.move(player.get_direction() - 90)
if lucia.key_pressed(lucia.K_s):
player.move(player.get_direction() + 180)
if lucia.key_pressed(lucia.K_d):
player.move(player.get_direction()+ 90)
if lucia.key_pressed(lucia.K_ESCAPE):
lucia.quit()
if lucia.key_pressed(lucia.K_c):
lucia.output.output(str(player.get_coords()))
if lucia.key_pressed(lucia.K_x):
lucia.output.output(f"facing {player.get_direction()}")

if __name__ == "__main__":
main()

URL: https://forum.audiogames.net/post/542036/#p542036




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@31That's two strategies. Alsop variables in functions are called keyword parameters.  You can find lots of Python tutorials covering them.  Note that they're different than declaring a variable inside a function.  That is:def func(param):
my_var = 5
# stuffIs a variable inside a function.  But:def func(param, my_var = 5):
# stuffIs a parameter with a default value.  But for any function (with default values or no) you can call it likefunc(5, 6)Which is normal, or:func(param = 5, my_var = 6)Which uses keyword parameters.  It is relatively normal in Python to have functions with 10 or 20 parameters, put default arguments on all but one or two of them, and then users call the function specifying the couple required ones and tweaking a couple settings.  Note that parameters with defaults have to comea fter params without defaults:def func(my_var = 5, param):
# stuffIs wrong.But I wouldn't limit yourself to these two strategies for getting rid of globals.  There's tons of options out there.  For example you could do a Dialog class and put all the settings on it, and people wanting to make dialogs make an instance and call my_dialog.show.  I'm just offering examples of how it can be done.If you can't get rid of globals right now, that's okay.   But you should try anyway, and when you fail you should at least know that failing means you're probably not doing it the best way.  There are very few things in programming that almost everyone everywhere in any language agrees are a bad idea, and globals is one of them.

URL: https://forum.audiogames.net/post/541924/#p541924




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Ummm?

URL: https://forum.audiogames.net/post/541912/#p541912




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-16 Thread AudioGames . net Forum — Developers room : Jaidon Of the Caribbean via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Just to clarify here, I haven't red all the posts in hrere, but Zarvox, its OKAY for me to use this in public projects? Or only private tests? Cheers.

URL: https://forum.audiogames.net/post/541906/#p541906




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

after reading a few times, let's see if I understand this correctly. The best way to get rid of globals is putting them as default keyword parameters of functions. If you can't do that, use a dependency injection so that at least the program  won't be able to modify anything it shouldn't be able to.

URL: https://forum.audiogames.net/post/541765/#p541765




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

after reading a few times, let's see if I understand this correctly. The best way to get rid of globals is putting them as keyword parameters. If you can't do that, use a dependency injection so that at least the program  won't be able to modify anything it shouldn't be able to.

URL: https://forum.audiogames.net/post/541765/#p541765




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot.

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot. I have no idea how I am going to do this for my other variables, but if using a globals module is the best thing for me right now I will go with the flow. Unless others are willing to provide more examples of manipulating variables from inside a function. I don't even know what this concept is called, can I please have a term?

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot. I have no idea how I am going to do this for my other variables, but if using a globals module is the best thing for me right now I will go with the flow. Unless others are willing to provide more examples of manipulating variables from inside a function. I don't even know what this concept is called, can I please have a term?My theory: do I put all of my global variables in a class and pass that class to an object like @29?

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot. I have no idea how I am going to do this for my other variables, but if using a globals module is the best thing for me right now I will go with the flow. Unless others are willing to provide more examples of manipulating variables from inside a function. I don't even know what this concept is called, can I please have a term?My theory: do I put all of my global variables in a class and pass that class to an object like @28?

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot. I have no idea how I am going to do this for my other variables, but if using a globals module is the best thing for me right now I will go with the flow. Unless others are willing to provide more examples of manipulating variables from inside a function. I don't even know what this concept is called, can I please have a term?

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is interesting, thanks for the analogies. I ask lots of questions, sometimes dumb ones, but if I don't start asking, I can never learn. And since python is a mainstream language unlike bgt, I have a lot more resources to ask for help, and I do use them a lot. Nevertheless I appreciate everyone's time helping my dumb teenage mind take in complex or at least different logic in new ways I am not use to. Lol.Manipulating variables inside of a function to work in different and still accessible ways is a new thing to me, but I see why it will help a lot. I have no idea how I am going to do this for my other variables, but if using a globals module is the best thing for me right now I will go with the flow. Unless others are willing to provide more eamples of manipulating variables from inside a function. I on't even know what this concept is called, can I please have a term?

URL: https://forum.audiogames.net/post/541760/#p541760




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Also, here is a really good way to look at why I'm so against globals.  Say you come to us for help.  And you give us something like:import globals as gb

# 30 lines of stuff using gbAnd you say "It's broken, I want it to do X, but it does Y".  Then either we maybe spot the problem, or we have to ask you for the other 500 lines of your program to see what might be setting the globals to the wrong values and spend 10 times as long on it or more.Most bad ideas in programming work fine at first.  You find out they're bad ideas because eventually something breaks and the bad idea magnifies the mess, not because the bad idea is what broke it.  Globals are like rocket fuel.  You might get to the moon with them, but one tiny spark is going to blow up the entire rocket.  You'd never put rocket fuel in anything but rockets because it likes to blow things up, and yeah it might power your car for a while, but when it goes it's taking out the whole city block.  Only, to complete this analogy, there are also 5 other ways to get to the moon that don't risk blowing up the astronauts , either.

URL: https://forum.audiogames.net/post/541741/#p541741




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@27No. But users shouldn't be doing that anyway.  If a user wants to change the defaults, they can just:def my_dialog(message):
return dialog(message, my_setting=bla, my_other_setting=bla)And then use my_dialog instead wherever they want a dialog with those settings.  I have it return the other function so that if you ever decided to have dialog start returning something, all the my_dialog variants just start working, too.Changing the defaults goes wrong as soon as two parts of the program try to change them at the same time, at which point it actually depends on the order that files get imported by Python as to which one "wins", and god help you if both spots only change some of them because then you get a nice mix of the values instead of all one or all the other.  So not only did I just get rid of your globals and prevent a bug, I added the ability for different parts of the program to have different sorts of dialogs.Also I missed a bunch of commas between the arguments in 26, if you try that you'll want to add them in.

URL: https://forum.audiogames.net/post/541740/#p541740




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

If I put the variables inside the function itself, will users be able to modify the values and the values stay? For example, in the options, the user sets the default duration to 1500, the extend time to 1500, and wants auto scroll enabled when posible. Could they keep these values stored even though they ar saved in the function itself

URL: https://forum.audiogames.net/post/541736/#p541736




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@25To eliminate the globals in your example, take this part:default_duration=3000
auto_disappear=True
disable_auto_for_message=False
extend_time=3000
request_extra=False
def dialog(message):And turn it into:def dialog(message,
default_duration=3000
auto_disappear=True
disable_auto_for_message=False
extend_time=3000
request_extra=False):Which will work exactly the same except that the caller of the function can now do things like:dialog("hi", auto_disappear = False)It also makes sure that something in one file that's trying to change the dialog settings doesn't mess with something else in another file trying to change the dialog settings, because by putting them in the function you just get the defaults unless they're specified.Then you rename default_duration to duration because it's juskt duration now.  These are called keyword parameters, if you want to be able to Google this.But more generally, at your level of programming globals.py is probably your best bet, just because you are still having trouble with even small stuff.  But the way you get rid of globals is via default function parameters like the above or putting them in a class instead.  You can for example write a Game class, then pass the Game class to all the things in the game when they get created.  Like this:class Game:
def __init__(self):
self.global_thing = 5

class Mob:
def __init__(self, game):
self.game = game

g = Game()
m = Mob(g)This is called dependency injection.  The mob depends on the things stored in the game, so we give it the game, because that's the thing it depends on to exist.  This seems useless, but the thing it lets you do is tell what can modify the globals without having to read the entire program: either something has the ability to touch a game or it doesn't, and if it doesn't it can't go behind the reader's back and do it anyway.  There are more advanced patterns than this, but this is a really basic one to get started with.I think it's also important to distinguish between settings and globals.  If you have a conf.py with a bunch of settings in it that you set before you run it, that's fine, and all the other languages call those constants.  The reason globals are problematic is that when you start writing to them, it becomes literally impossible to figure out what can and can't touch them without reading literally the whole program.To put this in perspective, work's codebase is probably around 10 lines.  We easily have less than 100 globals that are used between multiple files, most of those are hidden behind functions that tightly control access.  Of the variables that aren't used between multiple files, 99% of those are for integrating with our metrics provider.  This isn't some work trade secret either, it's just how big codebases are, because anyone who is using globals all the time didn't get to 10 lines before they went out of business due to all the bugs.

URL: https://forum.audiogames.net/post/541735/#p541735




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@24 I didn't understand much of your message, can you please explain in simpler terms? I did understand that I shouldn't use a module for my globals, so how should I do it then?

URL: https://forum.audiogames.net/post/541733/#p541733




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@23That's much better.  But pulling those globals from the top of the file into function parameters as I demonstrated would make this both more flexible and more readable simultaneously, as you would also gain the ability for anything using this dialog to customize the settings at runtime.For globals importing:importglobals as bshould work.  But the right answer is to not have a globals.py, you're probably just not yet at the point where how to get rid of it is very obvious (but google dependency injection for one good design pattern for it).

URL: https://forum.audiogames.net/post/541732/#p541732




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

here is my redo of the msg, now called dialog. Also I decided not to put this function into the main script, just call msg.dialog()default_duration=3000
auto_disappear=True
disable_auto_for_message=False
extend_time=3000
request_extra=False
def dialog(message):
 duration_timer = timer.Timer()
 total_duration=default_duration
 if request_extra==True:
  total_duration+=extend_time
 if disable_auto_for_message==True:
  auto_disappear=False
 p.play_stationary("sounds/event/action.ogg")
 lucia.output.speak(message)
 duration_timer.restart()
 while 1:
  lucia.process_events()
  vertual_enter_key=False
  if duration_timer.elapsed>=total_duration and auto_disappear==True:
   vertual_enter_key=True
  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE) or vertual_enter_key==True:
   request_extra=False
   if disable_auto_for_message==True
settings.get("auto_disappear")
disable_auto_for_message=False
   break
  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):
   lucia.output.speak(message)
  time.sleep(0.05)This time, I decided to take out the ability to force a message to auto disappear. I found that wasn't a very good option for the user to have no control over. However I still left in the ability to force a dialog not to auto disappear, for important messages and suspense points.Another question, can I import globals.py as gv, so that the reader knows gv stands for a global variable?

URL: https://forum.audiogames.net/post/541727/#p541727




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

here is my redo of the msg, now called dialog. Also I decided not to put this function into the main script, just call msg.dialog()default_duration=3000
auto_disappear=True
disable_auto_for_message=False
extend_time=3000
request_extra=False
def dialog(message):
 duration_timer = timer.Timer()
 total_duration=default_duration
 if request_extra==True:
  total_duration+=extend_time
 if disable_auto_for_message==True:
  auto_disappear=False
 p.play_stationary("sounds/event/action.ogg")
 lucia.output.speak(message)
 duration_timer.restart()
 while 1:
  lucia.process_events()
  vertual_enter_key=False
  if duration_timer.elapsed>=total_duration and auto_disappear==True:
   vertual_enter_key=True
  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE) or vertual_enter_key==True:
   request_extra=False
   if disable_auto_for_message==True
settings.get("auto_disappear")
disable_auto_for_message=False
   break
  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):
   lucia.output.speak(message)
  time.sleep(0.05)This time, I decided to take out the ability to force a message to auto disappear. I found that wasn't a very good option for the user to have no control over. However I still left in the ability to force a dialog not to auto disappear, for important messages and suspense points.

URL: https://forum.audiogames.net/post/541727/#p541727




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

here is my redo of the msg, now called dialog. Also I decided not to put this function into the main script, just call msg.dialog()default_duration=3000
auto_disappear=True
disable_auto_for_message=False
extend_time=3000
request_extra=False
def dialog(message):
 duration_timer = timer.Timer()
 total_duration=default_duration
 if request_extra==True:
  total_duration+=extend_time
 if disable_auto_for_message==True:
  auto_disappear=False
 p.play_stationary("sounds/event/action.ogg")
 lucia.output.speak(message)
 duration_timer.restart()
 while 1:
  lucia.process_events()
  vertual_enter_key=False
  if duration_timer.elapsed>=total_duration and auto_disappear==True:
   vertual_enter_key=True
  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE) or vertual_enter_key==True:
   request_extra=False
   if disable_auto_for_message==True
settings.get("auto_disappear")
disable_auto_for_message=False
   break
  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):
   lucia.output.speak(message)
  time.sleep(0.05)

URL: https://forum.audiogames.net/post/541727/#p541727




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

@21Unpacking is a bad idea with respect to naming because you must then remember what functions are and aren't returning tuples, and what the order of the returned fields is.  Generally you don't unpack in Python when developing bigger things for this reason.   Multiple assignment is fine:health_percent, max_health = player.get_health_percent(), player.get_max_health()because there's no question about mixing up the order.I wouldn't suggest Zarvox do this, but if you yourself want a better way you can use namedtuple or attrs to make lightweight objects that you can return from functions that want to return multiple values.Sometimes unpacking is warranted, for example returning 3d coordinates or when dealing with a function that must execute atomically ALA Django's create or update functionality (which isn't just calling create followed by update if create fails).  But it should be used with incredibly extreme care.  It saves a line or two in the moment, but in the moment almost never matters when programming anything that's meant to last.

URL: https://forum.audiogames.net/post/541726/#p541726




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I mean I think you're overthinking it a bit. I would also map things to dictionaries where it would make sense. Also packing variables where it makes sense.Doing that and unpacking from function, like if I had a function that I knew would return information about the player's health like their current and max, to say, maybe calculate a percentage of their health to take rather than a hard number, I could be like:curhealth, maxhealth = player.get_health()

URL: https://forum.audiogames.net/post/541723/#p541723




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: issue with multiple variables in if statement

You will get better at this through practice, but for starters separate "words" with _.  When using abbreviations,  this makes it clear what is and isn't separated: for example automsg vs. auto_msg.  Note that some of the rest of this is specific to Python, and that in general languages and the communities around them develop conventions.  That said I'm not getting way into Python-specific idiom, and if you go to Rust or C++ or whatever else with these guidelines it'll be fine.Consistency is more important than anything, but functions are usually verb-noun: get_health, not health_get.I haven't picked apart your original code, but also note that globals are bad, not just for the obvious reasons but also because naming them is hard.  Python functions can take keyword arguments with default values:def say(message, loud = False, braille = False, immediate = False):
# stuff

say("hello", loud = True)
say("braille", braille = True)
say("hello", loud = True, immediate = True)If you do it this way it's obvious that the function parameters are for the messaging function and so they don't need to say anything about messaging.  The order doesn't matter as long as the names match.  Other languages will usually have a pattern of some sort for how you handle default arguments to functions; some don't, but the ones that don't have any way to handle it are very much in the minority.  If you want to be even more readable and/or plan to distribute the code to others:def say(message, loud = False, immediate = False, braille = False):
"""Communicate a message through a screen reader interface.

message: The message to say.
loud: If true, also play an alarm.
braille: If true, send this message to a braille display instead.
immediate: If true, interrupt any previous messages.

If no screen reader is present, throws NoScreenReaderError.
"""
# my code here.Which immediately tells you and anyone else what's going on.  Also if you format that right and set up Sphinx that'll give you a nice HTML manual.Python classes are camel case with leading capitals: MyClass.  Errors (things you intend to raise, which inherit from Exception) are MyError, rarely MyException.Long variable names are better than short variable names.  If you're going to use abbreviations, they should always be the same abbreviation for your entire program.Introduce consistent terminology, and use it everywhere.  Where possible, use standard terminology, but if you don't know what it is always at least use the same thing.  For example controls aren't controls in one file and widgets in another file.  For a game example, you shouldn't use npc, mob, enemy, robot, etc. for the things that aren't the player just because.  Npc being a base class for enemy and ally is fine, for example, or robot being special might mean it deserves a term, because in those cases there's a reason for it being different.You should always have a reason for the words you pick, and it shouldn't be just offhand.  If it's a loop variable using i or j is fine. The reason for that is that everyone else in programming land does.  If it's a variable that's going to be used for 2 lines, tmp is fine, because after 2 lines it doesn't matter, and tmp is a good name for something that's going to be used right now and then never again.  But the more code it's going to be in, the more important it is to be able to justify to yourself why you made whatever choice you made.  If it's a function, method, or class it should *always* have a justified name.  If it's going to be used beyond this file it should also be named taking into account that no one wants to play hunt the name to find out what it does.If something is private to a module, class, etc. Python names it like _my_private_function.  This doesn't have any special meaning or anything, it's just convention that lets everyone know you're not supposed to touch it from outside.Never have a variable hold two different types of things.  Don't assign a number and then assign a string later.  While Python allows you to, it's confusing if variables are sometimes one kind of thing and sometimes another.  There is very rarely a good reason but the chances of you encountering them yourself right now are basically nonexistant, I don't have an example offhand, and if I try to give you one it's going to be contrived and probably involve pretty serious metaprogramming stuff that no one does outside libraries.You aren't finding a class or something though because there are no hard and fast rules.  Some of programming is science.  Some of programming is art.  This is the part that's art.  Everyone does this a little bit differently.  It's like learning to speak a second language, a little bit.  The first things you learn are how the for loop works, and that's all well and good, you can get 

Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I need lots of help with better variable names. Obviously there are a lot of variables, how would you come up with a very very descriptive name for each one? How long does it have to be? How specific do I have to get? How do I label my functions with good names? No one teaches a course on this, there really should be one. So yeah, a cry for help. Can I please have some tips? Tips in python please as that is my language.Edit I am reading about it but feedback from here is also welcome.

URL: https://forum.audiogames.net/post/541718/#p541718




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I need lots of help with better variable names. Obviously there are a lot of variables, how would you come up with a very very descriptive name for each one? How long does it have to be? How specific do I have to get? How do I label my functions with good names? No one teaches a course on this, there really should be one. So yeah, a cry for help. Can I please have some tips? Tips in python please as that is my language.

URL: https://forum.audiogames.net/post/541718/#p541718




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I need lots of help with better variable names. Obviously there are a lot of variables, how would you come up with a very very descriptive name for each one? How long does it have to be? How specific do I have to get? How do I label my functions with good names? No one teaches a course on this, there really should be one. So yeah, a cry for help. Can I please have some tips?

URL: https://forum.audiogames.net/post/541718/#p541718




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I need lots of help with better variable names. Obviously there are a lot of variables, how would you come up with a very very descriptive name for each one? How long does it have to be? How specific do I have to get? How do I label my functions with good names? No one teaches a course on this, there really should be one

URL: https://forum.audiogames.net/post/541718/#p541718




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

"code" in square brackets, followed by your code, then closed with "/code" in square brackets.

URL: https://forum.audiogames.net/post/541661/#p541661




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Ok, I will try. I installed vs code, will give it a try. What is the bb code block to display my indentation correctly?

URL: https://forum.audiogames.net/post/541659/#p541659




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Ok, I ill try. I installed vs code, will give it a try. What is the bb code block to fix my indentation?

URL: https://forum.audiogames.net/post/541659/#p541659




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector


  


Re: issue with multiple variables in if statement

The first and easiest step is to simply not use so many abbreviations. time_duration, extend_time, enable_autoscroll, request_time are precise and clear names, for example. As said before, this looks like writing lots and lots of unnecessary stuff, but by using a code editor like VS Code, you don't have to type your names all the time. Then I would try to simplify your variables. Maybe I am not getting something here, but having two booleans, yesauto and noauto, really makes not much sense and yesauto and noauto are also the worst variable names in your example. It's generally good practice to comment unclear code for other people, but it's even better practice to make the code itself clearer and delete the comments.

URL: https://forum.audiogames.net/post/541649/#p541649




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

It is its own code editor, there's every reason to use it and really no downside to it.

URL: https://forum.audiogames.net/post/541633/#p541633




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

does vs code work with regular notepad, and what is the syntax for this bbc block to fix my indentation? What variable names are confusing to y'all, are any of them clear? Which ones are good, which ones aren't

URL: https://forum.audiogames.net/post/541628/#p541628




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Lets see:def func1():
if not True:
print("This will never trigger!")

#Now we switch indenting schemes to see if it works with spaces.
def func2():
if True:
print("This will always trigger!")Edit: Interesting. The first function used tabs when I was writing it, but it appears that the forum replaces that with 4 spaces.

URL: https://forum.audiogames.net/post/541614/#p541614




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Lets see:def func1():
if not True:
print("This will never trigger!")

#Now we switch indenting schemes to see if it works with spaces.
def func2():
if True:
print("This will always trigger!")

URL: https://forum.audiogames.net/post/541614/#p541614




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I didn't know if the code thing did anything here. I've used it before, but on other forums, it makes a scrollable box and sometimes gives line numbers and stuff. Here, there is no noticeable effect that I could see.

URL: https://forum.audiogames.net/post/541599/#p541599




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector


  


Re: issue with multiple variables in if statement

not to mention that using more descriptive names doesnt even take more hassle. just use an editor that has autocompletion. vs code is super accessible and great support for python. you just need to write the whole variable name once and then you just write a couple letters  and press tab to accept a completion suggestion.the reason noone has helped you anser your question is because the code you provided is clearly malformed and the bad variable names make it impossible to follow.

URL: https://forum.audiogames.net/post/541596/#p541596




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

When pasting/writing source code, the forum provides a BBCode block you can enclose it in. Just a note to solve all this indenting stuff.

URL: https://forum.audiogames.net/post/541585/#p541585




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Yes, the indentation is wrong, also there is no colon after the def main() line.Oh and a small tip: If I were you, I would use much more expressive variable names. When you or another person comes back to this in a year or so, it's very hard to understand names like dmsg, reqx or p. I know, it's very tedious, but giving clear names which say exactly what the variable in question stores is very important for understanding your own code and finding bugs.

URL: https://forum.audiogames.net/post/541432/#p541432




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: issue with multiple variables in if statement

For naming conventions, it’s not just about you. It’s about us when we have to help you. I have difficulty following your code because there is no indenting and because of the nonsensical variable names.  It’s not a question of if you understand, it’s a question of if we follow and how easy would it be for us to do so. Also, just because you can read it now doesn’t mean that you could read this in two years. Granted you will scrap this during that time as you learn more and more about the language, but that’s beside the point. Suppose that you didn’t.

URL: https://forum.audiogames.net/post/541542/#p541542




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

it wasn't indented at all inside that function block, not talking about tavs vs. spaces or which level of indent you used, after that function definition, it was flat.If you know a variable is going to be a boolean, or something that will have a truth value, you can use that shortcut.Let's say I made a function on a player class that just returns True or False. I can do either one of the following.if player.has_weapon("AK-47"):  passOr I could doif not player.has_weapon("AK-47"):  passEach one of these is just a shorter way of writingif player.has_weapon("AK-47") == True:  passorif player.has_weapon("AK-47") == False:  passYou can also treat bools like flags and flip them like this:lightswitch = not lightswitchThen you can with one line output the state of the flag you just flippedpreamble = "lights "  # combined with state msg belowlucia.output.speak(preamble+"on" if lightswitch else preamble+"off")

URL: https://forum.audiogames.net/post/541501/#p541501




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

anyway back to the original question, why are multiple conditions blocked in my if statement during a while loop unless there is a key_pressed function before it?

URL: https://forum.audiogames.net/post/541497/#p541497




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector


  


Re: issue with multiple variables in if statement

That is of course your decision in the end, but giving clear variable names is one of the first rules of writing clean code (professionally). I think it's often better to start using widely accepted conventions very early, instead of having to relearn it later if you ever work on a larger software project, maybe even in a team.

URL: https://forum.audiogames.net/post/541467/#p541467




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Hm... From what I can tell, the auto-delay code doesn't actually do anything. reqx is initially set to False, and there's a bit at the start of the msg() function that checks that if reqx is True to extend the delay. But in the while loop section, there's no code or trigger that actually sets reqx to True, so if force==True, it sets reqx to False, but this doesn't matter because its never set to True anyway, so nothing happens.

URL: https://forum.audiogames.net/post/541444/#p541444




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I added a tab instead of space for first level, but now it shows up as 3 spaces for first level, and 2 spaces for second. If that confuses you even more let me know.I tried the not equal to instead of == and it made no difference.

URL: https://forum.audiogames.net/post/541441/#p541441




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

I added a tab instead of space for first level, but now it shows up as 3 spaces for first level, and 2 spaces for second. If that confuses you even more let me know

URL: https://forum.audiogames.net/post/541441/#p541441




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


issue with multiple variables in if statement

I built a function in python that allows the user to receive a message like dlg in bgt. They can press enter or space to continue, or they can set a diration for it to automatically disappear. The manual method works, however the auto method won't execute my code. Code is below, and feel free to use this function if you want.in msg.py.#starting valuedmsg=3000#auto scrollautomsg=True#disable auto for 1 messagenoauto=False#enable auto for 1 messageyesauto=False#add more timeextend=3000#request the extra timereqx=Falsein main.py.import timeimport pygameimport luciafrom lucia.utils import timerimport msg as tdif lucia.running==False: lucia.initialize()p = lucia.audio_backend.SoundPool()def main():    lucia.show_window("game")    while 1:  lucia.process_events()  if lucia.key_pressed(pygame.K_SPACE):   msg("testing")   lucia.output.speak("test successful")def msg(message):#total time    tmsg=td.dmsg    mt = timer.Timer()#if auto is off but this message should be auto, turn it on for one message    if td.yesauto==True:  td.automsg=True  td.noauto=False#if requested, add on additional time    if td.reqx==True:  tmsg+=td.extend    p.play_stationary("sounds/event/action.ogg")    lucia.output.speak(message)    mt.restart()    while 1:  lucia.process_events()#a variable to virtually press enter  force=False#if the timer has elapsed, and auto is on, and no auto for this message is off, automatically disappear#this is the code that does not execute  if mt.elapsed>=tmsg and td.automsg==True and td.noauto==False:   force=True#manual continue  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE) or force==True:#turn off request for next message   td.reqx=False#if auto was turned off for this message only, turn it back on   if td.noauto==True:    td.noauto=False#if auto is only turned on for this message, turn it off again   if td.yesauto==True:    td.automsg=False   break  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):   lucia.output.speak(message)  time.sleep(0.05)main()

URL: https://forum.audiogames.net/post/541370/#p541370




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

#post 3 the indentation is wrong in the post because I use spaces not tab and one level indentation on the forum does not like that for some reason. I didn't paste the actual main function I am using, that is an example main, but I will add the colon anyway. I have a good memory, so the variable names aren't confusing for me, sorry that is it weird to others, I can explain it in more detail and change the names if you are planning on using this function.@@post 2 I will try not equal to. Or statements won't work because I need all 3 to be checked, not either of the 3.

URL: https://forum.audiogames.net/post/541437/#p541437




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: issue with multiple variables in if statement

#post 3 the indentation is wrong in the post because I use spaces not tab and one level indentation on the forum does not like that for some reason. I didn't paste the actual main function I am using, that is an example main, but I will add the colon anyway. I have a good memory or the variable names aren't confusing for me, osorry that is it weird to others, I can explain it in more detail and change the names if you are planning on using this function.@@post 2 I will try not equal to. Or statements won't work because I need all 3 to be checked, not either of the 3.

URL: https://forum.audiogames.net/post/541437/#p541437




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-15 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector


  


Re: issue with multiple variables in if statement

Yes, the indentation is wrong, also there is no colon after the def main() line.Oh and a small tip: If I were you, I would use much more expressive variable names. When you or another person comes back to this in a year or so, it's very hard to understand names like dmsg, reqx or p. I know, it's very tedious, but clear names which say exactly what the variable in question stores is very important for understanding your own code and finding bugs.

URL: https://forum.audiogames.net/post/541432/#p541432




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: issue with multiple variables in if statement

2020-06-14 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: issue with multiple variables in if statement

looks like no indent in your def (msg):Also you can do if not thing: as well so you don't need to do if thing == bla or oif thing != bla.Could be more but I only glanced.

URL: https://forum.audiogames.net/post/541399/#p541399




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


issue with multiple variables in if statement

2020-06-14 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


issue with multiple variables in if statement

I built a function in python that allows the user to receive a message like dlg in bgt. They can press enter or space to continue, or they can set a diration for it to automatically disappear. The manual method works, however the auto method won't execute my code. Code is below, and feel free to use this function if you want.in msg.py.#starting valuedmsg=3000#auto scrollautomsg=True#disable auto for 1 messagenoauto=False#enable auto for 1 messageyesauto=False#add more timeextend=3000#request the extra timereqx=Falsein main.py.import timeimport pygameimport luciafrom lucia.utils import timerimport msg as tdif lucia.running==False: lucia.initialize()p = lucia.audio_backend.SoundPool()def main() lucia.show_window("game") while 1:  lucia.process_events()  if lucia.key_pressed(pygame.K_SPACE):   msg("testing")   lucia.output.speak("test successful")def msg(message):#total time tmsg=td.dmsg mt = timer.Timer()#if auto is off but this message should be auto, turn it on for one message if td.yesauto==True:  td.automsg=True  td.noauto=False#if requested, add on additional time if td.reqx==True:  tmsg+=td.extend p.play_stationary("sounds/event/action.ogg") lucia.output.speak(message) mt.restart() while 1:  lucia.process_events()#a variable to virtually press enter  force=False#if the timer has elapsed, and auto is on, and no auto for this message is off, automatically disappear#this is the code that does not execute  if mt.elapsed>=tmsg and td.automsg==True and td.noauto==False:   force=True#manual continue  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE) or force==True:#turn off request for next message   td.reqx=False#if auto was turned off for this message only, turn it back on   if td.noauto==True:    td.noauto=False#if auto is only turned on for this message, turn it off again   if td.yesauto==True:    td.automsg=False   break  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):   lucia.output.speak(message)  time.sleep(0.05)main()

URL: https://forum.audiogames.net/post/541370/#p541370




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


issue with multiple variables in if statement

2020-06-14 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


issue with multiple variables in if statement

I built a function in python that allows the user to receive a message like dlg in bgt. They can press enter or space to continue, or they can set a diration for it to automatically disappear. The manual method works, however the auto method won't execute my code. Code is below, and feel free to use this function if you want.in msg.py.#starting valuedmsg=3000#auto scrollautomsg=True#disable auto for 1 messagenoauto=False#enable auto for 1 messageyesauto=False#add more timeextend=3000#request the extra timereqx=Falsein main.py.import timeimport pygameimport luciafrom lucia.utils import timerimport msg as tdif lucia.running==False: lucia.initialize()p = lucia.audio_backend.SoundPool()def main() lucia.show_window("game") while 1:  lucia.process_events()  if lucia.key_pressed(pygame.K_SPACE):   msg("testing")   lucia.output.speak("test successful")def msg(message):#total time tmsg=td.dmsg mt = timer.Timer()#if auto is off but this message should be auto, turn it on for one message if td.yesauto==True:  td.automsg=True  td.noauto=False#if requested, add on additional time if td.reqx==True:  tmsg+=td.extend p.play_stationary("sounds/event/action.ogg") lucia.output.speak(message) mt.restart() while 1:  lucia.process_events()#if the timer has elapsed, and auto is on, and noauto is off, automatically disappear#this is the code that does not execute  if mt.elapsed>=tmsg and td.automsg==True and td.noauto==False:#if more time was requested, reset the time and disable request   if td.reqx==True:    tmsg=td.dmsg   td.reqx=False#if auto is only turned on for this message, turn it off again   if td.yesauto==True:    td.automsg=False   break#manual continue#same code as above because above does not have forced_key_down support like bgt  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE):   if td.reqx==True:    tmsg=td.dmsg   td.reqx=False#if auto was turned off for this message only, turn it back on   if td.noauto==True:    td.noauto=False   if td.yesauto==True:    td.automsg=False   break  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):   lucia.output.speak(message)  time.sleep(0.05)main()

URL: https://forum.audiogames.net/post/541370/#p541370




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


issue with multiple variables in if statement

2020-06-14 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


issue with multiple variables in if statement

I built a function in python that allows the user to receive a message like dlg in bgt. They can press enter or space to continue, or they can set a diration for it to automatically disappear. The manual method works, however the auto method won't execute my code. Code is below, and feel free to use this function if you want.in msg.py.#starting valuedmsg=3000#auto scrollautomsg=True#disable auto for 1 messagenoauto=False#enable auto for 1 messageyesauto=False#add more timeextend=3000#request the extra timereqx=Falsein main.py.import timeimport pygameimport luciafrom lucia.utils import timerimport msg as tdif lucia.running==False  lucia.initialize()def main() lucia.show_window("game") while 1:  lucia.process_events()  if lucia.key_pressed(pygame.K_SPACE):   msg("testing")   lucia.output.speak("test successful")def msg(message):#total time tmsg=td.dmsg mt = timer.Timer()#if auto is off but this message should be auto, turn it on for one message if td.yesauto==True:  td.automsg=True  td.noauto=False#if requested, add on additional time if td.reqx==True:  tmsg+=td.extend p.play_stationary("sounds/event/action.ogg") lucia.output.speak(message) mt.restart() while 1:  lucia.process_events()#if the timer has elapsed, and auto is on, and noauto is off, automatically disappear#this is the code that does not execute  if mt.elapsed>=tmsg and td.automsg==True and td.noauto==False:#if more time was requested, reset the time and disable request   if td.reqx==True:    tmsg=td.dmsg   td.reqx=False#if auto is only turned on for this message, turn it off again   if td.yesauto==True:    td.automsg=False   break#manual continue#same code as above because above does not have forced_key_down support like bgt  if lucia.key_pressed(pygame.K_RETURN) or lucia.key_pressed(pygame.K_SPACE):   if td.reqx==True:    tmsg=td.dmsg   td.reqx=False#if auto was turned off for this message only, turn it back on   if td.noauto==True:    td.noauto=False   if td.yesauto==True:    td.automsg=False   break  if lucia.key_pressed(pygame.K_UP) or lucia.key_pressed(pygame.K_DOWN) or lucia.key_pressed(pygame.K_LEFT) or lucia.key_pressed(pygame.K_RIGHT):   lucia.output.speak(message)  time.sleep(0.05)main()

URL: https://forum.audiogames.net/post/541370/#p541370




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector