Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Autonauts

Make and teach robots to automate the world! · By Denki

SteamBot Loop Example

A topic by Demongornot created Sep 12, 2017 Views: 1,143
Viewing posts 1 to 1
(+2)

Hi everyone, some people have trouble with loops, if you want to set two argument like getting a new axe when the old one broke and stop chopping when log storage is full, you often set two loops inside each others, one which is "until hand empty" and the other "until storage full".

But doing this you often encounter the issue of the bot keeping chopping until his axe is broken even if storage is full or trying to keep chopping after broking his axe, and steambot who need log are even worst because you need 3 conditions now.

So until a more complex programming system is added to the game, here is a loop design that allow all those 3 conditions or more, all my steambots ran for hours without issue on my whole base.

Little advise, for the steambots put stones in all inventory slot but one, until the fuel consumption bug is fixed since this loop fill the inventory.

Wood cutting steambot :

(until Log Storage not full)

Here the bot will forever repeat the loop where, at first if his inventory is missing fuel, he will store his tool and take one fuel (only one if you already put something else in his inventory, this loop just fill his inventory).

Then if he have no tools, regardless if this is because of the tool being broken or for taking fuel, he will take one.

Finally, when the storage is full, he will wait, since he don't consume fuel or damage the tool while waiting, this don't cause any troubles.

And the 3 last instructions are simply to chop trees.

For the "wait" command, when instructing the robot, click to move somewhere and when you reach your destination, click again where you are, the second command after "move" will be "wait", just remove the unnecessary "move" command and you have a "wait" command, each wait command is one second, if you want him to wait for example 5 seconds after the log storage is not full, put 5 "wait" or one inside a 5 times "repeat" loop.


Here is another example with a log picking robot :


All this is inside a "forever" loop, I couldn't took it in a single screenshot, sorry.

Of course I could also have set "until hand full" rather than a 2 times "repeat" loop.

And here a last one for the axe creation robot :

(until Metal Axe Storage not full)


I hope it helped, if you have any questions don't hesitate.