zarqon
Well-known member
r32 Updates!
This update brings us some pretty big changes for script settings. And most of them are the sort of changes where, after the fact, you look at them and think "Dang, why didn't I just make it work like this to begin with?" Or rather, I look at them and think that. You look at them and think whatever you're about to comment below.
Inspired by Veracity's recent work around properties, I have slightly overhauled the way ZLib handles script settings:
Important Note
There's also a new function:
string getvar(string varname)
Hitherto, we have simply used a direct vars[] lookup to reference script settings. However, with this new implementation, I'd eventually like vars[], just like vars_myname.txt, to contain only those settings which have been changed from the default. Hence, this new function, which really should have existed since the dawn of script settings.
"Script settings had a dawn?" Yes.
So, if you are a script author using ZLib's handy-dandy script settings, at some point not too far from now you'll want to
search: vars[
replace with: getvar(
And handle the closing ] to ) as well. For all your scripts. I'll be doing this over time with my scripts as well.
Since this is a not insignificant change I'll give everyone loads of time to transition. Let's say... six whole months! Or maybe a year! For now, ZLib adds the default values back in to vars[] so as not to break existing scripts. But in the meantime, let's all encourage each other to be better versions of ourselves and use getvar(), not vars[].
I've also updated this information on ZLib's Wiki page (which you can get to by typing "ashwiki zlib" in the CLI). And in the big info-post I made when I first introduced script settings, in case anyone has linked to that post.
The best and most exciting part of the script settings revamp is yet to come -- a new relay script for editing ZLib script settings and mafia properties. I have everything except the actual editing part complete and it's looking awesome:
Changes to Kmail Functions
Also this update brings us the fix suggested by AlbinoRhino above, implemented by digitrev in his New You script, and as it turns out, suggested by Bale in this very thread back in June of 2011. Somehow that suggestion passed right by me back then without ever catching my eye. My eye was no doubt looking at some far-off vision of the future and was not so easily distracted by the mundane reality of the present!
So, the future is now! Since items, etc. can be received mid-kmail, the message field will now be the entire message.
Also, I discovered a little bug in kmail() which I'm quite surprised no one spotted yet. When sending meat and more than 11 different items to a person who can receive non-gift items, the amount of meat specified would be sent in all the item group kmails, not just the first. I have driven the windshield of correct code through the flight path of this bug, and it exists no more.
Enjoy the future, everyone!
This update brings us some pretty big changes for script settings. And most of them are the sort of changes where, after the fact, you look at them and think "Dang, why didn't I just make it work like this to begin with?" Or rather, I look at them and think that. You look at them and think whatever you're about to comment below.
Inspired by Veracity's recent work around properties, I have slightly overhauled the way ZLib handles script settings:
- First, setvar() now saves the default value and type information to vars_defaults.txt. Your vars_<myname>.txt file is not edited at this point.
- Since the defaults are now saved separately, vars_<myname>.txt now only contains values that have been changed from the default.
- Improved CLI output for searching/editing settings when running ZLib in the CLI.
- Since type information is now saved for each setting, we can now normalize settings when changing them rather than the next time setvar() is called! You get immediate feedback on whether your edit worked as desired.
Important Note
There's also a new function:
string getvar(string varname)
Hitherto, we have simply used a direct vars[] lookup to reference script settings. However, with this new implementation, I'd eventually like vars[], just like vars_myname.txt, to contain only those settings which have been changed from the default. Hence, this new function, which really should have existed since the dawn of script settings.
"Script settings had a dawn?" Yes.
So, if you are a script author using ZLib's handy-dandy script settings, at some point not too far from now you'll want to
search: vars[
replace with: getvar(
And handle the closing ] to ) as well. For all your scripts. I'll be doing this over time with my scripts as well.
Since this is a not insignificant change I'll give everyone loads of time to transition. Let's say... six whole months! Or maybe a year! For now, ZLib adds the default values back in to vars[] so as not to break existing scripts. But in the meantime, let's all encourage each other to be better versions of ourselves and use getvar(), not vars[].
I've also updated this information on ZLib's Wiki page (which you can get to by typing "ashwiki zlib" in the CLI). And in the big info-post I made when I first introduced script settings, in case anyone has linked to that post.
The best and most exciting part of the script settings revamp is yet to come -- a new relay script for editing ZLib script settings and mafia properties. I have everything except the actual editing part complete and it's looking awesome:
Changes to Kmail Functions
Also this update brings us the fix suggested by AlbinoRhino above, implemented by digitrev in his New You script, and as it turns out, suggested by Bale in this very thread back in June of 2011. Somehow that suggestion passed right by me back then without ever catching my eye. My eye was no doubt looking at some far-off vision of the future and was not so easily distracted by the mundane reality of the present!
So, the future is now! Since items, etc. can be received mid-kmail, the message field will now be the entire message.
Also, I discovered a little bug in kmail() which I'm quite surprised no one spotted yet. When sending meat and more than 11 different items to a person who can receive non-gift items, the amount of meat specified would be sent in all the item group kmails, not just the first. I have driven the windshield of correct code through the flight path of this bug, and it exists no more.
Enjoy the future, everyone!