OS Interaction

Donavin69

Member
For obvious security reasons, this may not be an implementable feature, but I thought I would ask. Is there currently, or would it be easy to implement some OS interaction from within Mafia? Specifically, I would like to, on an event in the game fire up a bot character (for baiting hobo sewers). If there is already a way to do something simple like write to the system event log, I can monitor that, or something else.

I have come up with a work-around to be able to do what I want, but it is definitely going to be 'clunky'. (create a file, if it is created, then I can create an event via another running process (or kick off the bait bot directly from that process)
 

Ulti

Member
If you wanted a bot to listen to PMs, for example, to fire up another bot in another mafia instance, I think the closest you'd come is visit_url in combination with PHP or Python to interact with the OS to fire up another mafia instance.
 

heeheehee

Developer
Staff member
The extent of the non-network-related I/O available to the end-user in Mafia lies in get/set_property, file_to_map/map_to_file, and svn (various commands).

chatbotScripts might be useful, though, for some sort of event-based system.
 

Theraze

Active member
Easiest thing to do would probably be to combine a scheduled task running every XX minutes to scan the session logs for today, for whatever event you're trying to kick off. If discovered, save a file or environmental variable that means to not do it again today (or until found again), and launch your bot character.

In Windows, the scan would probably be something like:
findstr /c:"something to find" C:\KoLmafia\session\*_%today%.txt
where C:\KoLmafia is wherever mafia is saved and %today% has been defined as your mafia session file date format.

It's not hard to save stuff to your session logs. For that matter, you could use map_to_file to save your launch command, and your bot could wipe the file again with a new blank map.
 

xKiv

Active member
Or setup a local CGI script, and then visit_url('http://localhost/cgi-bin/triggerbot?x='+someparameter)?
 

Donavin69

Member
Easiest thing to do would probably be to combine a scheduled task running every XX minutes to scan the session logs for today, for whatever event you're trying to kick off. If discovered, save a file or environmental variable that means to not do it again today (or until found again), and launch your bot character.

In Windows, the scan would probably be something like:
findstr /c:"something to find" C:\KoLmafia\session\*_%today%.txt
where C:\KoLmafia is wherever mafia is saved and %today% has been defined as your mafia session file date format.

It's not hard to save stuff to your session logs. For that matter, you could use map_to_file to save your launch command, and your bot could wipe the file again with a new blank map.

This is what I was planning, but figured if there was a built in way to do it, I'd use that instead of a 'workaround'

Thanks for the help!
 
Top