I’m trying to extract only the numbers from an item’s name in Skript. I tried using the following code, but it’s not working, and I keep getting errors. Here is what I have so far:
The goal is to remove all non-numeric characters from the item's name and extract the number. For example, if the item is called Sword123, I want to extract 123. However, this script doesn't seem to be working as expected, and I'm unsure how to fix it.
Can anyone help me identify what I’m doing wrong or suggest a better approach for extracting numbers from a string in Skript?
*It was written by chatGPT
Code:
on right click:
set {_name} to name of player's tool
set {_number} to "%{_name}%"
replace all characters except "0123456789" in {_number} with ""
if {_number} is not "":
set {_number} to {_number} parsed as number
send "Extracted number from item name: %{_number}%"
else:
send "There is no number in the name."
The goal is to remove all non-numeric characters from the item's name and extract the number. For example, if the item is called Sword123, I want to extract 123. However, this script doesn't seem to be working as expected, and I'm unsure how to fix it.
Can anyone help me identify what I’m doing wrong or suggest a better approach for extracting numbers from a string in Skript?
*It was written by chatGPT