2020-12-31 21:39:01

@75 you're technically not supposed to import packages outside your project scope like that...

Follow on twitter! @masonasons_me
Thanks, enjoy, thumbs up, share, like, hate, exist, do what ya do,
my website: masonasons.me
Follow my telegram channel for real time updates: https://t.me/masonasons_me

2021-01-01 00:17:16

Oh damn, OK I'll dump the examples folder inside it.

Join me in eliminating BGT from the forum.
It's very easy, if you see a topic about BGT, simply don't reply to it.
If you're thinking about creating a topic about BGT, just don't.
Doing these things will cause all such topics to sink to oblivion.

Thumbs up

2021-01-05 18:40:20

Hi all, i am not sure if i am using this map class the right way, but here is the error:
NameError: name 'type_3d' is not defined                                                                               
And here is the code:
main_map=map.map(type=type_3d, tile="grass", maxx=100, maxy=100, maxz=100)

Can any one please tell me what i am doing wrong?

best regards
never give up on what ever you are doing.

2021-01-05 18:55:44 (edited by bhanuponguru 2021-01-05 18:56:40)

try using map.type_3d because as far as i remember, these variables are declared in map file where map class is written. so, use map.type_3d

if you like this post, please thum it up!
if you like to see my projects, feel free to check out my github
if you want to contact me, you can do here by skype. or you can follow me on twitter: @bhanuponguru
discord: bhanu#7882

Thumbs up +1

2021-01-05 18:58:08

Hi there, thanx a lot. I only realised that while i was eating, but thanx a lot

best regards
never give up on what ever you are doing.

2021-01-05 19:14:20 (edited by ashleygrobler04 2021-01-05 19:16:11)

Hi all, sorry for the double post, but i am facing another error, I am not sure what i am doing wrong here, since i am filling in all the propperties that the map class requires to get the tile of the player, here is the code and the error.
Sorry for the issues i might cause by asking...
def play_step():
    player.pool.play_stationary("sounds/"+main_map.get_tile_at(me.x,me.y,me.z)+str(random.randint(1,5))+".mp3",False)

TypeError: get_tile_at() takes 1 positional argument but 4 were given

Thanx
And the type is equal to type_3d. so i don't understand why it tells me that map.get_tile_at () only takes 1 arguement, when it takes 3 if the type is equal to type_3d.

best regards
never give up on what ever you are doing.

2021-01-05 19:19:06

sorry for the tripple post, but i believe it would be the last for the night, but i fixed it by doing the following:
get_tile_at(x=me.x,y=me.y,z=me.z) and it worked.

best regards
never give up on what ever you are doing.

2021-01-05 19:43:43

Yup, that's **kwargs for you. smile

2021-01-05 20:00:55

@83, it confuzed me untill i saw it was kwargs...
I am so use to every thing being propperties.

best regards
never give up on what ever you are doing.

2021-01-06 03:55:19

Yeah, I actually don't know why he used Kwargs. I might actually open a PR fixing that. You can give Python default values for variables, and AFAIK the code checks for the type before using them. Either way, I can probably fix that, without breaking everything, as I think Python let's you provide variable names when providing parameters even without using Kwargs.

2021-01-06 12:06:56

Yeah, it would be cool. thanx

best regards
never give up on what ever you are doing.

2021-01-06 19:41:08 (edited by ashleygrobler04 2021-01-06 19:51:38)

Hi all.
So today i am facing a new problem:
I am using a sound_manager to play a sound in 3d, and updating it also.
So here is what i am doing:
I say player.pool.play_3d("sounds/test.mp3", sound_x, sound_y, sound_z, False)
then i say player.pool.update_3d(player.pool, sound_x, sound_y, sound_z)
How ever if i execute my code, the sound plays on the right even though the position of the sound is at the exact same position as the player is at.
Can any one please tell me why it is doing that?
As far as i am consurned, if the sound's position is at the exact same position as the player, it should play infront of the player. not to the right...
And i do have code to check that the sound of the 3d is at the player's co ordinates. I am basicly coding a camera to move around. I am not sure...
Can any one please tell me if i done some thing wrong or is there some thing i am missing?
Oh and edit:
The reason why i used player.pool.update_3d(player.pool,sound_x,sound_y,sound_z) is because in the readme it told me that sound_manager.play_3d returns a slot for later use. I can't seem to figure out how to access the slot.

best regards
never give up on what ever you are doing.

2021-01-07 06:15:46 (edited by bhanuponguru 2021-01-07 06:17:06)

@87
in order to get to slot, you do like
s=player.pool.play3d('sound', x, y, z)
and, i hate to tell people to use this without explaination. so, i will give you explaination
when ever you call play3d, it will return a value. you can experiment with a python terminal. if you set a variable, say if play3d returns a value 3, then if you set variable while calling it, that is s=play3d('sond', x, y, z), the s variable will bee 3.
i can't remember exactly if this sound pool returns an integer value for slot or sound like object, but this is how it works.
and while updating, use s as first parameter

if you like this post, please thum it up!
if you like to see my projects, feel free to check out my github
if you want to contact me, you can do here by skype. or you can follow me on twitter: @bhanuponguru
discord: bhanu#7882

Thumbs up

2021-01-07 11:56:45

Oh, i just got a bit confuzed, I thought the read me told me that it returns a slot for later use.

best regards
never give up on what ever you are doing.

2021-01-07 17:46:06

@89
If this is anything like BGT sound pool, then post 88 should be correct. Consider this:

def do_something(n=None):
    if n is not None:
        return n * 2
    return 1

If you call do_something without an integer, it returns 1. That one is the proverbial slot. Calling the function again and passing in that slot will cause you to get the powers of two, I.e, 2, 4, 8, 16, etc. So, when the sound pool "returns a slot", it's a fancy way of saying that the function returns a value which you could use later in some other function call.
To hopefully clear it up, consider this:

x = do_something()
print(x) #1
x = do_something(x)
print(x) #2
x = do_something(x)
print(x) #4

The code above reuses the function values, the slots, if you will, to obtain a different result. This is not what the sound pool does (you only need slots for updating sound ranges if memory serves), but the gist remains the same.

Thumbs up

2021-01-07 20:59:18

@90, thanx. it makes a little more sence now.

best regards
never give up on what ever you are doing.

2021-01-08 01:56:13

I feel the need to point out that you'd all have way less problem with this stuff if you'd just include type hints.

I know they're a drag if you're not used to them, but honestly my Python game has gone way up since I started treating it like a typed language. MyPy's not perfect, but it's pretty good.

Take care,
Chris Norman
Selling my soul to andertons.co.uk since 2012.

2021-01-08 03:25:41

@92, I'm a Swifter myself, but hardly see how it helps in the case of Python. Can you explain what you mean?

2021-01-08 10:15:32

fully agree with @92. type hints really help disambiguate what data type is expected for an argument. taking a quick look at the API of framework, I am afraid that much of it would be impossible to type hint anyway though. which is a common problem with dynamically typed libraries where the API is designed without typing in mind. what I mean in the case of framework is for example the map function, which takes a type parameter, and then based on what the type is, takes different kwargs. so it isn't possible to directly type hint that function. although you could still provide a typed version by exposing 3 wrappers for each type of map like so:

def map_1d(max: int) -> Map:
  return map(type = type_1d, max = max)

def map_2d(max_x: int, max_y: int) -> Map:
  return map(type = type_2d, max_x = max_x, max_y = max_y)

... and so on. this would also have the benefit that you could pass all arguments positionally, instead of having to refer to them by name for kwargs, as Turret pointed out.

Thumbs up

2021-01-08 20:01:29

Hi all, so sorry once again, this time i think i have a lot of code but i am facing an issue, which i can't fix, even after trying multiple times.
The issue is that I am trying to make a camera for the game i am working on.
How ever, when i use the camera, the sound does not play relatively to the player's position.
Here is the code for those who wants to obviously read, please do note that it's quite long...
def camloop():
    if window.key_pressed(window.K_x) and vars.active==True:
        speech.speak("cam co ords are at "+str(vars.cam_x)+", "+str(vars.cam_y)+", "+str(vars.cam_z))
    if window.key_pressed(window.K_UP) and vars.active==True and vars.cam_y <100:
        vars.cam_y+=1
        s=player.pool.play_3d("sounds/"+main_map.get_tile_at(x=vars.cam_x,y=vars.cam_y,z=vars.cam_z)+str(random.randint(1,5))+".mp3",vars.cam_x,vars.cam_y,vars.cam_z,False)
        player.pool.update_3d(s,vars.cam_x,vars.cam_y,vars.cam_z)
    elif window.key_pressed(window.K_DOWN) and vars.active==True and vars.cam_y > 0:
        vars.cam_y-=1
        s=player.pool.play_3d("sounds/"+main_map.get_tile_at(x=vars.cam_x,y=vars.cam_y,z=vars.cam_z)+str(random.randint(1,5))+".mp3",vars.cam_x,vars.cam_y,vars.cam_z,False)
        player.pool.update_3d(s,vars.cam_x,vars.cam_y,vars.cam_z)
    elif window.key_pressed(window.K_LEFT) and vars.active==True and vars.cam_x > 0:
        vars.cam_x-=1
        s=player.pool.play_3d("sounds/"+main_map.get_tile_at(x=vars.cam_x,y=vars.cam_y,z=vars.cam_z)+str(random.randint(1,5))+".mp3",vars.cam_x,vars.cam_y,vars.cam_z,False)
        player.pool.update_3d(s,vars.cam_x,vars.cam_y,vars.cam_z)
    elif window.key_pressed(window.K_RIGHT) and vars.active==True and vars.cam_x < 100:
        vars.cam_x+=1
        s=player.pool.play_3d("sounds/"+main_map.get_tile_at(x=vars.cam_x,y=vars.cam_y,z=vars.cam_z)+str(random.randint(1,5))+".mp3",vars.cam_x,vars.cam_y,vars.cam_z,False)
        player.pool.update_3d(s,vars.cam_x,vars.cam_y,vars.cam_z)
    elif window.key_down(window.K_g) and vars.active==False:
        vars.active=True
        vars.cam_x=me.x
        vars.cam_y=me.y
        vars.cam_z=me.z
    elif window.key_up(window.K_g) and vars.active==True:
        vars.active=False
        vars.cam_x=me.x
        vars.cam_y=me.y
        vars.cam_z=me.z
        player.pool.update_3d(player.pool,vars.cam_x,vars.cam_y,vars.cam_z)

best regards
never give up on what ever you are doing.

2021-01-09 02:49:56 (edited by amerikranian 2021-01-09 02:55:38)

I am going to be very, very diplomatic, or try to. This engine is bad. Like, really bad. The only thing this offers is the synthizer sound pool, and even then this could be done more cleanly.
I'll go down the list:

#data.py
iv="flajef8ejri3l25m"

So first, the supposed encryption function maintains a constant IV. I'm not an expert on Cryptography, but I am positive that this is really, really bad. Check this out, the answer in particular, to get a bit more info on what this is and why should you care. But... fine.

def directory_create(path):
    try:
        os.mkdir(path)
        return True
    except:
        return False

Throughout the code, the employed except statements are mostly vague and often silently fail. It is very common to see a "except: pass" within the engine, which can be kind of frustrating when debugging. Also, this is a wrapper over os.mkdir, which kind of defeats the whole purpose of the function. It's much more easier for me to go thus:

if not os.path.isdir(path):
    os.mkdir(path)

That, unfortunately, summarizes about half of the "engine".
find_recursive can be easily surpassed with regex or your own loop, again.
file_copy and file_delete are perhaps the only functions one does not have an easy access to in Python. file_put_contents is just an unneeded wrapper once again, and the encrypt and decrypt functions are flawed do to the constant IV. Savedata class could be useful I suppose, but I personally feel like this is too narrow in scope. One would have a hard time saving game state or anything of substance using this approach.
From now on, I'll provide comments for the files as a whole.
map.py and its type_2d and type_3d serve zero purpose. Besides employing kwargs 99% of the time, something which causes code repetition, the falsy typing of the map serves only to confuse the reader and doesn't allow it to gain more features. Why not use positional args and provide default values?
menu3d.py is only useful until you realize that you can't do any kind of design pattern with it because, surprise, it takes control of your main loop.
sound3d.py serves as a painful reminder that this was taken from BGT

    def get_id(self):
        id=random.randint(100000000, 999999999)
        tries=0
        while self.get_item(id)!=0 and tries<500:
            id=random.randint(100000000, 999999999)
            tries+=1
        if tries>=500: return -1
        return id

This speaks of the lack of understanding about what classes are. Why not discard the idea of slots entirely and return newly-created objects and change the update functions to work with them directly? If you are that intent on using IDs, why not have an index which you increment every time you append the sound to the list? You can then use said value as the new ID and mitigate the, although insignificant, chance of your get_id function failing. Your fade functions once again steal the main loop. What if I want to do something else while the sound fades out? I'd have to modify the engine to support callbacks... but at that point I just won't use it.
Also, what do these lines do? Do they actually work as expected?

#update_3d
i.handle.source.position=(x,z,y) #Do you have coordinates switched?
#play_1d
return self.play_3d(filename,x,4,0,looping,verb)
What is this magical 4 constant?

Speech.py worths mentioning because it once again, provides a wrapper over a wrapper which serves absolutely zero purpose
Timer and window -- the essential components of your engine -- are lifted straight from Lucia, which brings me to the point of this post: Why not offer what you've made as contributions to the Lucia repo? Calling this "tools" is a stretch especially when so much of the essential features are from another engine. Please, do us all a favor, clean and merge your actual creations (excluding data.py for the reasons mentioned above) to the Lucia repository.
TLDR: Avoid this and use Lucia instead if you must... or just switch directly to pygame and cytolk. It's not hard, folks.

Thumbs up

2021-01-09 07:30:59

agreed with @96
i really wan;t to help lucia 2.0. but i cannot unless some part of the repo is completed because if some parts are completed like output etc, then i know in what patern lucia codes stuf. i am really happy to contribute to lucia once i find required info.

if you like this post, please thum it up!
if you like to see my projects, feel free to check out my github
if you want to contact me, you can do here by skype. or you can follow me on twitter: @bhanuponguru
discord: bhanu#7882

Thumbs up

2021-01-09 13:03:14

@95 sorry but your code is a bit hard to read because there seems to be a problem with indentation. for example, every line beginning with
s=player.pool.play_3d...
has no indentation so it isn't clear if that is intentional or just a problem with how it was copied over to your post.

also your code has a lot of repetition, which makes it hard to figure out the logic of it. each s=player.pool.play_3d and call to player.pool.update_3d is just copy pasted in each arm of the if/else chain. instead it would be much simpler and less repetitive to handle changing your vars in the if/else chain and then afterwards just call play_3d and update_3d after the if/else chain.

also as a small side note, it would be a good idea to not have vars be a global variable, but to instead pass it in explicitly to the function.

Thumbs up

2021-01-09 13:19:14

@96 I agree with some of your points, but statements like "Please, do us all a favor, clean and merge your actual creations (excluding data.py for the reasons mentioned above) to the Lucia repository." are completely inappropriate. instead of providing constructive criticism on how this codebase can be improved you just point at things to say see how bad this engine this is? just use my thing instead! and then you tell the author to do everyone (or do you mean just you) a favor and to abandon their project and contribute to yours instead...

other open source projects are free to depend on other open source projects like lucia. you would probably do well to get to grips with it. hijacking someone elses thread with inflammatory unconstructive comments is extremely disrespectful and reflects on your level of maturity.

Thumbs up

2021-01-09 17:31:12 (edited by amerikranian 2021-01-09 17:38:08)

@99, I think you have me confused with someone else. I am in no major form or fashion a developer of Lucia, I've contributed to it, but that's as far as I've gone. I encouraged contributions to Lucia because, as my post stated, a good chunk of features use it anyways, are directly in the engine itself (menu), will possibly require their own solutions depending on the constraints of your project (map), or contain vulnerabilities which one may not necessarily be aware of (data). Taking out all the fluff reveals sound3d, which can, and should, be improved. My statement of "Please do everyone a favor" was just that, a request to clean up the sound3d class. In no way was it intended to spark animosity, though in retrospect I realize that this was difficult to recognize from simple text.
As for pointing out "all the bad things," again, not quite correct. I did mention that sound3d was decent, we did not have a high level wrapper over Synthizer, which this topic provided. My biggest peeve perhaps is the unnecessary inclusion of components within the framework and the redundancy of wrapper functions.
I have no issue with open source depending on open source. That is the whole point -- to be able to utilize what others wrote within your own code. I do have an issue with the level of misdirection provided within the topic. If I recall correctly, Lucia is planning to switch to Synthizer as its base sound system and cytolk as its speech output method. The sound3d class and the speech.py module could have greatly assisted in this transition. Instead, the author chose to split off and provide his own option, one that, when discarding the argument of design patterns and globals, still lacks the features offered by Lucia. So, one must pose the question: Why? Why offer a "new" option and not try and improve the one already available, especially when your project ends up heavily relying on the available open source code and still lacks some of the old project’s features.

Thumbs up