The Farmer Was Replaced

The Farmer Was Replaced

Pulling Different Code Blocks
So, i like to over engineer most of my work in the since of organization (sadly). and i want to know if there is a way to pull code from the different blocks/terminals the games lets you create. like instead of using the def() function and writing it out in the same terminal, i want to write a script to plant/harvest carrots in a single terminal, then on the main, i can just tell it to run/pull the script on that terminal.

so like terminal.main would have like carrots() in it and the game would run terminal.carrots

this is most definitely something that is over-complicated and very probably needles/useless for this game. I just want to know if i CAN lol.
< >
Showing 1-2 of 2 comments
also, below is my current script for my farm. only up to pumpkins and a 4x4:



# -------------------- making tab wide to please the eyes --------------------
prepp = get_world_size()
coord = prepp - 1
#Resets Drone to 0,0
def origin():
while get_pos_x() != 0:
move(East)
while get_pos_y() != 0:
move (North)
origin()
#Preps First Row (X=0) for carrots
a = 0
while a <= prepp: # a = 4 after carrots are done
if get_ground_type() == Grounds.Grassland:
till()
plant(Entities.Carrot)
move(North)
a = a + 1
move(South)
move(East)
#Preps Second Row (X=1) for pumkins
while a <= prepp * 2: # a = 8 after pumkins are done
if get_ground_type() == Grounds.Grassland:
till()
plant(Entities.Pumpkin)
move(North)
a+=1
origin()
#Carrots
while True:
if get_pos_x() == 0:
if get_pos_y() < 3:
if can_harvest():
harvest()
plant(Entities.Carrot)
move(North)
if get_pos_y() == 3:
if can_harvest():
harvest()
plant(Entities.Carrot)
move(North)
move(East)
#Pumkins
if get_pos_x() == 1:
if get_pos_y() < 3:
if get_entity_type() == None:
plant(Entities.Pumpkin)
if can_harvest():
harvest()
plant(Entities.Pumpkin)
move(North)
if get_pos_y() == 3:
if get_entity_type() == None:
plant(Entities.Pumpkin)
if can_harvest():
harvest()
plant(Entities.Pumpkin)
move(North)
move(East)
#Logs
if get_pos_x() == 2:
if get_pos_y() < 3:
if can_harvest():
harvest()
plant(Entities.Bush)
move(North)
if get_pos_y() == 3:
if can_harvest():
harvest()
plant(Entities.Bush)
move(North)
move(East)
#Hay
if get_pos_x() == 3:
if get_pos_y() < 3:
if can_harvest():
harvest()
plant(Entities.Grass)
move(North)
if get_pos_y() == 3:
if can_harvest():
harvest()
plant(Entities.Grass)
move(North)
move(East)


very if'y (hehe), i tried using "for i in range(x)" however i couldnt do much to figure it out to make it work. you can prolly see my idea better here. i want to be able to have the main terminal see what x pos its in and run the appropriate terminal that is associated with whatever crop ive assigned to that column
Last edited by gnr runner; Jan 14 @ 5:34am
umop-apisdn Jan 14 @ 5:42am 
Try using [code][/code] tags, so your code is actually readable; Steam "swallows" the whitespace if you don't, which means we can't tell where your conditional blocks and loops start/stop.

Also, anyone in these forums will either A: not understand your code, or B: not care about your code; don't bother [spoiler]ing it, it just makes it harder for people to read through it because if your cursor wanders off the text while you're scrolling (or your finger, on mobile), it goes black again.

prepp = get_world_size() coord = prepp - 1 #Resets Drone to 0,0 def origin(): while get_pos_x() != 0: move(East) while get_pos_y() != 0: move (North) origin() #Preps First Row (X=0) for carrots a = 0 while a <= prepp: # a = 4 after carrots are done if get_ground_type() == Grounds.Grassland: till() plant(Entities.Carrot) move(North) a = a + 1 move(South) move(East) #Preps Second Row (X=1) for pumkins while a <= prepp * 2: # a = 8 after pumkins are done if get_ground_type() == Grounds.Grassland: till() plant(Entities.Pumpkin) move(North) a+=1 origin() #Carrots while True: if get_pos_x() == 0: if get_pos_y() < 3: if can_harvest(): harvest() plant(Entities.Carrot) move(North) if get_pos_y() == 3: if can_harvest(): harvest() plant(Entities.Carrot) move(North) move(East) #Pumkins if get_pos_x() == 1: if get_pos_y() < 3: if get_entity_type() == None: plant(Entities.Pumpkin) if can_harvest(): harvest() plant(Entities.Pumpkin) move(North) if get_pos_y() == 3: if get_entity_type() == None: plant(Entities.Pumpkin) if can_harvest(): harvest() plant(Entities.Pumpkin) move(North) move(East) #Logs if get_pos_x() == 2: if get_pos_y() < 3: if can_harvest(): harvest() plant(Entities.Bush) move(North) if get_pos_y() == 3: if can_harvest(): harvest() plant(Entities.Bush) move(North) move(East) #Hay if get_pos_x() == 3: if get_pos_y() < 3: if can_harvest(): harvest() plant(Entities.Grass) move(North) if get_pos_y() == 3: if can_harvest(): harvest() plant(Entities.Grass) move(North) move(East)

... and all of that aside, I just have to ask:
Why do you dislike the idea of additional functions?

Separate your concerns, and you can do something like this:
while True: if num_items(Items.Wood) < desired_wood: make_bushes_and_trees() elif num_items(Items.Carrot) < desired_carrot: make_carrots() elif num_items(Items.Pumpkin) < desired_pumpkin: make_pumpkins() else: make_grass() # each of these functions plants and harvests a full field of the requisite item # (for example: checkerboard pattern for wood, making a single super-pumpkin, etc)
This allows you to test and refine each function to maximize the amount of produce production (by pressing play on the window it lives in after adding a function call to the end of the script), then add it to your main loop when you're ready to run full-tilt (for example, when you're doing a leaderboard run).

... and with all of that said, perhaps you just didn't know this:
Originally posted by gnr runner:
so like terminal.main would have like carrots() in it and the game would run terminal.carrots
We can already do this, and what you are asking for is more complicated than the existing system.

Just define carrots() in any window, and any window (same or other) can call it. Every window's functions are accessible from every other window... although only the window you press the "play" button on will instantiate its vars that live outside functions.
Last edited by umop-apisdn; Jan 14 @ 6:15am
< >
Showing 1-2 of 2 comments
Per page: 1530 50