Post by CSP on Aug 8, 2013 4:40:55 GMT
Baking i think is relatively simple to code than other workshops.
First off whenever we want to perform an activity that requires us to select some parameters (ex: duration) in this case the number of flour bags to bake, we need to send this data to the game server via a HTML form. This is done via HTTP POST method. So the first step is to figure out these post parameters (header,value) pairs.
1. Install the firebug addon
2. Go to the workshop page.
3. Start firebug. Go to the Net tab. Within the Net tab go to the HTML sub tab.
4. Now choose baking activity with your character (3 torts?)
5. Once you do that firebug will capture all HTML data. In that you will see a POST packet with the URL of the baking activity (http://...Action.php?action=x ..something like this).
6. Click on that and go to Post sub tab. There you will see headers and their values. Those are the ones we need to send to the game server.
Generally (i can't say about baking since i have not captured for it) there will be 2 kinds of headers.
- Those who have fixed values
- Those whose values change based on the form value selected by the user. (for baking this would be no. of tortilla to bake)
So all we need to do is to send the game server the same data to that URL. That is how the bot basically works. Sends data to appropriate URL. Use
The format of post parameters is of the form ['header1':'value1', 'header2':'value2',..]. Basically both the header and the value must be string type. You can refer to other activities like work_at_mine() / apply_for_jobs() on how to pass the post parameters to the visit function.
First off whenever we want to perform an activity that requires us to select some parameters (ex: duration) in this case the number of flour bags to bake, we need to send this data to the game server via a HTML form. This is done via HTTP POST method. So the first step is to figure out these post parameters (header,value) pairs.
1. Install the firebug addon
2. Go to the workshop page.
3. Start firebug. Go to the Net tab. Within the Net tab go to the HTML sub tab.
4. Now choose baking activity with your character (3 torts?)
5. Once you do that firebug will capture all HTML data. In that you will see a POST packet with the URL of the baking activity (http://...Action.php?action=x ..something like this).
6. Click on that and go to Post sub tab. There you will see headers and their values. Those are the ones we need to send to the game server.
Generally (i can't say about baking since i have not captured for it) there will be 2 kinds of headers.
- Those who have fixed values
- Those whose values change based on the form value selected by the user. (for baking this would be no. of tortilla to bake)
So all we need to do is to send the game server the same data to that URL. That is how the bot basically works. Sends data to appropriate URL. Use
char.visit(action_url, urllib.urlencode({insert_post_(header,value) _pairs}));
The format of post parameters is of the form ['header1':'value1', 'header2':'value2',..]. Basically both the header and the value must be string type. You can refer to other activities like work_at_mine() / apply_for_jobs() on how to pass the post parameters to the visit function.
def bake(char, ntortillas = 4):
#check if char is already working
#check if we have the necessary materials in the home inventory. (wood and bags of flour). Use gamedata.py to see the item codes.
#Then all you need to do is check if `char.home.inventory[wood_code] ` and `char.home.inventory[flour_code]` are in sufficient quantity
#char.visit(bake_url, urllib.urlencode({Insert - post parameters here}))
#check if we got job and write to the logger and return result (True/False)