Issue with options - what is wrong here?

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

pepper82

Member
Jan 26, 2017
272
1
18
Hi all,
I have this script:

code_language.skript:
options:
   sword_material: wooden sword,stone sword,iron sword,golden sword,diamond sword

command /mytest [<text>]:
   trigger:
       set {_material::*} to "{@sword_material}" split at ","
       set {_item} to a random object ouf of {_material::*}
       give {_item} to player

But when reloading the script it says:

ovsLbOZ.png


What is wrong there?

And one more thing:

how can I name an item when the item is a variable?

this does not work:

code_language.skript:
        set {_mt} to an iron sword
        set {_mt}'s name to "&dTESTITEM"
        give {_mt} to player
 
Last edited:
For the first thing, you may place some spaces between the swords, because the code can't read a unique name for all of the swords. Ex: (diamond sword, gold sword etc).

For the second thing, you can do like that to use less lines:
code_language.skript:
        set {_mt} to an iron sword named "&dTESTITEM"
        give {_mt} to player
 
Hi all,
I have this script:

code_language.skript:
options:
   sword_material: wooden sword,stone sword,iron sword,golden sword,diamond sword

command /mytest [<text>]:
   trigger:
       set {_material::*} to "{@sword_material}" split at ","
       set {_item} to a random object ouf of {_material::*}
       give {_item} to player

But when reloading the script it says:

ovsLbOZ.png


What is wrong there?

And one more thing:

how can I name an item when the item is a variable?

this does not work:

code_language.skript:
        set {_mt} to an iron sword
        set {_mt}'s name to "&dTESTITEM"
        give {_mt} to player
The aliases section is a much better fit for this. To fix this error, you can do split x at x instead of x split at x
 
So like, this isn't my post, but I changed the "split at" to be correct according to Pikachu and this post just to double check, and there are no errors now, but I still don't get the item, so I added a broadcast event just to make sure it's going through, you just don't get the item for some reason.
code_language.skript:
options:
   sword_material: wood sword,stone sword,iron sword,gold sword,diamond sword
 
command /mytest [<text>]:
    trigger:
        set {_material::*} to split "{@sword_material}" at ","
        set {_item} to a random object out of {_material::*}
        give {_item} to player
        broadcast "%{_item}%"
 
What he had is supposed to be valid, however a parser bug has currently broken it.
 
So I see, any idea on why you don't get the item, or is that parser bug part of that?
 
Yes, it's because you're trying to give a string. parse it as an item and it will be fixed
code_language.skript:
give (random element out of split "{@sword_material}" at ",") parsed as an item to player
 
  • Like
Reactions: pepper82
Yes, it's because you're trying to give a string. parse it as an item and it will be fixed
code_language.skript:
give (random element out of split "{@sword_material}" at ",") parsed as an item to player
Alright cool! Thanks.
 
Status
Not open for further replies.