[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
97
S
35
G
29
Posts: 3,139
Reputation: 28,371

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
27
S
16
G
73
Posts: 974
Reputation: 41,157

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
65
S
22
G
4
Posts: 358
Reputation: 6,555

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
27
S
16
G
73
Posts: 974
Reputation: 41,157

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
62
S
17
G
5
Posts: 169
Reputation: 8,325

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
61
S
34
G
13
Posts: 229
Reputation: 12,269

Post » Sat Feb 11, 2017 10:55 am

@Unconnected you can compare it with 0 or 1. 0 is false, 1 is true.
Image
B
62
S
28
G
39
Posts: 459
Reputation: 24,158

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
54
S
23
G
12
Posts: 746
Reputation: 11,908

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
54
S
23
G
12
Posts: 746
Reputation: 11,908

Post » Sat Feb 11, 2017 7:53 pm

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

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests