TIps before I start something please

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

Status
Not open for further replies.

swaith

Supporter
May 4, 2021
23
1
3
34
Hi all,

I am still fairly new to Skript having taken a large break from it the last year, I want to resurrect an old project and while I had some success doing things myself with the documentation, my next project is a bit more ambitious and before I start down the wrong road I wanted to ask if anyone can suggest a functional way of storing the data I want, that won't cause things to get messy later on.

Let me explain the project.

I am currently running a DND campaign via a well known TTS (Table top simulator) and I want to have some parts automated for the characters downtime allowing them to do things in the MC world in-between sessions rewarding time and effort without my having to be party to it.

This relies on me having some kind of stored stat system for each player in-game, I was planning on using normal variables, but after reading Sluhties post on performant ways to store data figured id start this thread and update as I create my skript.

After reading it through I want to make sure I am not creating issues for myself in the future.

An example below before I update this evening with a framework for the skript. Tips in advance are more than welcome, anything that is glaringly wrong feel free to tell me, once I am home and can test I will adjust as needed based on what I can find, or potentially what someone can post here to save me before I need saving :emoji_grinning:

Code:
on first join:
    if {Strength::%player%} is not set:
        set {Strength::%player%} to 10
    if {Dexterity::%player%} is not set:
        set {Dexterity::%player%} to 10
    if {Constitution::%player%} is not set:
        set {Constitution::%player%} to 10
    if {Intelligence::%player%} is not set:
        set {Intelligence::%player%} to 10
    if {Wisdom::%player%} is not set:
        set {Wisdom::%player%} to 10
    if {Charisma::%player%} is not set:
        set {Charisma::%player%} to 10
    if {Exhaustion::%player%} is not set:
        set {Exhaustion::%player%} to 0
       
on death:
    add 1 to {Exhaustion::%player%}

# commands to set stats usable by GM etc - I haven't tested this it may be completely incorrect to set a variable like this.
command /setstr  <number> <player>:
    Trigger: 
        if player has the permission "set.stats":
            if arg-1 and arg-2 is set:
                set {Strength::[arg-2]} to arg-1
            else:
                message "set value followed by player name."
        else:
            message "You do not have permission to use this command"
       
# rewards based on stats - very rough and I expect to use this as a framework to make multiple different activities
on mine:
    if block is stone:
        if {Exhaustion::%player%} >= 17:
            chance of 0.001%
            clear drops
            drop emerald named "&aGemstone"
        if {Exhaustion::%player%} >= 20:
            chance of 0.01%
            clear drops
            drop emerald named "&aGemstone"
            chance of 0.001%
            drop emerald named "&aRare Gemstone"
        else:
            chance of 0.2%
            clear drops
            message "You aren't skilled enough to harvest this gemstone"
            drop stone named "&eBroken Gemstone"

For clarity, all rewards are just examples I plan on having named items that aren't available in the playable area themed around the activity they chose to do, with those rewards exchangeable for items in the DND campaign on the TTS.

I haven't worked out the best way to connect the two worlds other then having player rewards named by the skripts and then have them give them to me in MC to then manually add onto the TTS but I won't worry about tht until later. ((Meaning they can swap rewards or trade In MC for things the other players can then roll for which are only locked to character after naming etc))

Edit: Changed it after running through the parser
 
Last edited:
So using the skill example above I am working on various different checks and actions to reward the player - all rewards are placeholders until I finish learning how to make resource packs with custom items so i can reward them with suitable rewards that fit the lore/world etc so please ignore them, this is the kind of thing I will be making and fleshing out, I want to have a lot of variety on the return and the parse hasn't screamed at me so I think its working well.

Does anything know it things like {note_lost} are only saved in this instance and can be overwritten? if I use the same reward and rewrite for other skills for example they can rename the same thing in those brackets without issue correct?

For example if I tweaked it slightly so one skill gives that item with lore that is different from another skill I don't need to make like {note_lost2/3/4/5/6} etc etc I can just leave {note_lost} in place and have each event write over it as and when needed? I am wondering if that would work if multiple people trigger it at the same time if it would use the last use and overwrite before the item is awarded to the player.

Code:
command /Forage:
    trigger:
        player has permission "skript.forage"
        send "Forraging"
        loop all blocks in radius 5 around player:
            if all loop-blocks are grass:
                if  {Intelligence::%player%} >14:
                    give player 1 obsidian
                if {Intelligence::%player%} >18:
                    give player 1 diamond
                else:
                    give player 1 stick
                    say "you are unable to find anything useful"
            else:
                set {_chance} to a random integer between 1 and 100
                if {_chance} is between 1 and 25:
                    say "You are unable to find anything in this terrain"
                if {_chance} is between 26 and 80:
                    say "You search for some time but find nothing useful"
                if {_chance} is between 81 and 99:
                    say "You found... no.. no it's nothing"
                if {_chance} is between 100 and 100:
                    say "I am not sure what this is, but I had better keep it for later"
                    set {note_lost} to paper named "Lost note"
                    set line 1 of lore of {note_lost} to "A scrap of paper with illegible scrawls"
                    give player 1 {note_lost}
        else:
            "you are not trained in foraging"
 
Variables such as {note_lost} are global variables and they'll be replaced once you overwrite them.
If you only need to change the lore, you can keep calling back to this same variable as it'll always overwrite the lore before awarding the item to the player.
You could also create a local variable and then adjust the lore of it, without having to modify anything about {note_lost} e.g.

Code:
set {_x} to {note_lost}
set line 1 of lore of {_x} to "Your lore"
give {_x} to player
 
Ahh brilliant thank you for the Kapo, I am still learning the different variations of variables (no irony intended) so this is very useful! - I have been working most recently on the ambient noises as a lighter note for the same project, I will hopefully have more to post and a little video showing how's its going soon.
 
Status
Not open for further replies.