Is Skript A Viable Option For This?

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

NobodysSon

Member
Jul 26, 2017
11
0
0
46
Canada
Hello all,

I discovered the existence of Skript not long ago and I'm pretty excited about the possibilities it presents. Here is a question for those with more experience than I before I go down the rabbit hole in learning Skript and its many add-ons:

Can Skript do something as complicated as detecting when a player has thrown a specific item into a specific fire and adjusting a score based on how many items were burned?

I ask because I have been toying with the idea of a server where players choose a god to worship when they join and get powers and items based on how many of a specific item they throw into the altar fire at their deity's temple ie the war god wants bones as a sacrifice and the player receives a new power for every 100 they throw in his temple fire.

Is Skript up for that or is it meant for simpler tasks?

Thanks for any advice!
 
Hello all,

I discovered the existence of Skript not long ago and I'm pretty excited about the possibilities it presents. Here is a question for those with more experience than I before I go down the rabbit hole in learning Skript and its many add-ons:

Can Skript do something as complicated as detecting when a player has thrown a specific item into a specific fire and adjusting a score based on how many items were burned?

I ask because I have been toying with the idea of a server where players choose a god to worship when they join and get powers and items based on how many of a specific item they throw into the altar fire at their deity's temple ie the war god wants bones as a sacrifice and the player receives a new power for every 100 they throw in his temple fire.

Is Skript up for that or is it meant for simpler tasks?

Thanks for any advice!
While I'm not best at Skript either yet, I think what you want to do is possible. The way I could see you working it out is
1: setting a variable for the location a fire is created at when the flint and steel is used. so something like
code_language.skript:
on right click with flint and steel:
    set {location.fire1} to location of event-block
2: when the item is dropped, looping the blocks in a radius of the player.
3: checking if the loop block location is equal to the fire location variable
4: and if it is executing the adjustment on your score, however, you choose to have that system set up.
code_language.skript:
#can be any item. Can add named item condition too  
on drop of diamond:
    loop blocks in radius 5 of player:
        if "%{location.fire1}%" = "%location of loop-block%":
        set {Score.%player%} to {Score.%player%} + 1
[doublepost=1501144862,1501144612][/doublepost]Ooo and just in case you don't have them, I would book mark these pages. I really found these useful when starting out. ^-^
http://nfell2009.uk/skunity/events
http://nfell2009.uk/skunity/conditions
http://nfell2009.uk/skunity/effects
http://nfell2009.uk/skunity/expressions
Really it seems Skript's only limitation is how inventive you can be
 
Thanks for the reply, Wynnevir!

The 'on drop of diamond' portion doesn't seem to get called even when I strip it down to the bare minimum to test it:

code_language.skript:
on drop of diamond:
    message "Success!"

I am sure I am doing something incredibly obvious wrong here...
 
Thanks for the reply, Wynnevir!

The 'on drop of diamond' portion doesn't seem to get called even when I strip it down to the bare minimum to test it:

code_language.skript:
on drop of diamond:
    message "Success!"

I am sure I am doing something incredibly obvious wrong here...
No, I don't think you've done anything wrong I just tested it and can't even get plain "on drop:" to work. I wonder if the event is broken.
[doublepost=1501302691,1501302657][/doublepost]What version do you run? I'm on bensku dev 29
 
I'm using using the same version as yourself.
it must be broken then. We definitely have it right x3
9c1c78cfdb.png
 
Edited all of prev post down to be just the best answer here.
Try this code exactly. I just ran it on my server and It does exactly what you want it to. fingers crossed. it should also only work if the player is within two blocks of the fire to make sure your item burns
code_language.skript:
on drop of diamond:
    if target block is fire:
        set {_trg.blck} to target
        if distance between player and {_trg.door} is bigger than 2:
            cancel event
            message "Move closer to make an offering"
        broadcast "THE FIRE ACCEPTS YOUR OFFERING"
        if {godpoints.%player%} is not set:
            set {godpoints.%player%} to 0
        add 1 to {godpoints.%player%}
        send "you have %{godpoints.%player%}% godpoints" to player
http://puu.sh/wW2sy/7a39441549.png
 
Last edited by a moderator:
It is working for me now too...very, very odd. It is too late at night for me to be trying to wrap my head around all this. Thank you for your help, Wynnevir.
 
No problem, this was pretty fun to work through! Enjoy your night.
Here's a question:

Does this:

code_language.skript:
loop {location.altar::*}:
    if {location.altar::%loop-index%} is location of event-block:
        message "There is already an altar here" to player
        exit loop

Do the same as this:

code_language.skript:
if {location.altar::*} contains location of event-block:
    message "There is already an altar here" to player

And if so, which is more efficient/better in practice?
 
Without having tested them, they both look like they do the same thing. you're just checking it in two different ways. One by if the loop value is the same as location of event and the other if that event location is on the list of locations.

In which case I'd say the second, it's less code and seems a bit more efficient:emoji_slight_smile:
 
in theory yes but checking if a list contains something is buggy so you have to loop it.
Is the only difference the stability of using a loop? It's still just comparing the event location to a value of the list variable if I'm understanding it right.
 
what im saying is that checking if a list contains a value is buggy and doesnt work so you have to use the first method he showed
 
While I'm not best at Skript either yet, I think what you want to do is possible. The way I could see you working it out is
1: setting a variable for the location a fire is created at when the flint and steel is used. so something like
code_language.skript:
on right click with flint and steel:
    set {location.fire1} to location of event-block
2: when the item is dropped, looping the blocks in a radius of the player.
3: checking if the loop block location is equal to the fire location variable
4: and if it is executing the adjustment on your score, however, you choose to have that system set up.
code_language.skript:
#can be any item. Can add named item condition too
on drop of diamond:
    loop blocks in radius 5 of player:
        if "%{location.fire1}%" = "%location of loop-block%":
        set {Score.%player%} to {Score.%player%} + 1
[doublepost=1501144862,1501144612][/doublepost]Ooo and just in case you don't have them, I would book mark these pages. I really found these useful when starting out. ^-^
http://nfell2009.uk/skunity/events
http://nfell2009.uk/skunity/conditions
http://nfell2009.uk/skunity/effects
http://nfell2009.uk/skunity/expressions
Really it seems Skript's only limitation is how inventive you can be
Edited all of prev post down to be just the best answer here.
Try this code exactly. I just ran it on my server and It does exactly what you want it to. fingers crossed. it should also only work if the player is within two blocks of the fire to make sure your item burns
code_language.skript:
on drop of diamond:
    if target block is fire:
        set {_trg.blck} to target
        if distance between player and {_trg.door} is bigger than 2:
            cancel event
            message "Move closer to make an offering"
        broadcast "THE FIRE ACCEPTS YOUR OFFERING"
        if {godpoints.%player%} is not set:
            set {godpoints.%player%} to 0
        add 1 to {godpoints.%player%}
        send "you have %{godpoints.%player%}% godpoints" to player
http://puu.sh/wW2sy/7a39441549.png
First of all I have to tell you:
Use list variables.

Why? Because:
  • You can loop them.
  • Delete them easier.
  • It's also easier when you want to make top lists and that stuff.
  • Other reasons I'm lazy to explain.
Said that, answering the OP's question, you could use this function:

code_language.skript:
function contains(list: objects, object: object) :: boolean:

  loop {_list::*}:
    if loop-value is {_object}:

        return true

  return false
And use it like this:

code_language.skript:
if contains({location.altar::*}, location of event-block) is true:
  send "There is already an altar there" to player
 
  • Like
Reactions: Wynnevir
what im saying is that checking if a list contains a value is buggy and doesnt work so you have to use the first method he showed

This is good to know. I've been going back and forth between the two methods and couldn't figure out why one seemed to work and the other didn't though they seemed to be doing the same thing.
[doublepost=1501368292,1501368105][/doublepost]
First of all I have to tell you:
Use list variables.

Why? Because:
  • You can loop them.
  • Delete them easier.
  • It's also easier when you want to make top lists and that stuff.
  • Other reasons I'm lazy to explain.
Said that, answering the OP's question, you could use this function:

code_language.skript:
function contains(list: objects, object: object) :: boolean:

  loop {_list::*}:
    if loop-value is {_object}:

        return true

  return false
And use it like this:

code_language.skript:
if contains({location.altar::*}, location of event-block) is true:
  send "There is already an altar there" to player


I think I follow as it isn't that different from using functions in other languages. Are functions more efficient or just better practice?
 
This is good to know. I've been going back and forth between the two methods and couldn't figure out why one seemed to work and the other didn't though they seemed to be doing the same thing.
[doublepost=1501368292,1501368105][/doublepost]


I think I follow as it isn't that different from using functions in other languages. Are functions more efficient or just better practice?
It's just better as you aren't repeating code all the time, you can also use these in other scripts which makes it useful for utility functions like this one, as long as it's loaded before you use it on your code it should work fine.

Also, Skript loads every script in the following way:
  • Scripts folder:
    • Subfolders loaded alphanumerically:
      • Scripts in these subfolders loaded alphanumerically.
    • Scripts in the main scripts folder loaded alphanumerically.
So, if I have the scripts test and 1_functions in the main scripts folder and testing and utils in a functions folder that's into the main scripts folder Skript will load it in the following way:
  • Scripts folder:
    • functions
      • 1: testing.sk
      • 2: utils.sk
    • 3: 1_test.sk
    • 4: functions.sk
 
Well, I wanted to say thank you to everyone for their help and input! I am definitely going to give Skript a go for my project. I'm pretty excited to have discovered it to be honest lol
 
Status
Not open for further replies.