[Plugin] Globals

Post your completed addons to share with the community

Post » Thu Jan 12, 2017 1:34 am

I understood your reason, I guess it would be good practice for code architecture. Thanks for explaining in other way!
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

Post » Thu Jan 12, 2017 1:47 am

spacedoubt wrote:Could you not accomplish the same thing with, say, a blank dictionary? Am I missing something?


As I mentioned in my recent post:

Toby R wrote:It’s all about the approach. You can use nearly any other plugin and achieve the same result. I just made this one to have an empty plugin so to not load unnecessary data to the memory and have a separate plugin with unique icon to make it visually distinct.


So yes, you can use a blank dictionary as well. Wouldn't be that elegant (IMO) as using this empty plugin, but you can achieve the same results.
ImageImageImage
B
45
S
23
G
89
Posts: 1,100
Reputation: 50,611

Post » Tue Jan 24, 2017 5:12 am

I already do it by using a permanent object (say, an array) in my game instead of global variables. The problem is i just recently started this approach and still have tons of globals to turn into object variables with all affected events.
B
67
S
23
G
4
Posts: 365
Reputation: 6,721

Post » Tue Jan 24, 2017 12:59 pm

Danwood wrote:I already do it by using a permanent object (say, an array) in my game instead of global variables. The problem is i just recently started this approach and still have tons of globals to turn into object variables with all affected events.


That's why it is recommended to use this approach always from the start of the project (from the very first global variable) and have things encapsulated all the time. Refactoring the existing project is always time consuming. Still if you have "tons" of globals it most probably mean your app architecture is not the best it could be. Whenever it is possible you should use local variables instead of globals.
ImageImageImage
B
45
S
23
G
89
Posts: 1,100
Reputation: 50,611

Post » Sun Feb 05, 2017 7:42 am

I was totally going to do that! It's kind of like a "struct" object... Great idea!
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
70
S
18
G
5
Posts: 186
Reputation: 8,724

Post » Sat Feb 11, 2017 8:22 am

I am testing this out with a boolean.

As an action using The Global Plugin "Set boolean" the boolean can only be set to "True" or "False".

As a condition when using System "Compare two values" I can only compare to "true" or "false".

"False" isn't working when compared to "false"?
It seems to be ignoring the condition.



When I change it to a text variable I am able to match the capitalization of the variable and the conditions are working.
It seems boolean can't be used, or I am comparing/setting it wrongly?
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

Post » Sat Feb 11, 2017 10:55 am

@Unconnected you can compare it with 0 or 1. 0 is false, 1 is true.
B
76
S
38
G
52
Posts: 504
Reputation: 32,292

Post » Sat Feb 11, 2017 12:13 pm

.
Last edited by Anonnymitet on Sat Feb 11, 2017 12:18 pm, edited 1 time in total.
B
63
S
26
G
16
Posts: 816
Reputation: 14,573

Post » Sat Feb 11, 2017 12:16 pm

Anonnymitet wrote:
Unconnected wrote:I am testing this out with a boolean.

As an action using The Global Plugin "Set boolean" the boolean can only be set to "True" or "False".

As a condition when using System "Compare two values" I can only compare to "true" or "false".

"False" isn't working when compared to "false"?
It seems to be ignoring the condition.



When I change it to a text variable I am able to match the capitalization of the variable and the conditions are working.
It seems boolean can't be used, or I am comparing/setting it wrongly?


Just use "is bolean set" and invert it to compare if a bool is false.

Image
B
63
S
26
G
16
Posts: 816
Reputation: 14,573

Post » Sat Feb 11, 2017 7:53 pm

This looks awesome. Dreading converting my global variables but definitely worth it.
Image
B
76
S
23
G
3
Posts: 673
Reputation: 9,348

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: GoldyPMU, Sokuden1252 and 3 guests