gen Skript breaks itself with no errors

  • 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.

ItzSulf

New Member
Jul 15, 2022
7
0
1
21
Here i have a gen skript im working on, everything works fine and skript reloads with no errors.


once the player gets to tier 17 "bamboo" they lose ownership over the gen so they cant break the gen or upgrade it any further. the only way to combat this is if they place tier 17 then upgrade it but once upgraded they lose ownership of that.


Code:
options:
    ServerName: test
    moneyvariable: {test::%player's uuid%}

#Registration of gens
on load:
    #registerGen(ID, Tag, (block named "name" with lore "lore"), block, upgrade cost, (dropitem named "name" with lore "lore" and "lore"))
   
    registerGen(1, "dirt_gen", (dirt named "&x&9&B&7&6&5&3&lDIRT GENERATOR &8[&x&9&B&7&6&5&3&lT1&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&5&C&4&0&3&3Podzol" and "&8• &7Upgrade Cost: &x&9&B&7&6&5&31⛃" and "&8• &7Drop Value: &x&9&B&7&6&5&31⛃" and " " and "&x&9&B&7&6&5&3&lEXCLUSIVE"), dirt, 10, (brown dye named "&x&9&B&7&6&5&3&lDIRT" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&9&B&7&6&5&31⛃" and "&8•&7 Sell with &x&9&B&7&6&5&3/sell" and " " and "&x&9&B&7&6&5&3&lSPECIAL"))

    registerGen(2, "podzol_gen", (podzol named "&x&5&C&4&0&3&3&lPODZOL GENERATOR &8[&x&5&C&4&0&3&3&lT2&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&3&4&8&C&3&1Grass" and "&8• &7Upgrade Cost: &x&5&C&4&0&3&31⛃" and "&8• &7Drop Value: &x&5&C&4&0&3&31⛃" and " " and "&x&5&C&4&0&3&3&lEXCLUSIVE"), podzol, 11, (podzol named "&x&5&C&4&0&3&3&lPODZOL" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&5&C&4&0&3&31⛃" and "&8•&7 Sell with &x&5&C&4&0&3&3/sell" and " " and "&x&5&C&4&0&3&3&lSPECIAL"))

    registerGen(3, "grass_gen", (grass block named "&x&3&4&8&C&3&1&lGRASS GENERATOR &8[&x&3&4&8&C&3&1&lT3&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &eWheat" and "&8• &7Upgrade Cost: &x&3&4&8&C&3&11⛃" and "&8• &7Drop Value: &x&3&4&8&C&3&11⛃" and " " and "&x&3&4&8&C&3&1&lEXCLUSIVE"), grass block, 12, (fern named "&x&3&4&8&C&3&1&lGRASS" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&3&4&8&C&3&11⛃" and "&8•&7 Sell with &x&3&4&8&C&3&1/sell" and " " and "&x&3&4&8&C&3&1&lSPECIAL"))

    registerGen(4, "wheat_gen", (hay block named "&e&lWHEAT GENERATOR &8[&e&lT4&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&F&F&A&5&0&0Carrot" and "&8• &7Upgrade Cost: &e1⛃" and "&8• &7Drop Value: &e1⛃" and " " and "&e&lEXCLUSIVE"), hay block, 13, (wheat named "&e&lWHEAT" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &e1⛃" and "&8•&7 Sell with &e/sell" and " " and "&e&lSPECIAL"))

    registerGen(5, "carrot_gen", (orange concrete named "&x&F&F&A&5&0&0&lCARROT GENERATOR &8[&x&F&F&A&5&0&0&lT5&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&B&D&9&A&7&APotato" and "&8• &7Upgrade Cost: &x&F&F&A&5&0&01⛃" and "&8• &7Drop Value: &x&F&F&A&5&0&01⛃" and " " and "&x&F&F&A&5&0&0&lEXCLUSIVE"), orange concrete, 14, (carrot named "&x&F&F&A&5&0&0&lCARROT" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&F&F&A&5&0&01⛃" and "&8•&7 Sell with &x&F&F&A&5&0&0/sell" and " " and "&x&F&F&A&5&0&0&lSPECIAL"))

    registerGen(6, "potato_gen", (brown concrete named "&x&B&D&9&A&7&A&lPOTATO GENERATOR &8[&x&B&D&9&A&7&A&lT6&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&F&E&F&F&F&ESugarcane" and "&8• &7Upgrade Cost: &x&B&D&9&A&7&A1⛃" and "&8• &7Drop Value: &x&B&D&9&A&7&A1⛃" and " " and "&x&B&D&9&A&7&A&lEXCLUSIVE"), brown concrete, 15, (potato named "&x&B&D&9&A&7&A&lPOTATO" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&B&D&9&A&7&A1⛃" and "&8•&7 Sell with &x&B&D&9&A&7&A/sell" and " " and "&x&B&D&9&A&7&A&lSPECIAL"))

    registerGen(7, "sugarcane_gen", (green concrete named "&x&F&E&F&F&F&E&lSUGARCANE GENERATOR &8[&x&F&E&F&F&F&E&lT7&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&B&D&D&4&9&AMelon" and "&8• &7Upgrade Cost: &x&F&E&F&F&F&E1⛃" and "&8• &7Drop Value: &x&F&E&F&F&F&E1⛃" and " " and "&x&F&E&F&F&F&E&lEXCLUSIVE"), green concrete , 16, (sugar named "&x&F&E&F&F&F&E&LSUGAR" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&F&E&F&F&F&E1⛃" and "&8•&7 Sell with &x&F&E&F&F&F&E/sell" and " " and "&x&F&E&F&F&F&E&lSPECIAL"))

    registerGen(8, "melon_gen", (melon named "&x&B&D&D&4&9&A&lMELON GENERATOR &8[&x&B&D&D&4&9&A&lT8&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&F&F&7&5&1&8&lPumpkin" and "&8• &7Upgrade Cost: &x&B&D&D&4&9&A1⛃" and "&8• &7Drop Value: &x&B&D&D&4&9&A1⛃" and " " and "&x&B&D&D&4&9&A&lEXCLUSIVE"), melon, 17, (melon slice named "&x&B&D&D&4&9&A&lWATERMELON" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&B&D&D&4&9&A1⛃" and "&8•&7 Sell with &x&B&D&D&4&9&A/sell" and " " and "&x&B&D&D&4&9&A&lSPECIAL"))

    registerGen(9, "pumpkin_gen", (pumpkin named "&x&F&F&7&5&1&8&lPUMPKIN GENERATOR &8[&x&F&F&7&5&1&8&lT9&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&E&2&0&6&2&CApple" and "&8• &7Upgrade Cost: &x&F&F&7&5&1&81⛃" and "&8• &7Drop Value: &x&F&F&7&5&1&81⛃" and " " and "&x&F&F&7&5&1&8&lEXCLUSIVE"), melon, 18, (pumpkin pie named "&x&F&F&7&5&1&8&lPUMPKIN PIE" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&F&F&7&5&1&81⛃" and "&8•&7 Sell with &x&F&F&7&5&1&8/sell" and " " and "&x&F&F&7&5&1&8&lSPECIAL"))

    registerGen(10, "apple_gen", (red concrete named "&x&E&2&0&6&2&C&lAPPLE GENERATOR &8[&x&E&2&0&6&2&C&lT10&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&6&0&7&8&6&0Cactus" and "&8• &7Upgrade Cost: &x&E&2&0&6&2&C1⛃" and "&8• &7Drop Value: &x&E&2&0&6&2&C1⛃" and " " and "&x&E&2&0&6&2&C&lEXCLUSIVE"), red concrete, 19, (apple named "&x&E&2&0&6&2&C&lAPPLE" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&E&2&0&6&2&C1⛃" and "&8•&7 Sell with &x&E&2&0&6&2&C/sell" and " " and "&x&E&2&0&6&2&C&lSPECIAL"))

    registerGen(11, "cactus_gen", (green terracotta named "&x&6&0&7&8&6&0&lCACTUS GENERATOR &8[&x&6&0&7&8&6&0&lT11&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&9&E&3&3&5&0Beetroot" and "&8• &7Upgrade Cost: &x&6&0&7&8&6&01⛃" and "&8• &7Drop Value: &x&6&0&7&8&6&01⛃" and " " and "&x&6&0&7&8&6&0&lEXCLUSIVE"), green terracotta, 20, (cactus named "&x&6&0&7&8&6&0&lCACTUS" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&6&0&7&8&6&01⛃" and "&8•&7 Sell with &x&6&0&7&8&6&0/sell" and " " and "&x&6&0&7&8&6&0&lSPECIAL"))

    registerGen(12, "beetroot_gen", (red terracotta named "&x&9&E&3&3&5&0&lBEETROOT GENERATOR &8[&x&9&E&3&3&5&0&lT12&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&8&B&0&0&0&0Netherwart" and "&8• &7Upgrade Cost: &x&9&E&3&3&5&01⛃" and "&8• &7Drop Value: &x&9&E&3&3&5&01⛃" and " " and "&x&9&E&3&3&5&0&lEXCLUSIVE"), red terracotta, 21, (beetroot named "&x&9&E&3&3&5&0&lBEETROOT" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&9&E&3&3&5&01⛃" and "&8•&7 Sell with &x&9&E&3&3&5&0/sell" and " " and "&x&9&E&3&3&5&0&lSPECIAL"))

    registerGen(13, "netherwart_gen", (red wool named "&x&8&B&0&0&0&0&lNETHERWART GENERATOR &8[&x&8&B&0&0&0&0&lT13&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&F&A&E&0&3&3Sunflower" and "&8• &7Upgrade Cost: &x&8&B&0&0&0&01⛃" and "&8• &7Drop Value: &x&8&B&0&0&0&01⛃" and " " and "&x&8&B&0&0&0&0&lEXCLUSIVE"), red wool, 22, (nether wart named "&x&8&B&0&0&0&0&lNETHERWART" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&8&B&0&0&0&01⛃" and "&8•&7 Sell with &x&8&B&0&0&0&0/sell" and " " and "&x&8&B&0&0&0&0&lSPECIAL"))

    registerGen(14, "sunflower_gen", (yellow concrete named "&x&F&A&E&0&3&3&lSUNFLOWER GENERATOR &8[&x&F&A&E&0&3&3&lT14&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&B&5&6&5&1&DBrown Mushroom" and "&8• &7Upgrade Cost: &x&F&A&E&0&3&31⛃" and "&8• &7Drop Value: &x&F&A&E&0&3&31⛃" and " " and "&x&F&A&E&0&3&3&lEXCLUSIVE"), yellow concrete, 10, (sunflower named "&x&F&A&E&0&3&3&lSUNFLOWER" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&F&A&E&0&3&31⛃" and "&8•&7 Sell with &x&F&A&E&0&3&3/sell" and " " and "&x&F&A&E&0&3&3&lSPECIAL"))

    registerGen(15, "brownmushroom_gen", (brown mushroom block named "&x&B&5&6&5&1&D&lBROWN MUSHROOM GENERATOR &8[&x&B&5&6&5&1&D&lT15&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&D&C&1&4&3&CRed Mushroom" and "&8• &7Upgrade Cost: &x&B&5&6&5&1&D1⛃" and "&8• &7Drop Value: &x&B&5&6&5&1&D1⛃" and " " and "&x&B&5&6&5&1&D&lEXCLUSIVE"), brown mushroom block, 10, (brown mushroom named "&x&B&5&6&5&1&D&lBROWN MUSHROOM" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&B&5&6&5&1&D1⛃" and "&8•&7 Sell with &x&B&5&6&5&1&D/sell" and " " and "&x&B&5&6&5&1&D&lSPECIAL"))

    registerGen(16, "redmushroom_gen", (red mushroom block named "&x&D&C&1&4&3&C&lRED MUSHROOM GENERATOR &8[&x&D&C&1&4&3&C&lT16&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&D&2&B&0&4&CBamboo" and "&8• &7Upgrade Cost: &x&D&C&1&4&3&C1⛃" and "&8• &7Drop Value: &x&D&C&1&4&3&C1⛃" and " " and "&x&D&C&1&4&3&C&lEXCLUSIVE"), red mushroom block, 10, (red mushroom named "&x&D&C&1&4&3&C&lRED MUSHROOM" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&D&C&1&4&3&C1⛃" and "&8•&7 Sell with &x&D&C&1&4&3&C/sell" and " " and "&x&D&C&1&4&3&C&lSPECIAL"))

    registerGen(17, "bamboo_gen", (green glazed terracotta named "&x&D&2&B&0&4&C&lBAMBOO GENERATOR &8[&x&D&2&B&0&4&C&lT17&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&8&0&0&0&0&0Sweetberry" and "&8• &7Upgrade Cost: &x&D&2&B&0&4&C1⛃" and "&8• &7Drop Value: &x&D&2&B&0&4&C1⛃" and " " and "&x&D&2&B&0&4&C&lEXCLUSIVE"), green glazed terracotta, 10, (bamboo named "&x&D&2&B&0&4&C&lBAMBOO" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&D&2&B&0&4&C1⛃" and "&8•&7 Sell with &x&D&2&B&0&4&C/sell" and " " and "&x&D&2&B&0&4&C&lSPECIAL"))

    registerGen(18, "sweetberry_gen", (red glazed terracotta named "&x&8&0&0&0&0&0&lSWEETBERRY GENERATOR &8[&x&8&0&0&0&0&0&lT18&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&F&B&B&F&7&7Glowberry" and "&8• &7Upgrade Cost: &x&8&0&0&0&0&01⛃" and "&8• &7Drop Value: &x&8&0&0&0&0&01⛃" and " " and "&x&8&0&0&0&0&0&lEXCLUSIVE"), red glazed terracotta, 10, (sweet berry named "&x&8&0&0&0&0&0&lSWEETBERRY" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&8&0&0&0&0&01⛃" and "&8•&7 Sell with &x&8&0&0&0&0&0/sell" and " " and "&x&8&0&0&0&0&0&lSPECIAL"))

    registerGen(19, "glowberry_gen", (yellow glazed terracotta named "&x&F&B&B&F&7&7&lGLOWBERRY GENERATOR &8[&x&F&B&B&F&7&7&lT19&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&4&D&5&5&3&1Kelp" and "&8• &7Upgrade Cost: &x&F&B&B&F&7&71⛃" and "&8• &7Drop Value: &x&F&B&B&F&7&71⛃" and " " and "&x&F&B&B&F&7&7&lEXCLUSIVE"), yellow glazed terracotta, 10, (glow berry named "&x&F&B&B&F&7&7&lGLOWBERRY" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&F&B&B&F&7&71⛃" and "&8•&7 Sell with &x&F&B&B&F&7&7/sell" and " " and "&x&F&B&B&F&7&7&lSPECIAL"))

    registerGen(20, "kelp_gen", (lime glazed terracotta named "&x&4&D&5&5&3&1&lKELP GENERATOR &8[&x&4&D&5&5&3&1&lT20&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &x&D&8&B&5&8&9Oak Log" and "&8• &7Upgrade Cost: &x&4&D&5&5&3&11⛃" and "&8• &7Drop Value: &x&4&D&5&5&3&11⛃" and " " and "&x&4&D&5&5&3&1&lEXCLUSIVE"), lime glazed terracotta, 10, (kelp named "&x&4&D&5&5&3&1KELP" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&4&D&5&5&3&11⛃" and "&8•&7 Sell with &x&4&D&5&5&3&1/sell" and " " and "&x&4&D&5&5&3&1&lSPECIAL"))

    registerGen(21, "log_gen", (oak wood named "&x&D&8&B&5&8&9&lLOG GENERATOR &8[&x&D&8&B&5&8&9&lT21&8]" with lore " " and "&8&lSTATS:" and "&8• &7Next Tier: &cMaxed" and "&8• &7Upgrade Cost: &cMaxed" and "&8• &7Drop Value: &x&D&8&B&5&8&91⛃" and " " and "&x&D&8&B&5&8&9&lEXCLUSIVE"), oak wood, 10, (oak wood named "&x&D&8&B&5&8&9OAK LOG" with lore " " and "&8&lSTATS:" and "&8•&7 Sell Value &x&D&8&B&5&8&91⛃" and "&8•&7 Sell with &x&D&8&B&5&8&9/sell" and " " and "&x&D&8&B&5&8&9&lSPECIAL"))


function registerGen(id: integer, discrim: string, item: item, block: item, upgrade: integer, drop: item):
    set {gens::internal::%{_id}%} to {_discrim}
    set {gen::internal::%{_id}%::item} to {_item}
    set {gen::internal::%{_id}%::block} to {_block}
    set {gen::internal::%{_id}%::upgrade} to {_upgrade}
    set {gen::internal::%{_id}%::drop} to {_drop}

#Gen Place
function placeGen(p: player, block: block, id: integer):
    set {_u} to uuid of {_p}
    add location of {_block} to {gens::player::%{_u}%::*}
    set {_discrim} to size of {gens::player::%{_u}%::*}
    set {_loc} to location of {_block}
    set {gens::all::%{_loc}%} to {_discrim}
    set {gen::player::%{_u}%::%{_discrim}%::id} to {_id}

on place:
    loop {gens::internal::*}:
        if 1 of player's tool is {gen::internal::%loop-index%::item}:
            if {usedslots::%player's uuid%} < {maxslots::%player's uuid%}:
                placeGen(player, event-block, loop-index parsed as integer)
                add 1 to {usedslots::%player's uuid%}
                send action bar "&6&l{@ServerName} &7You have placed a generator! &e%{usedslots::%player's uuid%}%&6/&e%{maxslots::%player's uuid%}%" to player
            else:
                cancel event
                send action bar "&6&l{@ServerName} &cYou have already reached the maximum generators available!" to player
            exit loop


#Gen Break
on left click:
    player is sneaking
    if {gens::all::%location of clicked block%} is set:
        set {_discrim} to {gens::all::%location of clicked block%}
        if {gens::player::%player's uuid%::*} contains location of clicked block:
            give player {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::item}
            delete {gen::player::%player's uuid%::%{_discrim}%::id}
            remove location of clicked block from {gens::player::%player's uuid%::*}
            remove 1 from {usedslots::%player's uuid%}
            send action bar "&6{@ServerName} &7You have destroyed a generator! &e%{usedslots::%player's uuid%}%&6/&e%{maxslots::%player's uuid%}%" to player
            delete {gens::all::%location of clicked block%}
            set clicked block to air
        else:
            cancel event
            send action bar "&6&l{@ServerName} &cThat isn't your generator!" to player

on break:
    if {gens::all::%location of event-block%} is set:
        play sound "entity.villager.no" for player
        send action bar "&6&l{@ServerName} &cShift left click to pickup your generator!" to player
        cancel event

#Gen Upgrade
on right click:
    if player is sneaking:
        if {gens::all::%location of clicked block%} is set:
            set {_discrim} to {gens::all::%location of clicked block%}
            if {gens::player::%player's uuid%::*} contains location of clicked block:
                cancel event
                set {_level} to {gen::player::%player's uuid%::%{_discrim}%::id} + 1
                if {gens::internal::%{_level}%} is set:
                    if {@moneyvariable} >= {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::upgrade}:
                        remove {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::upgrade} from {@moneyvariable}
                        set clicked block to {gen::internal::%{_level}%::block}
                        add 1 to {gen::player::%player's uuid%::%{_discrim}%::id}
                        send action bar "&6&l{@ServerName} &7Generator upgrade!" to player
                        play sound "ui.toast.challenge_complete" for player
                    else:
                        send action bar "&6&l{@ServerName} &cInsufficient funds!" to player
                else:
                    send "&6&l{@ServerName} &cYou are at the max upgrades!"

on join:
    while player is online:
        loop {gens::player::%player's uuid%::*}:
            drop {gen::internal::%{gen::player::%player's uuid%::%loop-index%::id}%::drop} at block above loop-value without velocity
        wait 10 seconds


command testgens:
    trigger:
        loop {gens::internal::*}:
            give player {gen::internal::%loop-index%::item}

command testmoney:
    trigger:
        set {@moneyvariable} to 10000

command resetslots:
    trigger:
        set {usedslots::%player's uuid%} to 0

command genslist:
    trigger:
        loop 21 times:
            send "%{gen::internal::%loop-value%::item}%"
            send "%{gen::internal::%loop-value%::block}%"
            send "%{gen::internal::%loop-value%::upgrade}%"
            send "%{gen::internal::%loop-value%::drop}%%nl%"
 
Last edited:
Status
Not open for further replies.