DEV Community

Quinn
Quinn

Posted on • Originally published at midsubspace.hashnode.dev on

Getting Started With Farmtronics

Stardew Valley, a charming and beloved farming simulation game, has captured the hearts of gamers worldwide since its release. The game offers an idyllic escape into rural life, allowing players to cultivate crops, raise livestock, and build relationships with the town's quirky residents. However, if you're seeking to breathe new life into your virtual farming endeavors, look no further than the Farmtonics mod. In this guide, we'll take you through the steps to get started with the Stardew Valley Farmtonics mod, a fantastic addition that introduces exciting elements and enriches your gameplay experience with the power of programming and robots.

We have gone over how to install both the Mod API for Stardew Valley and the Farmtonics Mod itself. But what about once you load the game for the first time?

First, you will want to go over to the tv in your farmhouse

and select the Farmtronics Home Computer

Then in the main terminal type todo

This will bring up the to-do list which you need to complete to get your first robot.

The rest of this post will be going through the to-do list.

Printing Hello World

Moving Directories

the next item is to cd to another directory or folder on the computer. Farmtronics does not use your actual computer folders but its virtual folders. you see the root or first folder in the file system run [dir "/"]

cd stands for Change Directory and with MiniScript which is the programming language used by this mod you need to have quotes " around the file or folder name so we will run [cd "/sys/"]

To make sure it worked you can run pwd which will show the folder you are currently in.

Running the first program

Next, we need to run a demo which is located at the path "/sys/demo"

so we will do [cd "/sys/demo"]

then we will load the dogYears.ms program [load "dogYears.ms"]

then use the run command to run the program

Editing and Saving A Program

Next on the list is to edit and save a program to do this we will first run [cd] which will take us to our main folder and then just run the [edit] command to open the dog years program and then you can just add a space to the first line.

then hit Ctrl+Q to exit the editor window. and type save "test" to save it in the /usr folder

For-Loops and Counting To 100

Next, we will be writing our first program which uses a for-loop that will print the number 1 through 100.

the first line says for every number that is within the range of 1-100 it should print that number on the screen

For this last one, I am not going to show any code for theFizzBuzz program

FizzBuzz: The Last Step

Per the request of Joe Strout creator of MiniScript and Farmtronics "One thing I ask, though: don't give away the solution to the FizzBuzz task. If somebody can't get through that, they're only going to get frustrated trying to program their bots. So, that's an opportunity for somebody to slow down and check their understanding."

What is FizzBuzz?

FizzBuzz is a programming puzzle that appears deceivingly simple but carries a hidden complexity. The goal of FizzBuzz is to generate a sequence of numbers while applying specific rules. These rules dictate that for multiples of 3, the word "Fizz" should be displayed, and for multiples of 5, the word "Buzz" should appear. When a number is a multiple of both 3 and 5, the program combines the two words into "FizzBuzz." For all other numbers, the program prints the number itself.

The Intricate Steps

Let's embark on the journey of showing a little peak behind the curtain of the FizzBuzz challenge without giving away the exact solution:

  1. Number Iteration : Begin by iterating through a range of numbers, starting from 1 up to a specified limit. As we did with the above for-loop of 1-100

  2. Divisibility Checks : For each number in the range, you'll need to perform checks to determine whether it is a multiple of 3, 5, or both. Can be done using somewhat basic math

  3. Output Rules : Depending on the divisibility checks, decide what output to display. Remember, the rules are: "Fizz" for multiples of 3, "Buzz" for multiples of 5, and "FizzBuzz" for numbers that satisfy both conditions. For all other numbers, the output should be the number itself. One way we can do this is by using "if-then" statements

  4. Printing : Print the determined output for each number, following the established rules. As we did when printing Hello world!

  5. Loop Continuation : Continue iterating through the range of numbers until you reach the specified limit. As we did with the above for-loop of 1-100

The Art of Problem Solving

Creating the FizzBuzz program isn't just about coding; it's an exercise in problem-solving and logic. As you navigate through the steps outlined above, consider the following:

  • How can you efficiently check for divisibility without resorting to repetitive code?

  • Are there any patterns or conditions that can help you optimize your solution?

  • How can you ensure that the program handles all possible cases correctly?

Experiment and Refine

Coding, like any skill, improves with practice and experimentation. Don't hesitate to experiment with different approaches and iterate on your code. You might find more elegant solutions or discover unique ways to tackle the challenge.

If you need further help you can check out the Miniscript Manual or the Quick Reference Guide. You can also connect with the Miniscript and Farmtronics community on both Discord and the Miniscript Forums.

Top comments (1)

Collapse
 
joestrout profile image
JoeStrout

Great guide! I'm going to give one more hint on the FizzBuzz challenge; something that you'd be unlikely to know unless you learned it from some other programming language already.

To check for divisibility, you can use the "mod" operator, %. This gives the remainder after division. For example, 7 % 3 (seven mod three) is 1 because 3 goes into 7 twice, with 1 left over. If a number is evenly divisible, then there is nothing (zero) left over. This is how you can tell if a number is evenly divisible by 3 or 5.