Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ working with "true" and "false" strings

working with "true" and "false" strings

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by R-Strunk   (3 posts)  Bio
Date Tue 01 Mar 2022 08:16 PM (UTC)
Message
I want to create a set of filters that will stay consistent from one session to the next. I believe the best way to do this is with the GetVariable and SetVariable functions.
However, I'm also hoping to be able to have the variables in a set of tables, such that the final object might look like this for ease of comparisons:
beaconfilter = {
asteroid = {text = false, sound = false},
cargo = {text = false, sound = false},
cloud = {text = false, sound = false},
mineable = {text = false, sound = false},
organic = {text = false, sound = false}}

I could, in theory, populate the table with GetVariable on world open using a nested set of for loops.
In so doing, however, the sub-tables would be populated with "true" and "false" strings rather than true and false bools.
A few questions, then:
1. Am I off my rocker in terms of this approach?
2. If this approach is decent, how might I convert the GetVariable results to bools so I don't have to worry about quite so many quote marks when processing the code?
Thanks!
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 01 Mar 2022 09:49 PM (UTC)
Message
The easiest way is to "serialize" your table as described here: http://www.gammon.com.au/forum/?id=4960

Then the bools stay bools and you only have to do one SetVariable rather than one per item.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


6,173 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.