After making my Topic script i found medelling with 'two dimensional' vars tiresome and annoying.
So, I've created a way to simplify double variables below I have made a simple way to handle them for those new to irc or those who like a bit of help here and there before they step into the main stream stuff in mIRC.
I will add more snippets below as i come across them!
; mIRC Coder Tools
; By Thomas Edwards (TMFKSOFT)
; This script contains commands that you will find to be of great use in bot creation
; If you use any of it please leave credit to myself!
; Feel free to remove commenting when using in your scripts.
; Better vars, giving our code some type of standards is whats best this will speed the process.
alias setvar {
;Usage: /setvar [main var] [sub var] [value]
; e.g. /setvar talk #ilkotech 0
; Which is the same was %talk.#ilkotech
; This allows different vars for different channels.
set % $+ $1 $+ . $+ $2 $3-
}
alias getvar {
;Usage $getvar([main var],[sub var])
; e.g. if ($getvar(talk,#ilkotech == 1) { HALT } else { msg # Hello. }
; This gets the result of a var set via the /setvar command.
; It will return $null by default
return % [ $+ [ $1 ] $+ . $+ [ $2 ] ]
}
alias unsetvar {
;Usage: /unsetvar [main var] [sub var]
; e.g. unset talk #ilkotech
; Will unset the previously set var, It may be used for normal vars e.g. unsetvar %test
unset % $+ $1 $+ . $+ $2
}
; More to come as I dig it up...
; Fixes
; * Fixed that sleeply slurr on initiating a variable before return.
; * Aded the simpler brackets.
Honestly, I'd have no clue how to do that. I got my uno script from here (http://www.mirc.net/projects.php?go=1085886167), and this would be a lot to go through and manually change. Plus, I don't really know what all I would have to change in it.
mIRC scripting isn't really my strong point.... I only make small basic scripts.
Would it be possible to use something like this to be able to have a game script (eg. an uno script) run on multiple channels simultaneously without the vars conflicting? As of now, all the uno scripts I've seen can only one on one channel at a time.
If I seem pretty confused, I am... all i really looked at was this line:
; This allows different vars for different channels.
Lucius:
I intend to improve it when i can be bothered but you can make a good bot using it i have created my own IRCD in mIRC using this method for storing modes, topics and anything else that needs to be handled including nicks.
Also its better 2.point than nothing and is useful for simple game scripts. Its not exactly going to be needed to recreate 9/11...
You mean things like:
%IPtrack. [ $+ [ $nick ] ]
%adminpass. [ $+ [ $nick ] ]
True enough, but also not all variables need that 2 point style, what about simple counters which only need one?
Or 3point ones like: %autopass. [ $+ [ $server ] . $+ [ $nick ]
(take note of that people, thats the kind of thing you need to stop you failing OPER when you connect to another server, I still have my autokill on failed oper. And I still use it.)
The way you have it now is permenantly set to 2point variables.
So something like %lolcount would become %lolcount.info and unusable (although it would be simpler to use /set
I understand that you meant it to help a standardised variable set, but isn't it better that everyone has their own style of doing it? Thats one of the reasons vars don't overlap across scripts very often.
If I was to consider using that, I'd need it to be multiple optional. $setvar(blah blarg blah INFO,3) or $setvar(blah blarg bleh 4th_option, INFO) etc which would make it recognise %how.many.are.needed for the variable in question.
For games on bots especially I can see this having a use once it isn't so restricted.
%uno.$nick.wins
%uno.$server.$nick.wins
for example.
It's just too simplified right now to be a properly useful tool. It's a 2.point or nothing type of alias.
That said I apologise for my inital derogatory post, it has more use than I expected but it's got more potential as more of an intermediate/advanced use for bot game coders than an initial help.
Lucius:
As easy as it is to set %something.something you can do that for variables that differ and arent fixed.
SunnyD:
I were tired and for some reason if i didnt init the var before returning my mind would implode, i should fix that.
pball:
I've not tried that but my gut instinct would tell me it wouldn't work, excuse me if it does work.
Jethro:
I've never tried $eval() so i have no idea how to use it, thansk for letting me know i will get around to learning it!
jaytea:
I've never devled into $hget() and so forth so i never thought to try it, and the bracket mess was the result of me messing with the brackets used in my topic script, so thanks for pointing out about simplyfying it.
pball:
I love working it out and hey its fun! some people dislike that concept and prefer the intelligent method which i dont so there you are!
Thanks for the feed back guys, ill apply the simplified brackets and sort that silly return!
assuming many 'sub vars' to one 'main var', the interface you've created is essentially an alias for /hadd and $hget() ;) but i've always liked the idea of creating utilities for other scripters, so i look forward to future submissions made in the same vein.
% [ $+ [ $1 ] ] [ $+ [ . ] ] [ $+ [ $2 ] ]
there's a lot going on behind the scenes there, and it's worth noting that the above can be simplified to:
% [ $+ [ $1 ] $+ . $+ [ $2 ] ]
the simplification makes the pattern easier to understand, should you try to do so. evaluation brackets are fascinating, but as pball showed, their use in this context has been superseded by $eval().
while you are at it why don't you add in:
/chat_in_room
/doing_an_action
/make_me_quit
/show_only_to_me
/who_is_that
/join_this_room
/leave_this_room
then you wouldn't need to actually know how to use IRC at all. You'd just have to learn those commands instead...
yes that was sarcasm, sorry. I don't mean to be an ass but seriously?
why not make the variables use mirc's built in /set and /unset along with /echo
that way people can learn the right way of doing it, and just add some echo reply information which mirc doesn't do as standard like: your variable was set/unset.
The closest I can see to useful is the getvar but that is easily accomplished with //echo -a %varname
There's no reason I can see for this at all. One of the first things someone learns for coding is the /set and /unset along with /echo -a
this just confuses the issue with unneeded complications.
If you are going to make a coding help script, why not run it as an interactive script that people can do themselves with mirc's normal commands. If It's for a bot then it's even easier, just make the bot pose hypothetical variable names and ask them to answer them.
how can I remove my variable? it's called: %kick.count.ROOMNAME (reply with !answer ...) !answer /unset %kick.count.ROOMNAME CORRECT! how do I check what is in my variable? it's called: %brb.count.ROOMNAME !answer /echo -a %brb.count.ROOMNAME Close! remember to use double slash. /echo -a will show the name, not check inside it. Use //echo -a now that would be useful for learning. As I can see right now you are just making new commands to learn and adding a bit of info to it.