[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  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] Refresh page


Posted by R-Strunk   (3 posts)  [Biography] 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!
[Go to top] top

Posted by Nick Gammon   Australia  (22,928 posts)  [Biography] 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
[Go to top] 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.


4,550 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]