Solved Check two regions if they are the same

  • 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 community!

    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.

FreakShears

Member
Mar 2, 2017
2
0
0
I'm trying to write a minigame for my server where a player has to make a "painting" out of some random clay blocks that is shown to him. The paintings are 8x8, so here is the first one:

code_language.skript:
                        set {counter} to 1
                        loop blocks within {bbloc1} to {bbloc2}:
                            set {pblock} to a random integer between 1 and 8
                            set {paintblock} to "159:%{pblock}%"
                            set the loop-block to {paintblock} parsed as item
                            set {drawgiven::%{counter}%} to the loop-block
                            add 1 to {counter}


And here i save to the {drawplayer::*} the painting of the player

code_language.skript:
                        set {counter} to 1
                        loop blocks within {bbloc3} to {bbloc4}:
                            set {drawplayer::%{counter}%} to the loop-block
                            add 1 to {counter}


The comparison doesn't seem to work. Even when both of them are exactly the same the {welldone} turns out to be false always.

code_language.skript:
                        if {drawgiven::*} is {drawplayer::*}:
                            set {welldone} to true
                        else:
                            set {welldone} to false

========================================================
Skript Version: 2.2-dev24b
Skript Author:
Minecraft Version: 1.11.2
---
Full Code:

code_language.skript:
options:
     tag: &ePainter&6» 

variables:
    {painteroccupied} = false
    {painting.%player%} = false

on leftclick holding a blaze rod:
    if player has permission "OP":
        set {bbloc1} to location of clicked block
        send "pos1 has been set"
        send "%{bbloc1}%" to player

on rightclick holding a blaze rod:
    if player has permission "OP":
        set {bbloc2} to location of clicked block
        send "pos2 has been set"
        send "%{bbloc2}%" to player

on rightclick on a sign:
    if line 1 of block is "&1Painter":
        if line 2 of block is empty:
            if line 3 of block is empty:
                if line 4 of block is empty:
                    if {painteroccupied} is true:
                        loop all players:
                            if {painting.%loop-player%} is true:
                                set {_nowpainter} to loop-player
                        if {_nowpainter} is player:
                            send "{@tag} &dI guess you have to restart your game...%nl%Type &a/painter l &dfirst and then rejoin." to player
                        else:
                            set line 2 of block to "&4OCCUPIED"
                            set line 3 of block to "&2%{_nowpainter}%"
                            set line 4 of block to "is playing"
                            message  "{@tag} &dAnother player is playing right now. Go have a look!."
                            make player execute command "/rg tp painter"
                            wait 5 seconds
                            set line 2 of block to ""
                            set line 3 of block to ""
                            set line 4 of block to ""
                    else:
                        make player execute command "/rg tp painterspawn"
                        apply potion of slowness of tier 255 to the player for 4 seconds
                        send "&e&m-------------- &6&l Painter &e&m--------------" to player
                        send "&dWelcome to the Painter!" to player
                        send "&dYou have 4 minutes to make the painting you will be shown" to player
                        set {bbloc1} to the location at -8.5, 13.5, 353.5 of the world "mini_games"
                        set {bbloc2} to the location at -8.5, 6.5, 360.5 of the world "mini_games"
                        set {bbloc3} to the location at -11.5, 4.5, 353.5 of the world "mini_games"
                        set {bbloc4} to the location at -18.5, 4.5, 360.5 of the world "mini_games"
                        set {painteroccupied} to true
                        set {painting.%player%} to true
                        delete {drawplayer::*}
                        delete {drawgiven::*}
                        execute command "/ci %player%"
                        give player 1 diamond pickaxe
                        give player 64 orange stained clay
                        give player 64 magenta stained clay
                        give player 64 light blue stained clay
                        give player 64 yellow stained clay
                        give player 64 light green stained clay
                        give player 64 pink stained clay
                        give player 64 gray stained clay
                        give player 64 light gray stained clay
                        set the player's health to 10
                        set the player's food level to 10

                        wait 1 second
                        set {counter} to 1
                        loop blocks within {bbloc1} to {bbloc2}:
                            set {pblock} to a random integer between 1 and 8
                            set {paintblock} to "159:%{pblock}%"
                            set the loop-block to {paintblock} parsed as item
                            set {drawgiven::%{counter}%} to the loop-block
                            add 1 to {counter}

                        send player title "&c3..." for 1 second
                        wait 1 second
                        send player title "&c2..." for 1 second
                        wait 1 second
                        send player title "&c1..." for 1 second
                        wait 1 second
                        send player title "&aGO!!!" for 2 seconds

                        create timer "paintertimer" for 240 seconds keep active true
                        wait 210 seconds
                        send player title "" with subtitle "&230" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&229" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&228" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&227" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&226" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&225" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&224" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&223" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&222" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&221" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&220" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&219" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&218" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&217" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&216" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&215" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c14" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c13" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c12" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c11" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c10" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c9" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c8" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c7" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&c6" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&45" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&44" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&43" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&42" for 1 second
                        wait 1 second
                        send player title "" with subtitle "&41" for 1 second
                        wait 1 second
                        send player title "&4TIME IS OVER" with subtitle "&eCOLORS UP!" for 3 seconds
                        loop all items in the player's inventory:
                            remove loop-item from the player

                        wait 1 second
                        set {counter} to 1
                        loop blocks within {bbloc3} to {bbloc4}:
                            set {drawplayer::%{counter}%} to the loop-block
                            add 1 to {counter}

                        if {drawgiven::*} is {drawplayer::*}:
                            set {welldone} to true
                        else:
                            set {welldone} to false  
                        send "given: %{drawgiven::*}% --- player:  %{drawplayer::*}%" to player

                        if {welldone} is true:
                            send player title "&aYAY!" with subtitle "&eWhat an artist!" for 5 seconds
                        else:
                            send player title "&4&l✖" with subtitle "&eYou made mistakes!" for 5 seconds
                        wait 5 seconds

                        loop blocks within {bbloc1} to {bbloc2}:
                            set the loop-block to white wool block
                        loop blocks within {bbloc3} to {bbloc4}:
                            set the loop-block to air

                        execute console command "/warp minigames %player%"
                        set {painteroccupied} to false
                        set {painting.%player%} to false
#                        give rewards
                        stop

on quit:
    if {painting.%player%} is true:
        broadcast "{@tag} &b%player% &dleft while playing. Not so artistic talent I guess..."
        set {painteroccupied} to false
        set {painting.%player%} to false

on rightclick on a sign:
    if line 1 of block is "Back to":
        if line 2 of block is "&1&lMinigames":
            if line 3 of block is "&1&llobby":
                if line 4 of block is empty:
                    execute console command "/warp minigames %player%"

command /painter <text>:
    aliases: /painter leave, /painter l 
    usage: /painter [leave]
    executable by: players
    trigger:
        if {painting.%player%} is true:
            if arg-1 is "leave" or "l":
                loop all items in the player's inventory:
                    remove loop-item from the player
                heal the player
                set the player's food level to 10
                send "{@tag} &dYou left the Painter!" to player
                execute console command "/warp minigames %player%"
                set {painteroccupied} to false
                set {painting.%player%} to false
                stop
        else:
            if "%region at player%" contains "painter":
                execute console command "/warp minigames %player%"
            else:
                send "{@tag} &dEhmmm... you are not playing the Painter!" to the player

on command:
    if {painteroccupied} is true:
        if command is not "painter leave" or "painter l":
            send "{@tag} &dYou're not allowed to use commands during the game" to player
            cancel event

Errors on Reload: none

Console Errors: (if applicable) none


Other Useful Info:

Addons using (including versions):
SkQuery v3.5.2-Lime
skRayFall v1.9.7
SharpSK v1.6.1.4

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it?
[doublepost=1489746225,1489703404][/doublepost]I made some changes, my 2 lists have the blocks of the given painting and the player's painting but even when they are exactly the same the comparison still doesn't seem to work.

3524tn9.jpg


My updated code:
code_language.skript:
options:
     tag: &ePainter&6»

variables:
    {painteroccupied} = false
    {painting.%player%} = false

on leftclick holding a blaze rod:
    if player has permission "OP":
        set {bbloc1} to location of clicked block
        send "pos1 has been set"
        send "%{bbloc1}%" to player

on rightclick holding a blaze rod:
    if player has permission "OP":
        set {bbloc2} to location of clicked block
        send "pos2 has been set"
        send "%{bbloc2}%" to player

on rightclick on a sign:
    if line 1 of block is "&1Painter":
        if line 2 of block is empty:
            if line 3 of block is empty:
                if line 4 of block is empty:
                    if {painteroccupied} is true:
                        loop all players:
                            if {painting.%loop-player%} is true:
                                set {_nowpainter} to loop-player
                        if {_nowpainter} is player:
                            send "{@tag} &dI guess you have to restart your game...%nl%Type &a/painter l &dfirst and then rejoin." to player
                        else:
                            set line 2 of block to "&4OCCUPIED"
                            set line 3 of block to "&2%{_nowpainter}%"
                            set line 4 of block to "is playing"
                            message  "{@tag} &dAnother player is playing right now. Go have a look!."
                            make player execute command "/rg tp painter"
                            wait 5 seconds
                            set line 2 of block to ""
                            set line 3 of block to ""
                            set line 4 of block to ""
                    else:
                        make player execute command "/rg tp painterspawn"
                        apply potion of slowness of tier 255 to the player for 4 seconds
                        send "&e&m-------------- &6&l Painter &e&m--------------" to player
                        send "&dWelcome to the Painter!" to player
                        send "&dYou have 4 minutes to make the painting you will be shown" to player
                        set {bbloc1} to the location at -8.5, 13.5, 353.5 of the world "mini_games"
                        set {bbloc2} to the location at -8.5, 6.5, 360.5 of the world "mini_games"
                        set {bbloc3} to the location at -11.5, 4.5, 353.5 of the world "mini_games"
                        set {bbloc4} to the location at -18.5, 4.5, 360.5 of the world "mini_games"
                        set {painteroccupied} to true
                        set {painting.%player%} to true
                        delete {drawplayer::*}
                        delete {drawgiven::*}
                        execute command "/ci %player%"
                        give player 1 diamond pickaxe
                        give player 64 orange stained clay
                        give player 64 magenta stained clay
                        give player 64 light blue stained clay
                        give player 64 yellow stained clay
                        give player 64 light green stained clay
                        give player 64 pink stained clay
                        give player 64 gray stained clay
                        give player 64 light gray stained clay
                        set the player's health to 10
                        set the player's food level to 10

                        wait 1 second
                        loop blocks within {bbloc1} to {bbloc2}:
                            set {pblock} to a random integer between 1 and 8
                            set {paintblock} to "159:%{pblock}%"
                            set the loop-block to {paintblock} parsed as item
                            add loop-block to {drawgiven::*}

                        send player title "&c3..." for 1 second
                        wait 1 second
                        send player title "&c2..." for 1 second
                        wait 1 second
                        send player title "&c1..." for 1 second
                        wait 1 second
                        send player title "&aGO!!!" for 2 seconds

                        set {_paintertimer} to 240
                        wait 1 tick
                        loop 240 times:
                            remove 1 from {_paintertimer}
                            wait 1 second
                            if {_paintertimer} is 180:
                                send player title "" with subtitle "&c3 minutes left" for 1 second
                            if {_paintertimer} is 120:
                                send player title "" with subtitle "&c2 minutes left" for 1 second
                            if {_paintertimer} is 60:
                                send player title "" with subtitle "&c1 minute left" for 1 second
                            if {_paintertimer} is less than 11:
                                send player title "" with subtitle "&c%{_paintertimer}%" for 1 second
                        send player title "&4TIME IS OVER" with subtitle "&eCOLORS UP!" for 3 seconds
                        loop all items in the player's inventory:
                            remove loop-item from the player

                        wait 1 second
                        loop blocks within {bbloc3} to {bbloc4}:
                            add loop-block to {drawplayer::*}

                        set {welldone} to true
                        set {mistakes} to 0
                        set {counter} to 1
                        loop 64 times:
                            send "given: %{drawgiven::%{counter}%}%   --  player: %{drawplayer::%{counter}%}%" to player
                            if {drawgiven::%{counter}%} is not {drawplayer::%{counter}%}:
                                set {welldone} to false
                                add 1 to {mistakes}
                            add 1 to {counter}

                        if {welldone} is true:
                            send player title "&aYAY!" with subtitle "&eWhat an artist!" for 5 seconds
                        else:
                            send player title "&4&l✖" with subtitle "&eYou made &c%{mistakes}% &emistakes!" for 5 seconds
                        wait 5 seconds

                        loop blocks within {bbloc1} to {bbloc2}:
                            set the loop-block to white wool block
                        loop blocks within {bbloc3} to {bbloc4}:
                            set the loop-block to air

                        execute console command "/warp minigames %player%"
                        set {painteroccupied} to false
                        set {painting.%player%} to false
#                        give rewards
                        stop

on quit:
    if {painting.%player%} is true:
        broadcast "{@tag} &b%player% &dleft while playing. Not so artistic talent I guess..."
        set {painteroccupied} to false
        set {painting.%player%} to false

on rightclick on a sign:
    if line 1 of block is "Back to":
        if line 2 of block is "&1&lMinigames":
            if line 3 of block is "&1&llobby":
                if line 4 of block is empty:
                    execute console command "/warp minigames %player%"

command /painter <text>:
    aliases: /painter leave, /painter l
    usage: /painter [leave]
    executable by: players
    trigger:
        if {painting.%player%} is true:
            if arg-1 is "leave" or "l":
                loop all items in the player's inventory:
                    remove loop-item from the player
                heal the player
                set the player's food level to 10
                send "{@tag} &dYou left the Painter!" to player
                execute console command "/warp minigames %player%"
                set {painteroccupied} to false
                set {painting.%player%} to false
                stop
        else:
            if "%region at player%" contains "painter":
                execute console command "/warp minigames %player%"
            else:
                send "{@tag} &dEhmmm... you are not playing the Painter!" to the player

on command:
    if {painteroccupied} is true:
        if command is not "painter leave" or "painter l":
            send "{@tag} &dYou're not allowed to use commands during the game" to player
            cancel event
 
First of all, I have to cry about this whole thing:

code_language.skript:
wait 210 seconds
send player title "" with subtitle "&230" for 1 second
wait 1 second
send player title "" with subtitle "&229" for 1 second
...

Just use a loop, friend:

code_language.skript:
loop 240 times:
    set {_remaining} to 241 - loop-number
    if {_remaining} <= 5:
        send player title "" with subtitle "&4%{_remaining}%" for 1 second
    else if {_remaining} <= 15:
        send player title "" with subtitle "&c%{_remaining}%" for 1 second
    else if {_remaining} <= 30:
        send player title "" with subtitle "&2%{_remaining}%" for 1 second
    wait 1 second

Those 9 lines can replace your 60 lines of code used to send the countdown.

As for it not seeming to compare the blocks correctly, it possibly just has something to do with it instead treating them as a location or something. Hard to tell, but from the debug messages in your screenshot it looks like it should be working. Have you tried instead comparing them as strings?
code_language.skript:
if "%{drawgiven::%{counter}%}%" is not "%{drawplayer::%{counter}%}%":
 
code_language.skript:
if "%{drawgiven::%{counter}%}%" is not "%{drawplayer::%{counter}%}%":
Yes, this works! Thank you Mr_Simba!

First of all, I have to cry about this whole thing:
:emoji_disappointed:so embarrassed... yes you are right, I have no excuse, but to defend myself I was focused to make the comparison work. Already fixed this -check my updated code. :emoji_angel:
 
:emoji_disappointed:so embarrassed... yes you are right, I have no excuse, but to defend myself I was focused to make the comparison work. Already fixed this -check my updated code. :emoji_angel:

:emoji_sweat_smile: No worries, as long as you know now! Loops are super useful with countdowns and timers and stuff like that, it's really important to learn how they work in detail.
 
Status
Not open for further replies.