Is this even possible?

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

LeeifMR

Member
Oct 2, 2024
24
0
1
19
I am trying to make a script where if you attack the player wearing the armor, you get lit on fire. I keep getting so many errors, not even sure if it's possible. Can anyone help?
Code:
options:
    lighterLore: "&7Lighter %amount%"

command /loe add lighter <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to argument 1 parsed as integer
            add "{@lighterLore.replace("%amount%", "%{_amount}%")}" to lore of player's tool
            send "Lore added: &7Lighter %{_amount}%" to player
        else:
            send "You must hold an armor piece to add lore." to player

command /leeifsotherenchants add lighter <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to argument 1 parsed as integer
            add "{@lighterLore.replace("%amount%", "%{_amount}%")}" to lore of player's tool
            send "Lore added: &7Lighter %{_amount}%" to player
        else:
            send "You must hold an armor piece to add lore." to player

on damage:
    attacker is a player
    victim is a player
    victim is wearing any armor:
        set {_lore} to lore of victim's helmet
        {_lore} is not set
        loop {_lore::*}:
            if loop-value contains "Lighter":
                set {_level} to last 1 character of loop-value
                if {_level} is "I":
                    set {_duration} to 3
                else if {_level} is "II":
                    set {_duration} to 4
                else if {_level} is "III":
                    set {_duration} to 5
                else if {_level} is "IV":
                    set {_duration} to 6
                else if {_level} is "V":
                    set {_duration} to 7
                
                apply fire to attacker for {_duration} seconds
                stop
 
I am trying to make a script where if you attack the player wearing the armor, you get lit on fire. I keep getting so many errors, not even sure if it's possible. Can anyone help?
Code:
options:
    lighterLore: "&7Lighter %amount%"

command /loe add lighter <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to argument 1 parsed as integer
            add "{@lighterLore.replace("%amount%", "%{_amount}%")}" to lore of player's tool
            send "Lore added: &7Lighter %{_amount}%" to player
        else:
            send "You must hold an armor piece to add lore." to player

command /leeifsotherenchants add lighter <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to argument 1 parsed as integer
            add "{@lighterLore.replace("%amount%", "%{_amount}%")}" to lore of player's tool
            send "Lore added: &7Lighter %{_amount}%" to player
        else:
            send "You must hold an armor piece to add lore." to player

on damage:
    attacker is a player
    victim is a player
    victim is wearing any armor:
        set {_lore} to lore of victim's helmet
        {_lore} is not set
        loop {_lore::*}:
            if loop-value contains "Lighter":
                set {_level} to last 1 character of loop-value
                if {_level} is "I":
                    set {_duration} to 3
                else if {_level} is "II":
                    set {_duration} to 4
                else if {_level} is "III":
                    set {_duration} to 5
                else if {_level} is "IV":
                    set {_duration} to 6
                else if {_level} is "V":
                    set {_duration} to 7
               
                apply fire to attacker for {_duration} seconds
                stop
what is
Code:
"{@lighterLore.replace("%amount%", "%{_amount}%")}"
meant to do?
 
To answer your question, it is most definitely possible. Currently, I am making a system that converts numbers into roman numerals and back (because it looks like that was what you were attempting to do here), so I'll get back to you as soon as I finish it. I already fixes a bunch of issues with your code, just give me some time.
 
Actually, I'm just gonna go over what needs to be fixed here, because there is a LOT to go over.

1.
Code:
command /leeifsotherenchants add lighter <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to argument 1 parsed as integer
Why did you parse the argument as an integer when you already classified it as a number? That line is not necessary.

2.
Code:
options:
    lighterLore: "&7Lighter %amount%"
Why use an option if you never called it? I see you used this weird 'replace' thingy, which I have never seen before, so uh, interesting choice.
I'd recommend just using a local variable. Trust me. It will solve a lot of your issues.

3.
command /loe add lighter <number>:
REMOVE THE 'add lighter' BIT. PLEASE. YOU DON'T NEED IT.

Code:
command /loe <number>:
    trigger:
        if player's tool is a piece of armor:
            set {_amount} to arg-1
            add "Lighter (I'm currently setting up the roman numeral thing. trust.)" to lore of player's tool
            send "Lore added: &7Lighter %{_amount}%" to player
With all of this knowledge applied, we now have something like this.

4.
I noticed that the /loe and the /leeifsotherenchants command does the exact same thing. You don't need to do that.
What you can do instead is use the aliases: thingy. I don't know how to explain it, so let me just show you an example:

Code:
command /leeifsotherenchants <number>:
    aliases: /loe
    trigger:
        (code)

I think that's it for now. I may have missed some mistakes, but to be honest, I'm not gonna go digging around to find more. Lemme get the roman numeral thing set up meanwhile.





EDIT:

One last thing I would like to add is this:

Code:
loop {_lore::*}:
            if loop-value contains "Lighter":
                set {_level} to last 1 character of loop-value
                if {_level} is "I":
                    set {_duration} to 3
                else if {_level} is "II":
                    set {_duration} to 4
                else if {_level} is "III":
                    set {_duration} to 5
                else if {_level} is "IV":
                    set {_duration} to 6
                else if {_level} is "V":
                    set {_duration} to 7

You set {_level} to the last character of the loop-value, but you check for more than one character in some of these (e.g. "III", "IV").
What I did to fix this was split the lore text into two halves. One half was the 'enchantment' name, and the other half was the level.
Here's an example:

Code:
# (pretend that {_lore} is the text of the lore)

set {_enchantmentinfo::*} to {_lore} split by " "
    if {_enchantmentinto::1} contains "Enchantment Name": # pretty sure you can use 'is' instead of 'contains' here
        if {_enchantmentinnfo::2} contains "Level":
            (code)

I'm not pointing out these errors to take a jab at you, I'm pointing them out so you don't make these mistakes in the future. We're all learning here.
 
Last edited:
I attached the code to this message, HOWEVER...

Code:
function toRoman(number: integer) :: text:
    set {_integers::*} to 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1
    set {_numerals::*} to "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"
    set {_roman} to ""
    loop size of {_integers::*}:
        while {_number} >= {_integers::%loop-number%}:
            set {_roman} to "%{_numerals::%loop-number%}%"
            subtract {_integers::%loop-number%} from {_number}
    return {_roman}

command /test <number>:
    trigger:
        if arg-1 is not between 1 and 3999:
            send "Please enter a number between 1 and 3999."
            stop
        set {_result} to toRoman(arg-1)
        send "The Roman numeral of %arg-1% is %{_result}%."

This part of the code may be buggy. Run the /test command, and tell me if you get the roman numeral of the number. I really do not feel like logic checking it myself. Let me know if anything goes wrong.
 

Attachments

  • fix4c-v1.0.sk
    3.5 KB · Views: 18
I attached the code to this message, HOWEVER...

Code:
function toRoman(number: integer) :: text:
    set {_integers::*} to 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1
    set {_numerals::*} to "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"
    set {_roman} to ""
    loop size of {_integers::*}:
        while {_number} >= {_integers::%loop-number%}:
            set {_roman} to "%{_numerals::%loop-number%}%"
            subtract {_integers::%loop-number%} from {_number}
    return {_roman}

command /test <number>:
    trigger:
        if arg-1 is not between 1 and 3999:
            send "Please enter a number between 1 and 3999."
            stop
        set {_result} to toRoman(arg-1)
        send "The Roman numeral of %arg-1% is %{_result}%."

This part of the code may be buggy. Run the /test command, and tell me if you get the roman numeral of the number. I really do not feel like logic checking it myself. Let me know if anything goes wrong.
I am trying to light the player on fire when they attack them, not turn numbers into roman numerals