Three questions

Vandermonde

New member
If this is the wrong spot, feel free to move this.

  1. Why _raindohCopiesMade but spookyPuttyCopiesMade? I was hoping this might be some use, but it wasn't (not that I can blame anyone for feeling like writing it). I take it something special happens if you have both (like the maximum values become 5,1 or 1,5), but aren't the variables completely symmetrical or are they being used differently?
  2. Does there exist some way to fetch chat messages? So far my only means of communication is load_kmail() from Zlib (which is truly wonderful. I could wish only that it returned the aggregate instead. But it's still lovely). This works fine for some purposes and until recently I didn't realise I even had a problem since I mostly just got buffs and could refresh periodically, but not everyone is kind enough to stick to Kmail. It's OK if it turns out to be impossible or really painful; I'm expecting it to be that way.
  3. Is it possible to take the contents of my settings file and POST it to my website using visit_url()? My intention is to overwrite the local settings with the saved file as the first step of my loginScript when appropriate (note to self: and refresh afterwards you dolt)
    such as when I switch machines. I know there's a thread right below this one about file_to_map(), but to keep to a minimum of fuss I'd like to just read the file into a string or serialise it or something. If someone has a better idea that obviates the need for all this crap, however, I'm all ears. (I know there's Dropbox, but I'm not in the position to install it everywhere and doing so would be more trouble than just juggling the file via e-mail, USB, etc. which I already have enough trouble remembering.)

Thanks in advance for your advice. I understand I'm asking a lot, but I don't want to change stuff under a false assumption and I figure this doesn't cause anyone too much grief.
 

lostcalpolydude

Developer
Staff member
Why _raindohCopiesMade but spookyPuttyCopiesMade? I was hoping this might be some use, but it wasn't (not that I can blame anyone for feeling like writing it). I take it something special happens if you have both (like the maximum values become 5,1 or 1,5), but aren't the variables completely symmetrical or are they being used differently?
If either setting is at 5 and the other is at 0, then you know that you have a single use of the other one left. Before the 6th use was added, both items used the same setting.
Does there exist some way to fetch chat messages? So far my only means of communication is load_kmail() from Zlib (which is truly wonderful. I could wish only that it returned the aggregate instead. But it's still lovely). This works fine for some purposes and until recently I didn't realise I even had a problem since I mostly just got buffs and could refresh periodically, but not everyone is kind enough to stick to Kmail. It's OK if it turns out to be impossible or really painful; I'm expecting it to be that way.
You want a chatbotScript.
Is it possible to take the contents of my settings file and POST it to my website using visit_url()? My intention is to overwrite the local settings with the saved file as the first step of my loginScript when appropriate (note to self: and refresh afterwards you dolt)
such as when I switch machines. I know there's a thread right below this one about file_to_map(), but to keep to a minimum of fuss I'd like to just read the file into a string or serialise it or something. If someone has a better idea that obviates the need for all this crap, however, I'm all ears. (I know there's Dropbox, but I'm not in the position to install it everywhere and doing so would be more trouble than just juggling the file via e-mail, USB, etc. which I already have enough trouble remembering.)
If that was possible, even with file_to_map(), then someone could make a script to read your settings (including saved passwords) and upload them to their server.
 

roippi

Developer
re: 1)

spookyPuttyCopiesMade predates the introduction of _variables (i.e. preferences that reset daily) so it lacks the prepend underscore. It maintains its semantics for backwards-compatibility, that is why they are not symmetrical.
 

Vandermonde

New member
Thanks for the replies! I hope the reason #3 hasn't been implemented isn't some stupid prank like that. (Don't people look over the script before using one? But I guess I can understand how someone might develop that complex from, say, bumcheekascend.)

Kudos for the chatbotScript, though. That really hit the nail on the head. Would it be sensible to
  1. set the chatbotScript,
  2. cli_execute("chat;"),
  3. send the kmail/blue-message and return
and to essentially give control to the chatbotScript (by handling the received message, unsetting itself, and calling something else, all within chatbotScript)? I'm uncomfortable thinking about both scripts doing much at the same time, so this plan feels OK.
 

Winterbay

Active member
I think most users just download and use scripts, just as most people who download opensource software just run it without looking at the code first.
 

Vandermonde

New member
I think most users just download and use scripts, just as most people who download opensource software just run it without looking at the code first.
Oh. In that case, I recommend this farming calculator script (attached). The only problem is for some reason mafia fails to interpret it if it's been opened before, but I now know that's not a problem. :)

Roippi edit: malicious scripts are NOT OKAY. Even as a joke. This will be your first and only warning.
 
Last edited by a moderator:

Paragon

Member
While you can't upload/download files directly, I was pretty sure you can load/save maps using map_to_file and file_to_map with URLs as the file... I am pretty sure thats how some scripts share data or keep some settings up to date.

If that doesn't fit your needs, then you'd still be able to create a php site that your script can visit via visit_url that could generate a file in whatever format you wanted with the script passing the data via post or get... I am fairly certain mafia allows you to specify post/get. Then that same php site could read the file and serialize the results with another use of visit_url
 

zarqon

Well-known member
3. Using Jason's handy "prefref" alias as a starting point, I came up with this:

PHP:
record r{ string d; };
r[string,string] m;
file_to_map("defaults.txt",m);
string[string] mysettings;
foreach t,p,d in m mysettings[p] = get_property(p);
if (visit_url("http://mywebsite.com/settingsstoringscript.php?data="+to_json(mysettings)) != "success") 
  print("ERROR submitting settings");

That submits all your settings which are contained in defaults.txt (meaning no script-generated settings will be included) as a JSON string to your PHP script, and if the script outputs anything other than just the string "success" it prints an error message. I'd recommend that the PHP script save the settings data on your server in the exact same format as mafia's maps, for easy access with file_to_map() later.

The reverse would then simply involve loading the saved settings from your server:

PHP:
string[string] mysettings;
if (file_to_map("http://mywebsite.com/savedsettingsdata.txt",mysettings)) {
   foreach s,v in mysettings set_property(s,v);
}

You may want to add more to that, such as some sort of verification check, or personalizing the filenames per character, but that ought to be enough to get you started.
 
Kudos for the chatbotScript, though. That really hit the nail on the head. Would it be sensible to
  1. set the chatbotScript,
  2. cli_execute("chat;"),
  3. send the kmail/blue-message and return
and to essentially give control to the chatbotScript (by handling the received message, unsetting itself, and calling something else, all within chatbotScript)? I'm uncomfortable thinking about both scripts doing much at the same time, so this plan feels OK.
chatbotScript is my forte. However I'm not sure exactly what you are looking to do.
If your worry is that two scripts may be running at the same time there are a few ways to work around that (though whether you need to depends on what each script does).
What exactly is "chat" doing here? What do you mean by "send the kmail/blue-message"?
The chatbotScript isn't running. It gets activated when you receive a message. Awesomely, you can even have it activate when the message is "You received a kmail from whoever" which would obviate your "two scripts running simultaneously" problem, as you could just have the chatbotScript handle kmails as they come in.
However, disabling the chatbotScript, executing some other script, and then re-enabling the chatbotScript won't... quite work. If you could find some way to actually disable the chatbotScript, and then re-enable it post-other-script, then any messages received during its downtime will be lost, not queued. However even this would be tricky, since what I think you're proposing would actually pause the current invocation of the chatbotScript, run the other script, and then finish the chatbotScript, which would make disabling it unnecessary.

Oh, just so you know, if the chatbotScript is still running as another message comes in, it doesn't start running a new instance until the first finishes. If, for some reason, the script gets stuck, it will appear as if you aren't getting any more chat messages, so be careful with that.
 
Top