Povstalec / StargateJourney

A repository for the Stargate Journey Minecraft Mod
39 stars 16 forks source link

about the isStargateDialingOut cc method #90

Open C4PTRAMPAGE opened 3 months ago

C4PTRAMPAGE commented 3 months ago

isStargateDialingOut only returns true if the stargate is connected and returns false instead of nil if all chevrons are idle, is that intentional?

heres a look at the dialing program main menu 2024-03-15_09 40 09 your new dhd gui is great by the way!

lukaskabc commented 3 months ago

yes, it should always return bool
true if stargate is connected and it is outgoing connection = this gate dialed = it is safe to enter
false otherwise

Edit:
wiki:

Returns true if the Stargate is currently dialing out, otherwise (if Stargate isn't connected or the connection is incoming) returns false.

nice UI btw

C4PTRAMPAGE commented 3 months ago

thanks,

the reason i ask in that isStargateDialingOut would be a lot more useful if it could return false if >= 1 chevrons are active so that an alarm or other security that needs to be activated before the wormhole is established has time to do so and if it returned nil if no chevrons were active it'd help with checks as well

lukaskabc commented 3 months ago

so you are looking for getChevronsEngaged() ?

but yes I agree, there is no "absolute" way how at specific moment in time say, if chevrons are engaged for incomming or outgoing (not yet formed) connection

but you can do that with events & recent feedback

Povstalec commented 3 months ago

but yes I agree, there is no "absolute" way how at specific moment in time say, if chevrons are engaged for incomming or outgoing (not yet formed) connection

There is stargate_chevron_engaged Event

Povstalec commented 3 months ago

the reason i ask in that isStargateDialingOut would be a lot more useful if it could return false if >= 1 chevrons are active so that an alarm or other security that needs to be activated before the wormhole is established has time to do so and if it returned nil if no chevrons were active it'd help with checks as well

I hate returning null values because it often causes problems when something breaks (look no further than Java's infamous NullPointerException). If there was a function like that, it would 10 000 000 000% return numbers and NEVER nil.

C4PTRAMPAGE commented 3 months ago

the problem with the chevron engaged event is that (possibly due to my bad coding, so my fault not yours) the script doesn't always notice events reliably, though a lot more with mouse clicks than anything else, no idea why.

to be clear the program does work as intended, its just a bit unresponsive to mouse clicks and rarely skips other events.

lukaskabc commented 3 months ago

the problem with the chevron engaged event is that (possibly due to my bad coding, so my fault not yours) the script doesn't always notice events reliably, though a lot more with mouse clicks than anything else, no idea why.

to be clear the program does work as intended, its just a bit unresponsive to mouse clicks and rarely skips other events.

That is probably a problem in your event handling, note that using sleep and other similar functions, purges the event queue of the current coroutine, you can join SGJourney discord and consult your program with the community.

C4PTRAMPAGE commented 3 months ago

sleep clears events? don't think i'm using sleep much but i'll look, i assumed it was the 10 trillion if then statements in the doing stuff part of the code or the math for updating stuff on the screen.

...wait do timer evens clear other events? i'm using that to stop the script from pausing too long while it looks for other events, so the code can actually do stuff.

anyway maybe i'll join that discord but i doubt anyone would be willing to look through almost 4000 lines of spaghetti code total across 7 files that load each other with require.

lukaskabc commented 3 months ago

sleep clears events? don't think i'm using sleep much but i'll look, i assumed it was the 10 trillion if then statements in the doing stuff part of the code or the math for updating stuff on the screen.

...wait do timer evens clear other events? i'm using that to stop the script from pausing too long while it looks for other events, so the code can actually do stuff.

anyway maybe i'll join that discord but i doubt anyone would be willing to look through almost 4000 lines of spaghetti code total across 7 files that load each other with require.

I can try maybe 😅 I don't know what you mean by "stopping the script from pausing too long" so I guess it depends how you process events from timer.

Eventually you can look at my code, which also works with events and I don't think I'm losing any events, but it's not well written either. I solved the problems with sleep (which purged events) with something I called "run later", which is basically a separate coroutine/"thread" that has a queue of lambdas with timeouts, the "thread" checks the timeout and executes them when the timeout is exceeded. So I changed the problem from "stop the current thread for X seconds" to "give a function to another thread that will execute it after X seconds", it has its drawbacks, but the current "thread" keeps its events and the other one only takes care of timers and cleaning other events is not a problem there.

WinMister332 commented 2 months ago

Where'd you get that graphical DHD program. The Comptuer Craft stuff on Povstalec's Repos' haven't been updated since January, and C4P doesn't seem to have any Repos and from first appearance, it seems like he made it, yet doesn't have a github for hit, how... confusing.

Povstalec commented 2 months ago

Where'd you get that graphical DHD program. The Comptuer Craft stuff on Povstalec's Repos' haven't been updated since January, and C4P doesn't seem to have any Repos and from first appearance, it seems like he made it, yet doesn't have a github for hit, how... confusing.

There's a bunch of people on the Discord server that share their Dialing programs in the #creations channel

Povstalec commented 2 months ago

thanks,

the reason i ask in that isStargateDialingOut would be a lot more useful if it could return false if >= 1 chevrons are active so that an alarm or other security that needs to be activated before the wormhole is established has time to do so and if it returned nil if no chevrons were active it'd help with checks as well

Actually, what's the problem with using isStargateConnected() instead? You can pair that with isStargateDialingOut() and with those two functions you could pretty much just do what you want if I understood you correctly.

Either way, I'm also adding isWormholeOpen(), so that you can get more specific.