Solved Remove file extension from message

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

CormanYT

Active Member
Jan 6, 2018
122
5
18
So, I've been using this code with skUtilities to create a sort of /scripts command
code_language.skript:
command /scripts:
    trigger:
        clear {iBasics.scripts::*}
        loop directory "plugins\Skript\scripts"'s files:
            add loop-value to {iBasics.scripts::*}
        set {_count} to 0
        loop {iBasics.scripts::*}:
            increase {_count} by 1
        message "Scripts (%{_count}%): &a%{iBasics.scripts::*}%"
The two errors I have is that
1. It shows the whole file path like C:\Windows\Desktop\etc
2. It shows a .sk at the end
For the first issue, I've had 2 ideas to fix it and tried one of those ideas
The first idea was to split it by "\", then take the last one in the list of "\" and use it. That would theoritically give me a Skript Name.sk, but it didnt work
The second idea was to remove all the letters until the last \. but I didn't know how to do that
I have no idea how to solve the second issue.

I want it to be like
Scripts (4): This, That, Those, These
Well not those names but like you get the point. I'll give information if needed, and will install an addon if needed. Thanks!
 
ok so i tested this and it works. The number 10 you see there in "{_test::10}" that is how far into the folder you are. Now I was testing this on a mac, so that's how far into the directories it was, so just adjust that number until it starts to show your skript names. I also went a little further into this, and created a system, to separate your negated/disabled scripts to make them red, and your enabled scripts are green. Also made the commas white, because it looks nicer
EXAMPLE:
dBEzZih.png

code_language.skript:
command /scripts:
    trigger:
        loop directory "plugins\Skript\scripts"'s files:
            if loop-value contains ".sk":
                set {_test::*} to loop-value split by "/"
                set {_test2::*} to {_test::10} split by "."
                add {_test2::1} to {_iBasics.scripts::*}
        loop {_iBasics.scripts::*}:
            if loop-value contains "-":
                add loop-value to {_iBasics.scripts1::*}
                replace all "-" in {_iBasics.scripts1::*} with ""
            else:
                add loop-value to {_iBasics.scripts2::*}
        loop {_iBasics.scripts1::*}:
            add "&c%loop-value%" to {_iBasics.scripts3::*}
        loop {_iBasics.scripts2::*}:
            add "&a%loop-value%" to {_iBasics.scripts3::*}
        set {_count} to 0
        loop {_iBasics.scripts::*}:
            increase {_count} by 1
        set {_test} to "%{_iBasics.scripts3::*}%"
        replace all " and" in {_test} with ","
        replace all "," in {_test} with "&f,"
        message "Scripts (%{_count}%): %{_test}%"
 
Last edited by a moderator:
I slightly modified your code to work for windows. Now it gives me such an odd message with this code:
code_language.skript:
command /scripts:
    trigger:
        loop directory "plugins\Skript\scripts"'s files:
            if loop-value contains ".sk":
                set {_test::*} to loop-value split by "\"
                set {_test2::*} to {_test::10} split by "."
                add {_test2::1} to {_iBasics.scripts::*}
        loop {_iBasics.scripts::*}:
            if loop-value contains "-":
                add loop-value to {_iBasics.scripts1::*}
                replace all "-" in {_iBasics.scripts1::*} with ""
            else:
                add loop-value to {_iBasics.scripts2::*}
        loop {_iBasics.scripts1::*}:
            add "&c%loop-value%" to {_iBasics.scripts3::*}
        loop {_iBasics.scripts2::*}:
            add "&a%loop-value%" to {_iBasics.scripts3::*}
        set {_count} to 0
        loop {_iBasics.scripts::*}:
            increase {_count} by 1
        set {_test} to "%{_iBasics.scripts3::*}%"
        replace all " and" in {_test} with ","
        replace all "," in {_test} with "&f,"
        message "Scripts (%{_count}%): %{_test}%"
Scripts (3): scripts, scripts, scripts
That is not what my scripts are named! Hoping anyone could find a way to solve this, thanks!
 
I already told you exactly how to fix that part:

" The number 10 you see there in "{_test::10}" that is how far into the folder you are. Now I was testing this on a mac, so that's how far into the directories it was, so just adjust that number until it starts to show your skript names."
[doublepost=1533319571,1533319513][/doublepost]you most likely need to change the number to 11
 
I already told you exactly how to fix that part:

" The number 10 you see there in "{_test::10}" that is how far into the folder you are. Now I was testing this on a mac, so that's how far into the directories it was, so just adjust that number until it starts to show your skript names."
[doublepost=1533319571,1533319513][/doublepost]you most likely need to change the number to 11
Why don't you use the last element of the list?
 
Why don't you use the last element of the list?
oh damn you are right, that would work, back to the drawing board :emoji_wink:
[doublepost=1533322583,1533321616][/doublepost]okay i reformatted it, so it doesn't need the specific part of the directory
code_language.skript:
command /scripts:
    trigger:
        loop directory "plugins\Skript\scripts"'s files:
            if loop-value contains ".sk":
                set {_test::*} to loop-value split by "\"
                set {_test} to the last element of {_test::*}
                set {_test2::*} to {_test} split at "."
                add {_test2::1} to {_iBasics.scripts::*}
        loop {_iBasics.scripts::*}:
            if loop-value contains "-":
                add loop-value to {_iBasics.scripts1::*}
                replace all "-" in {_iBasics.scripts1::*} with ""
            else:
                add loop-value to {_iBasics.scripts2::*}
        loop {_iBasics.scripts1::*}:
            add "&c%loop-value%" to {_iBasics.scripts3::*}
        loop {_iBasics.scripts2::*}:
            add "&a%loop-value%" to {_iBasics.scripts3::*}
        set {_count} to 0
        loop {_iBasics.scripts::*}:
            increase {_count} by 1
        set {_test} to "%{_iBasics.scripts3::*}%"
        replace all " and" in {_test} with ","
        replace all "," in {_test} with "&f,"
        message "Scripts (%{_count}%): %{_test}%"
 
  • Like
Reactions: TPGamesNL
Status
Not open for further replies.