Solved Autofarmer

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Mattllama987

Active Member
Aug 5, 2018
225
7
18
25
Hi, how can i get this to set a random crop in the inventory? After 5 seconds, it will fill the whole inv with the crop. I want to add 1 crop to the slot at a time, and not fill up the inv.
https://gyazo.com/828df4f3f45325831d4d3c5e3749540a
Thanks!
~Matt

Code:

Code:
on inventory click:
    if "%event.getView().getTitle()%" = "&c&lAuto farming":
        cancel event
        if index of event-slot is 45:
            if {autofarm::time::%player%} >= 1:
                set {farm::%Player%} to true
                send "&a&lAutofarmer started!"
                while {farm::%Player%} is true:
                    if {custom::prefix::%Player%} = "&9[&bOutcast&9]":
                        set {cast} to random element out of carrots, wheat and potato
                        set {var} to -1
                        loop 44 times:
                            add 1 to {var}
                            set slot {var} of player's current inventory to {cast}
                    wait 5 seconds
 
I do not know if I fully understand you. What about using:
Code:
#...
if {custom::prefix::%Player%} = "&9[&bOutcast&9]":
    set {_cast} to random element out of carrots, wheat and potato
    set {_var} to random integer between 0 and 44
    set slot {_var} of current inventory of player to {_cast}
    #...
Note: I did not test it but it should work.
 
I do not know if I fully understand you. What about using:
Code:
#...
if {custom::prefix::%Player%} = "&9[&bOutcast&9]":
    set {_cast} to random element out of carrots, wheat and potato
    set {_var} to random integer between 0 and 44
    set slot {_var} of current inventory of player to {_cast}
    #...
Note: I did not test it but it should work.
Thank you for responding to me! When i use that code, it will randomize the slots, and if that chosen slot has carrots, it will replace that slot with another crop after a random time. I, going to post a gif of what is happening. I need it to choose the rows at the top and start filling down like a normal inv. But thats close to what im needing :emoji_slight_smile:
https://gyazo.com/f57776d004cff0391b3e2272687fb036
[doublepost=1590881841,1590865937][/doublepost]Ive updated it alot, and now its like breaking. No errors, just not working.
https://gyazo.com/3ad812f6fb0e34c20f42fc0a2b541048

It should be spawning the crops in the inventory, and when i close the inv, it would save it. Then when i open the inv, the crops should be there. But is all kinds of messed up now..

Code:
on inventory click:
    if "%event.getView().getTitle()%" = "&c&lAuto farming":
        cancel event
        if index of event-slot is 45:
            if {autofarm::time::%player%} >= 1:
                set {farm::%Player%} to true
                send "&a&lAutofarmer started!"
                while {farm::%Player%} is true:
                    if {custom::prefix::%Player%} = "&9[&bOutcast&9]":
                        set {_cast} to random element out of carrots, wheat and potato
                        wait 5 seconds
                        if "%event.getView().getTitle()%" = "&c&lAuto farming":
                            add {_cast} to player's current inventory
                            farmersave(player)
function Autofarmer(P: player):
    open chest inventory with 6 rows named "&a&lAutofarmer" to {_P}
    set {_var} to -1
    set {_var2} to 45
    loop 10 times:
        set slot {_var} of {_P}'s current inventory to black stained glass pane named ""
        set slot {_var2} of {_P}'s current inventory to black stained glass pane named ""
        add 1 to {_var}
        add 1 to {_var2}
    set slot 40 of {_P}'s current inventory to barrier named "&c&lClose"
    set slot 9 of {_P}'s current inventory to lever named "&aChange speed"
    set slot 11 of {_P}'s current inventory to glowing hopper named "&cOpen farm menu"
function farmersave(P: player):
    open chest with 6 rows named "&c&lAuto farming" to {_P}
    set {_slot} to -1
    loop 45 times:
        set slot {_slot} of current inventory of {_P} to {autofarmer::%{_slot}%::%{_P}%}
        add 1 to {_slot}
    set {_var} to -1
    set {_var2} to 45
    loop 10 times:
        set slot {_var} of {_P}'s current inventory to black stained glass pane named ""
        set slot {_var2} of {_P}'s current inventory to black stained glass pane named ""
        add 1 to {_var}
        add 1 to {_var2}
    set slot 40 of {_P}'s current inventory to barrier named "&c&lClose"
    set slot 9 of {_P}'s current inventory to lever named "&aChange speed"
    set slot 11 of {_P}'s current inventory to glowing hopper named "&cOpen farm menu"
on inventory close:
    if "%event.getView().getTitle()%" = "&c&lAuto farming":
        set {_slot} to -1
        loop 45 times:
            set {autofarmer::%{_slot}%::%player%} to slot {_slot} of current inventory of player
            add 1 to {_slot}
 
You're opening a new inventory with farmersave() after adding a crop to the last inventory
 
Status
Not open for further replies.