Solved Place banner by command

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

Aralwen

Active Member
May 26, 2017
164
14
18
25
Hello,
I try to do the following: Place a banner at a position of a pointed block that I defined beforehand.

My actual code :
code_language.skript:
command /setloc:
    trigger:
        set {Game.Position::BANNER} to location of target block
        send "&a&l[✓] &fThe &bbanner has been successfully defined:"
        send "&7&o%{Game.Position::BANNER}%"
         
command /bb:
    trigger:
        set {_x} to x-coord of {Game.Position::BANNER}
        set {_y} to y-coord of {Game.Position::BANNER}
        set {_z} to z-coord of {Game.Position::BANNER}
        broadcast "%{_x}% %{_y}% %{_z}%"
        wait 5 ticks
        execute console command "/setblock %{_x}% %{_y}% %{_z}% banner"

If possible I would like it to be without the use of execute console command, but I do not know if that is possible.

Thank's !
 
code_language.skript:
set block at {Game.Position::BANNER} to banner
Thank's, it works perfectly, but it is placed in the sky: It does not cling to the block

I'ts give this :
G8ZpwGF.png


But i want :
DKnzKBW.png
 
As @Lego_freak1999 Said. Skript has a built in aliases system which can also define the rotation/data value of a block if it has multiple data values. It changes the data value of any block and what that changes varies on the block/material. You can fix what numbers change to what data value of the block it in your aliases if needed. This automatically works for every block/material no matter if it has a data value. You just have to play around with aliases to get what you want.

For default aliases this should work:
code_language.skript:
set block at {Game.Position::BANNER} to wall banner:1 #north
set block at {Game.Position::BANNER} to wall banner:3 #south
set block at {Game.Position::BANNER} to wall banner:4 #west
set block at {Game.Position::BANNER} to wall banner:5 #east

Don't ask why it skips the number 2. It's Skript lol. More like Skipt am I right? lol quality pun.

And if you want to calculate stuff live, I have also made a function to make this easier on a user.
code_language.skript:
function getDirectionalBlock(i: item, d: direction) :: item:
    set {_block::north} to 1
    set {_block::south} to 3
    set {_block::west} to 4
    set {_block::east} to 5
    return "%{_i}%:%{_block::%{_d}%}%" parsed as item
Example:
code_language.skript:
set block at {Game.Position::BANNER} to getDirectionalBlock(wall banner, west)

I have also made a function to get the opposing direction of a direction
code_language.skript:
function getOppositeDirection(d: direction) :: direction:
    set {_s} to "%{_d}%"
    loop {_s} split at "and":
        if {_direction} is not set:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
        else if "%the numbers in loop-value%" parsed as number > {_direction}:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
    if {_final} contains "north":
        return north
    else if {_final} contains "east":
        return east
    else if {_final} contains "south":
        return south
    else if {_final} contains "west":
        return west
Example:
code_language.skript:
set block at {Game.Position::BANNER} to getDirectionalBlock(wall banner, getOppositeDirection(facing of player))

This function above needs Skellett and if you want better directional I suggest using SkQuery for the "direction from" expression.

Example using SkQuery:
This example will make it so the chest block will always look at a player
code_language.skript:
function getOppositeDirection(d: direction) :: direction:
    set {_s} to "%{_d}%"
    loop {_s} split at "and":
        if {_direction} is not set:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
        else if "%the numbers in loop-value%" parsed as number > {_direction}:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
    if {_final} contains "north":
        return north
    else if {_final} contains "east":
        return east
    else if {_final} contains "south":
        return south
    else if {_final} contains "west":
        return west
function getDirectionalBlock(i: item, d: direction) :: item:
    set {_block::north} to 1
    set {_block::south} to 3
    set {_block::west} to 4
    set {_block::east} to 5
    return "%{_i}%:%{_block::%{_d}%}%" parsed as item
command /lookatme:
    trigger:
        set {_direction} to direction from target block to player
        set {_opposite} to getOppositeDirection({_direction})
        set {_block} to getDirectionalBlock(chest, {_opposite})
        set target block to {_block}

A banner block does have up to 8 different directional positions (Not the wall banner though) so you will have to play around with that, as my function doesn't support 8 dimensional sides.
 
Last edited by a moderator:
  • Like
Reactions: Aralwen
As @Lego_freak1999 Said. Skript has a built in aliases system which can also define the rotation/data value of a block if it has multiple data values. It changes the data value of any block and what that changes varies on the block/material. You can fix what numbers change to what data value of the block it in your aliases if needed. This automatically works for every block/material no matter if it has a data value. You just have to play around with aliases to get what you want.

For default aliases this should work:
code_language.skript:
set block at {Game.Position::BANNER} to wall banner:1 #north
set block at {Game.Position::BANNER} to wall banner:3 #south
set block at {Game.Position::BANNER} to wall banner:4 #west
set block at {Game.Position::BANNER} to wall banner:5 #east

Don't ask why it skips the number 2. It's Skript lol. More like Skipt am I right? lol quality pun.

And if you want to calculate stuff live, I have also made a function to make this easier on a user.
code_language.skript:
function getDirectionalBlock(i: item, d: direction) :: item:
    set {_block::north} to 1
    set {_block::south} to 3
    set {_block::west} to 4
    set {_block::east} to 5
    return "%{_i}%:%{_block::%{_d}%}%" parsed as item
Example:
code_language.skript:
set block at {Game.Position::BANNER} to getDirectionalBlock(wall banner, west)

I have also made a function to get the opposing direction of a direction
code_language.skript:
function getOppositeDirection(d: direction) :: direction:
    set {_s} to "%{_d}%"
    loop {_s} split at "and":
        if {_direction} is not set:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
        else if "%the numbers in loop-value%" parsed as number > {_direction}:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
    if {_final} contains "north":
        return north
    else if {_final} contains "east":
        return east
    else if {_final} contains "south":
        return south
    else if {_final} contains "west":
        return west
Example:
code_language.skript:
set block at {Game.Position::BANNER} to getDirectionalBlock(wall banner, getOppositeDirection(facing of player))

This function above needs Skellett and if you want better directional I suggest using SkQuery for the "direction from" expression.

Example using SkQuery:
This example will make it so the chest block will always look at a player
code_language.skript:
function getOppositeDirection(d: direction) :: direction:
    set {_s} to "%{_d}%"
    loop {_s} split at "and":
        if {_direction} is not set:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
        else if "%the numbers in loop-value%" parsed as number > {_direction}:
            set {_direction} to "%numbers in loop-value%" parsed as number
            set {_final} to loop-value
    if {_final} contains "north":
        return north
    else if {_final} contains "east":
        return east
    else if {_final} contains "south":
        return south
    else if {_final} contains "west":
        return west
function getDirectionalBlock(i: item, d: direction) :: item:
    set {_block::north} to 1
    set {_block::south} to 3
    set {_block::west} to 4
    set {_block::east} to 5
    return "%{_i}%:%{_block::%{_d}%}%" parsed as item
command /lookatme:
    trigger:
        set {_direction} to direction from target block to player
        set {_opposite} to getOppositeDirection({_direction})
        set {_block} to getDirectionalBlock(chest, {_opposite})
        set target block to {_block}

A banner block does have up to 8 different directional positions (Not the wall banner though) so you will have to play around with that, as my function doesn't support 8 dimensional sides.

Thank you very much, you have done more than help me! :emoji_slight_smile:
Thank's for this function !
 
Status
Not open for further replies.