String Not Splitting

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

FreezaF

New Member
Jun 29, 2023
7
0
1
15
Code:
on chat:
    if player's name is "Kundaliel":
        if message is "Transmutate":
            loop all players:
                if loop-player's name is "Kundaliel":
                    set {_textO} to name of loop-player's offhand item
                    set {_textM} to name of loop-player's held item
                    
                    set {_o::*} to split {_textO} at " "
                    set {_m::*} to split {_textM} at " "
                    
                    set {_first} to {_o::1}
                    set {_last} to {_m::1}
                    
                    set {_item} to "%{_first}% %{_last}%"
Everything after
set {_textO} to name of loop-player's offhand item
set {_textM} to name of loop-player's held item

Is outputted as <none>
 
I thought you said it was it was returning <none>. What happens if you broadcast the lists?
 
from my testing {_textO} and {_textM} arent set if the name is not set. I was able to get it to work with this
Code:
on chat:
    if player's name is "phill310":
        if message is "do":
            loop all players:
                if loop-player's name is "Phill310":
                    set {_textO} to name of loop-player's offhand item ? type of loop-player's offhand tool
                    set {_textM} to name of loop-player's held item ? type of loop-player's held item

                    broadcast "O: %{_textO}%"
                    broadcast "M: %{_textM}%"

                    set {_o::*} to split "%{_textO}%" at " "
                    set {_m::*} to split "%{_textM}%" at " "

                    broadcast {_o::*}
                    broadcast {_m::*}

                    set {_first} to {_o::1}
                    set {_last} to {_m::1}

                    set {_item} to "%{_first}% %{_last}%"

                    broadcast {_item}
 
from my testing {_textO} and {_textM} arent set if the name is not set. I was able to get it to work with this
Code:
on chat:
    if player's name is "phill310":
        if message is "do":
            loop all players:
                if loop-player's name is "Phill310":
                    set {_textO} to name of loop-player's offhand item ? type of loop-player's offhand tool
                    set {_textM} to name of loop-player's held item ? type of loop-player's held item

                    broadcast "O: %{_textO}%"
                    broadcast "M: %{_textM}%"

                    set {_o::*} to split "%{_textO}%" at " "
                    set {_m::*} to split "%{_textM}%" at " "

                    broadcast {_o::*}
                    broadcast {_m::*}

                    set {_first} to {_o::1}
                    set {_last} to {_m::1}

                    set {_item} to "%{_first}% %{_last}%"

                    broadcast {_item}
this works great, however could you explain what this means?
 
it basically say that if the variable is still not set after the expression before the ?, skript should try to set it to the expression after
its basically the same as
Code:
set {_e} to name of player's tool
if {_e} is not set:
    set {_e} to type of player's tool