Khaikaa Posted May 13, 2021 Share Posted May 13, 2021 Hi everyone,  I would like to know which of this 2 options is better when working with intersect:  A) Having multiple boolean variables and check wether one or another is true/false depending on the situation  B) Having 1 single string variable, concat codes inside of it and check wether a code is contained by the string or not depending on the situation   Which one should anyone pick? Would the contains function be more desirable than multiple database boolean entries? Link to comment Share on other sites More sharing options...
0 Cheshire Posted May 14, 2021 Share Posted May 14, 2021 Oh I didn't quite catch you meant event variables.  I'd personally not do this with the event system as it'll get horribly convoluted and it can't affect stuff outside of its scope such as skill damage..  But I'd definitely use booleans for this still. Yeah it's a lot of them but it's easier to manage long term as there's no weird string combinations going and again boolean operations are faster than string searches. Link to comment Share on other sites More sharing options...
0 jcsnider Posted May 13, 2021 Share Posted May 13, 2021 The variables are all loaded into server memory anyways.  With that's said comparing a few books should be less expensive than dealing with strings. Link to comment Share on other sites More sharing options...
0 Khaikaa Posted May 14, 2021 Author Share Posted May 14, 2021 11 hours ago, jcsnider said: The variables are all loaded into server memory anyways.  With that's said comparing a few books should be less expensive than dealing with strings. Thank you for the reply  I'm going to specify the question and then I think I'll be able to mark the thread as answered.  In my project progression is not based on exp but in a skills board. The point is that I want to know which squares are active and which ones are inactive. At this moment I'm using 1 bool var per square(they are dozens) and @Weylon Santana suggested me to use just a few string vars and concat the activated square codes, so I can know if they are active/inactive by just using the 'contains' checker.  That's my problem, is it better to have... lets say... 300 boolean variables rather than 10 string variables but using the contains function? Link to comment Share on other sites More sharing options...
0 Cheshire Posted May 14, 2021 Share Posted May 14, 2021 If you're going to need 300 of them you might want to rethink how they're stored yes. Not necessarily from a performance standpoint, but definitely expandability. Lol  What you could do is make a new table where they're all stored like the inventory slots are. (One row for each skill per player)  Or what would likely be easier is to make a new class that contains all the skill booleans you want and serialise this class when stored to the database so it stays one field and you don't end up with 300 extra columns in the database.  Both those options are preferable over a large string that you look for data in. String concatenation and search operations take more time than checking a simple Boolean from memory. Link to comment Share on other sites More sharing options...
0 Khaikaa Posted May 14, 2021 Author Share Posted May 14, 2021 5 minutes ago, Cheshire said: If you're going to need 300 of them you might want to rethink how they're stored yes. Not necessarily from a performance standpoint, but definitely expandability. Lol  What you could do is make a new table where they're all stored like the inventory slots are. (One row for each skill per player)  Or what would likely be easier is to make a new class that contains all the skill booleans you want and serialise this class when stored to the database so it stays one field and you don't end up with 300 extra columns in the database.  Both those options are preferable over a large string that you look for data in. String concatenation and search operations take more time than checking a simple Boolean from memory. Yeah, I know I could change source to make this the proper way, but I need a non-coded solution, that's why I need to know which one of those 2 options is the best in terms of optimization and memory usage Link to comment Share on other sites More sharing options...
Question
Khaikaa
Hi everyone,
Â
I would like to know which of this 2 options is better when working with intersect:
Â
A) Having multiple boolean variables and check wether one or another is true/false depending on the situation
Â
B) Having 1 single string variable, concat codes inside of it and check wether a code is contained by the string or not depending on the situation
Â
Â
Which one should anyone pick? Would the contains function be more desirable than multiple database boolean entries?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts