Solved Setting the number in item's lore as a variable

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

Fladsaw

Member
Jul 18, 2022
30
0
6
21
Hey everyone! I need your help about two problems. I am trying to make a money bag skript. Basically, when player right clicks with a book, I want an inventory to open with the number of gold nuggets according to the item's lore. Check the code you will get what I mean.

Code:
on right click with book named "Money Bag":
    If the 1st line of the lore of the player's tool is "Total Amount: %number%":
        open chest inventory with 3 rows named "Money Bag" to player
        put %number% of gold nuggets into player's inventory
        
on inventory close:
    if name of event-inventory is "Money Bag":
        set {_money} to amount of gold nuggets in event-inventory
        set player's tool to book named "Money Bag" with lore "Total Amount: %number%"
        
on inventory click:
    if name of event-inventory is "Money Bag":
        if event-item is not gold nugget:
            cancel event


My first problem is how can I use the number in item's lore as variable? Or is there another way to do it?

And my second problem is how can I write 4. line? Obviously my example won't work. It is just to show you what I mean
Thanks in advance!
 
go in the skunity help 2 channel and send your formatted code, I'm busy helping people there
 
You might be able to use this code:

Code:
set {_lore::*} to lore of player's tool split at "Total Amount: "
then the amount of gold would be stored in {_lore::2}
 
You might be able to use this code:

Code:
set {_lore::*} to lore of player's tool split at "Total Amount: "
then the amount of gold would be stored in {_lore::2}

I'm afraid it didn't work. The error is:

Code:
{_lore::*} can't be set to 'lore of player's tool split at "Total Amount: "' because the latter is not an object
 
I'm afraid it didn't work. The error is:

Code:
{_lore::*} can't be set to 'lore of player's tool split at "Total Amount: "' because the latter is not an object
How about
Code:
set {_lore::*} to split line 1 of lore of item at "Total Amount: "
 
How about
Code:
set {_lore::*} to split line 1 of lore of item at "Total Amount: "
The code worked but now I can't use it as a variable. For example I tried this line just to see if it will work:

Code:
give player {_lore::*} of gold nuggets

And it didn't work.
 
The code worked but now I can't use it as a variable. For example I tried this line just to see if it will work:

Code:
give player {_lore::*} of gold nuggets

And it didn't work.
Use {_lore::2} when giving the player the gold