Craftomation 101

Craftomation 101

View Stats:
MattBold Feb 21, 2024 @ 6:59pm
How do I use variables?
Can anyone demonstrate a simple/early use case scenario for variables? I don't quite understand it.
< >
Showing 1-8 of 8 comments
Azazel's Echo Feb 22, 2024 @ 12:35am 
I'm not a programmer or anything but I'll try my best to explain the way I use them.

I made a screenshot of a function that I'm using to make bots fuel the furnaces. You can see on the left the cyan block that's a set variable and it's transmitting its value (32:27 the coordinates of one of my furnaces) to all the other blocks that use the same coordinates through the green line connectors.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165821992

So you can change the value in the cyan block (the variable) to modify the value of all the other blocks that it's connected to through the green lines.

In this case the variable I'm using is an "input" variable (you find them in the functions tab if you have unlocked them) that means that it's inheriting its value from another variable that I've manually set in another function (check the screenshot below, you see the same value 32:27 that's been inputted in another function through a green line). You can also see that I'm using another variable with the coordinate of another furnace (24:23) that's been inputted in another instance of the same function, so basically I can use the same function to fuel different furnaces by simply changing the values of the two variables (one for each furnace) in the function in the screenshot below.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165822192

I'm sorry if this can be a bit confusing but it's very simple once you get the hang of it, just experiment a bit and you'll get it easily!

Below you find a more advanced use of variables:

https://steamcommunity.com/sharedfiles/filedetails/?id=3165836776

In this case I'm using the "find" variable to look for wood from a source (from trees and furnaces but not from storages) once the bot finds a source it gets its coordinates and then compare them to the other two variables that I've manually put in that are the coordinates of my two furnaces, if the values matches then it means that the bot has located one of the two furnaces so it's going to avoid them and look from another source to collect wood, so this way it doesn't get the wood out of the furnaces and instead it only collects it from trees.

You see you can do a lot of stuff with variables!
Last edited by Azazel's Echo; Feb 22, 2024 @ 1:00am
MattBold Feb 22, 2024 @ 5:02am 
Originally posted by Azazel's Echo:
I'm not a programmer or anything but I'll try my best to explain the way I use them.

I made a screenshot of a function that I'm using to make bots fuel the furnaces. You can see on the left the cyan block that's a set variable and it's transmitting its value (32:27 the coordinates of one of my furnaces) to all the other blocks that use the same coordinates through the green line connectors.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165821992

So you can change the value in the cyan block (the variable) to modify the value of all the other blocks that it's connected to through the green lines.

In this case the variable I'm using is an "input" variable (you find them in the functions tab if you have unlocked them) that means that it's inheriting its value from another variable that I've manually set in another function (check the screenshot below, you see the same value 32:27 that's been inputted in another function through a green line). You can also see that I'm using another variable with the coordinate of another furnace (24:23) that's been inputted in another instance of the same function, so basically I can use the same function to fuel different furnaces by simply changing the values of the two variables (one for each furnace) in the function in the screenshot below.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165822192

I'm sorry if this can be a bit confusing but it's very simple once you get the hang of it, just experiment a bit and you'll get it easily!

Below you find a more advanced use of variables:

https://steamcommunity.com/sharedfiles/filedetails/?id=3165836776

In this case I'm using the "find" variable to look for wood from a source (from trees and furnaces but not from storages) once the bot finds a source it gets its coordinates and then compare them to the other two variables that I've manually put in that are the coordinates of my two furnaces, if the values matches then it means that the bot has located one of the two furnaces so it's going to avoid them and look from another source to collect wood, so this way it doesn't get the wood out of the furnaces and instead it only collects it from trees.

You see you can do a lot of stuff with variables!

Wow, thank you for this detailed and thought out explanation! You helped me understand it so much better!

Eager to play around with it later! Should help with my campfire problem!

One more follow up question. What's the difference between find and pick and just find then pick from like you have in your last example?
Azazel's Echo Feb 22, 2024 @ 5:22am 
Well to "pick" you also need to specify which tile you're trying to pick things from, while "find" by itself only locates the tile and records its coordinates so after that you can say to actually do something with those coords like go and pick or go check and count the items that it contains and so on.

The command "find and pick" makes the bot look for the closest tile with the item that you've specified and it goes and pick it up. You can also specify to only pick things either from the storage, from the ground or from a source (furnaces and bonefires also count as source apparently) or any combination of those.

Essentially using the "find" variable allows for more articulate actions while "find and pick" is a straight forward command but is more limited. So in my example I needed to add an exception to which tiles the bot could pick up wood from, so I needed to use the "find" variable to then make a comparison and check if those tiles were the same as my furnaces, so in that case the bot wouldn't pick the wood from those and move on to the next action.
Last edited by Azazel's Echo; Feb 22, 2024 @ 5:24am
MattBold Feb 22, 2024 @ 6:19am 
Originally posted by Azazel's Echo:
Well to "pick" you also need to specify which tile you're trying to pick things from, while "find" by itself only locates the tile and records its coordinates so after that you can say to actually do something with those coords like go and pick or go check and count the items that it contains and so on.

The command "find and pick" makes the bot look for the closest tile with the item that you've specified and it goes and pick it up. You can also specify to only pick things either from the storage, from the ground or from a source (furnaces and bonefires also count as source apparently) or any combination of those.

Essentially using the "find" variable allows for more articulate actions while "find and pick" is a straight forward command but is more limited. So in my example I needed to add an exception to which tiles the bot could pick up wood from, so I needed to use the "find" variable to then make a comparison and check if those tiles were the same as my furnaces, so in that case the bot wouldn't pick the wood from those and move on to the next action.

This one is a little harder to wrap my head around but I have enough to go off of and start playing around with it.

Thank you SO much!
Sigma Feb 25, 2024 @ 1:52am 
Originally posted by Azazel's Echo:
I'm not a programmer or anything but I'll try my best to explain the way I use them.

I made a screenshot of a function that I'm using to make bots fuel the furnaces. You can see on the left the cyan block that's a set variable and it's transmitting its value (32:27 the coordinates of one of my furnaces) to all the other blocks that use the same coordinates through the green line connectors.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165821992

So you can change the value in the cyan block (the variable) to modify the value of all the other blocks that it's connected to through the green lines.

In this case the variable I'm using is an "input" variable (you find them in the functions tab if you have unlocked them) that means that it's inheriting its value from another variable that I've manually set in another function (check the screenshot below, you see the same value 32:27 that's been inputted in another function through a green line). You can also see that I'm using another variable with the coordinate of another furnace (24:23) that's been inputted in another instance of the same function, so basically I can use the same function to fuel different furnaces by simply changing the values of the two variables (one for each furnace) in the function in the screenshot below.

https://steamcommunity.com/sharedfiles/filedetails/?id=3165822192

I'm sorry if this can be a bit confusing but it's very simple once you get the hang of it, just experiment a bit and you'll get it easily!

Below you find a more advanced use of variables:

https://steamcommunity.com/sharedfiles/filedetails/?id=3165836776

In this case I'm using the "find" variable to look for wood from a source (from trees and furnaces but not from storages) once the bot finds a source it gets its coordinates and then compare them to the other two variables that I've manually put in that are the coordinates of my two furnaces, if the values matches then it means that the bot has located one of the two furnaces so it's going to avoid them and look from another source to collect wood, so this way it doesn't get the wood out of the furnaces and instead it only collects it from trees.

You see you can do a lot of stuff with variables!

Is this a setup for one singular furnace? Do you have to set one up for each furnace or is there a way to tell one or two bots to go through all furnaces and fuel them? Appreciate it!
Azazel's Echo Feb 25, 2024 @ 5:03am 
Originally posted by Sigma:
Is this a setup for one singular furnace? Do you have to set one up for each furnace or is there a way to tell one or two bots to go through all furnaces and fuel them? Appreciate it!

Basically I use a function that contains the coords of the funaces that I want to fuel:
https://steamcommunity.com/sharedfiles/filedetails/?id=3168048810

You can see that I've placed the variables pretty much in the same pattern of the furnaces on the map, so it's easier for me to add, remove or move around the furnaces without messing up the program.

I've assigned one bot that is going to loop around those furnaces and keep them fueld, and if it can't find wood then it's going to help with tree farming and then go back to the furnaces:
https://steamcommunity.com/sharedfiles/filedetails/?id=3168048404
flywong0330 Feb 25, 2024 @ 10:07pm 
https://steamcommunity.com/sharedfiles/filedetails/?id=3168594381
why i can't make a function to set position ,if i can , i will easy to control my bot to do anything
https://steamcommunity.com/sharedfiles/filedetails/?id=3168594340
is this mean one function only can make one position out?
Last edited by flywong0330; Feb 25, 2024 @ 10:09pm
Ratta Feb 26, 2024 @ 2:25am 
Originally posted by flywong0330:
https://steamcommunity.com/sharedfiles/filedetails/?id=3168594381
why i can't make a function to set position ,if i can , i will easy to control my bot to do anything
https://steamcommunity.com/sharedfiles/filedetails/?id=3168594340
is this mean one function only can make one position out?

it would need to look something like this: https://imgur.com/a/BgF3irm
in my example here the bot will continue to move from left to right and vice versa, just by using 1 move command. in order to change a variable u need to have at least 2 signals linked to the input of a variable.
so to explain how my example works:
the entire loop starts bot sets the variable to the value of "input 1" the variable is setting the move location in the move command to the value of "input one and the bot moves there, once the bot reaches the destination the comperator is comparing the value of the variable to the value of "input 1" since those r equal right now the "assign"-trigger is setting the value of the variable to the value of "input 2" which is setting the destination for the move command to the value of "input 2", since its routed back to the move command the bot is moving from the location of "input 1" to the location of "input 2" since all this is happening before the comperator is comparing a 2nd time, the now unequal value will only be compared after the bot reached the location of "input 2", with the unequal comperator result the signal/bot is routed out of the function, which in this case means it just goes to idle and the entire loop restarts, and the bot is setting the variable in the function to the value of "input 1" again, ergo the bot moves back from the location of "input 2" to the location of "input 1"

i hope this explanation on my little example shows u that ur stuff could have never worked because ur not changing values of any of ur variables, in ur screenshot, and ur also not doing anythign with a change that could have happened
< >
Showing 1-8 of 8 comments
Per page: 1530 50