#Skript not functioning properly

1 messages · Page 1 of 1 (latest)

viscid arch
#

I wrote two scripts following the same format, one works one doesnt. I have supplied both files below and was wondering if anyone could show me why they aren't working. The working file is called bosschest.sk, the broken one is called bosschestlegendary.sk

#

Please ping me with any answers so I can see it sooner<3 thank you!

smoky reef
#

why are those files so big

lime barn
smoky reef
#

does it give a parse error if so send it and the surrounding code

#

@viscid arch

viscid arch
#

which is weird because both scripts have almost equal functions

smoky reef
#

also, the problem is never 'skript not functioning properly' it's a user error

viscid arch
#

I can convert them to yaml if you want

smoky reef
#

did you make another function with same name?

viscid arch
smoky reef
#

they will overwrite unless local functions

viscid arch
smoky reef
#

function, not file name

viscid arch
smoky reef
#

function myFunc():

#

try debugging by broadcasting values and see where it stops working

viscid arch
viscid arch
smoky reef
#

uhhhh

#

wtf

lime barn
#

….

#

You how you could just do

#

execute console command "/lootchest respawn LSLegendary%{_random}%"

smoky reef
lime barn
#

And then delete all of the ifs and else ifs and all that

viscid arch
#

if I wanted to repeat the function 3 times, what would that look like?

lime barn
#

Yeah percentages around something replaces it with the value

smoky reef
#

loop 3 times:

lime barn
lime barn
smoky reef
#

the problem might be whatever is adding those commands

#

do the commands work in-game?

viscid arch
#

so it would look like this?

viscid arch
smoky reef
#

indent after the loop

#

and put those in a trigger

lime barn
#

You need a trugger

#

And you need to set random still

#

But besides that yeah

#

So it’d be

viscid arch
lime barn
#

Yeendifhisksa

#

Do you, by chance, know skript at all?

#

The loop goes in the trigger

#

And you still have to set random

viscid arch
#

I have no understanding, im sorry, this was the first thing I picked up that made sense towards what I was trying to do

smoky reef
#

command /bosschest:
trigger:
loop 3 times:
execute blah blah

viscid arch
#

could I be sent something to educate me on the functions I am trying to understand?

lime barn
#

This isn’t a function

#

It’s a command

viscid arch
#

so this, but now I need to add the random thing>?

smoky reef
#

yes

lime barn
#

Yes now you just have to set random to a random number between 1 and 70 like you had befor

smoky reef
#

before the execute line

viscid arch
#

hows this?

smoky reef
#

try it

lime barn
smoky reef
#

100+ lines down to 6
if you have repetitive code it can always be simplified

viscid arch
smoky reef
#

try random whole number

#

or random integer

lime barn
#

Yeah it’s random int sorry

smoky reef
#

btw if you didn't know, you can do /sk reload scripts instead of restarting your server

lime barn
#

Or just /sk reload <skript>

viscid arch
#

ive been doing this, yes ty!!

lime barn
#

Very useful when you have like 200 grubhappy

viscid arch
#

I have 2 scripts c:

lime barn
#

No no no

#

just random integer

viscid arch
#

ohh

#

remove number

#

got it got it

lime barn
#

And add eger

#

actually

#

Int might work

#

Idk I’m a Java guy

viscid arch
#

this worked!!

lime barn
#

Cool

smoky reef
#

if you don't wanna flood your console it might be possible to use the plugins internal api instead of running console commands, but that is a bit complicated

#

yw

lime barn
#

If the plugin has javadocs it should be very easy with reflect

viscid arch
#

how could I simplify my other script?
it has an additional variable

#

there are 3 tiers of chests

lime barn
#

Why not just use chance?

viscid arch
#

and I set it up with 3 different values that equate to percentages

60% common
35% rare
5% legendary

viscid arch
lime barn
#
chance 60%:
    stuff
else chance 35%:
    stuff
else chance 5%:
    stuff```
smoky reef
#

set random same as in the other script, and then use chance to decide the rarity

lime barn
#

Actually it might be

else:
    chance``` instead of else chance
#

But I know that chance statements can fire an else

smoky reef
#

else if

lime barn
#

oh right maybe it’s else if chance?

smoky reef
#

yeah

#

else if condition:

lime barn
#

#

No chances fire an else

#

I can’t check rn it’s really late

#

A chance is a Boolean not a condition it only has one other value

#

So it’s just else not else if iirc

viscid arch
#

I really don't think I did this right, but I tried

lime barn
#

What the actual fuck

viscid arch
#

im sorry 😭

lime barn
#

Nah nah you’re trolling

viscid arch
#

im really not

#

ive just been overcomplicating things so now my brain is dead

smoky reef
#

if chance of 60%:
stuff
else if chance of 35%:
stuff

lime barn
#

No no

#

Chance isn’t a condition

#

Wait hold on

smoky reef
#

replacing stuff with the execute lines

#

really?

#

it has a chance to be true or false

#

pretty sure it is

lime barn
#

Nvm chance is yeah

#

Cuz it’s a Boolean

#

I literally said it myself I’m dumb

viscid arch
#

I think this is more on track?

#

I would need to repeat the trigger 70 times though, but I cant just use the repeat like last time because the number goes up this time, and cannot repeat, it needs to test which tier for all chests 1-70

smoky reef
#

remove else if condition:

viscid arch
smoky reef
#

and put if before the first chance

viscid arch
smoky reef
#

no

#

completely remove 'else if condition:'

#

the whole line

#

and then make it 'if chance 60%'

viscid arch
smoky reef
#

indent everything after the trigger

viscid arch
smoky reef
#

try that

#

and then we just need the random part

#

for the numbers

viscid arch
#

how would I go about repeating this 70 times, so that each time it makes sure the number goes up by 1 on each of the "LSCommon1"

smoky reef
#

loop 70 times: and then loop-index

lime barn
#

Oh true nvm

smoky reef
#

right after the trigger put loop 70 times

lime barn
#

Could also use loop-number

smoky reef
#

and then replace the 1's with %loop-index%

lime barn
viscid arch
smoky reef
#

chance of

lime barn
#

Oh it’s chance of

#

Didn’t realize that was a necessary bit of syntax idk I don’t like chance

viscid arch
#

if chance of 60%:

#

?

smoky reef
#

condition btw

#

yes

viscid arch
smoky reef
#

yeah try it

viscid arch
#

maybe just else chance?

smoky reef
#

else if

#

i think if is necessary

#

else if chance of 35%

viscid arch
#

ohh

lime barn
#

Mf you need to learn skript nah I’m out

viscid arch
smoky reef
#

chance of

#

else if chance of 35%

viscid arch
smoky reef
#

nice

#

one more thing

viscid arch
#

is there a document that explains how to do the increment integer? or could you explain it?

smoky reef
#

replace the last chance with just else:

viscid arch
smoky reef
#

loop 70 times:
your current code here

#

yeah

#

and then replace 1 with %loop-index%

smoky reef
#

cause it's checking that chance each time instead of adding onto the other ones

viscid arch
#

60+35=95

#

5 is left over

#

but okay!

#

uhh

viscid arch
#

above trigger?

smoky reef
#

below

#

trigger contains all the code for the command

viscid arch
#

and then indent, correct?

smoky reef
#

yes

viscid arch
viscid arch
smoky reef
#

that should work

viscid arch
#

I'll try it!

viscid arch
smoky reef
#

hmm

#

loop-number maybe

#

i will check docs

#

loop-iteration

viscid arch
#

appears that both integer and number work

#

oop okay

smoky reef
#

gtg be back later

#

good luck

viscid arch
#

it loaded properly, hope it works, thank you chicken

#

I'm not sure why, but it skipped a few numbers

heavy verge
#

it'll do that, because it's random

viscid arch
heavy verge
#

maybe not guaranteed, but you can do it so if the 35 and 5 percent chances don't do anything, the fallback 60 is always run: chance of 35%: do this else chance of 5%: do this instead else: # don't use chance this will always run
If you have a chance for the last one, there is a chance that nothing happens, because out of 100 times, 60 of them will do something.

smoky reef
#

that's what i was trying to say

#

for example if you had 2 50% chances, the top would be 50% but the bottom would be 25%

#

and the last 25% nothing would happen

#

so maybe setting a number and checking if it's between is best way here

#

unless there's another way to use chance

heavy verge
#

or do my method, and the last 60% chance is guaranteed to happen

smoky reef
#

but then it's not accurate percents. it's hard to know what chance for which ones

#

if you check between it's easy to see the chance

heavy verge
#

true.

#

either my or your method will work

#

but yeah, setting specific values (preferrably 1 to 100) would be better than using % chances

#

1 - 50: 50%
50 - 70: 20%
70 - 100: 30%

smoky reef
#
set {_random} to random number between 1 and 100
if {_random} is more than 60:
  stuff
if {_random} is more than 35:
  stuff
else: # this is the remaining percent, in this case 5%
  stuff
#

@viscid arch

viscid arch
#

so that its not a multi hundred line script

smoky reef
#
loop 70 times:
  set {_random} to random number between 1 and 100
  if {_random} is more than 60:
    execute console command "/lootchest respawn LSCommon%loop-iteration%"
  if {_random} is more than 35:
    same but for rare
  else: # this is the remaining percent, in this case 5%
    same but for legendary
#

@viscid arch

smoky reef
# viscid arch

like what you did here, but replacing the way the chance works

lyric silo
viscid arch
#

I will try this now

#

I believe I did it correctly

smoky reef
#

you don't need between

#

just check if more than 60

#

but yeah looks good

viscid arch
lyric silo
#

What they mean is you could use

  ...
else if {_random} <= 95:
  ...
else:
  ...```
viscid arch
#

woould I still need the else if

lyric silo
#

(less, not more)

smoky reef
#

there is a way to do it where you put the actual numbers

#

hang on i got confused lol

#

maybe not idk

viscid arch
#

Like this?

smoky reef
#

yes

#

perfect

viscid arch
#

this worked seemlessly

#

thank you so much guys

smoky reef
#

yw :D

#

hope you learned a lot

viscid arch
#

I did haha, I am not using script for anything else but am sure I will need to write similar scripts for the same function on my server in other areas, so I will use the knowledge to make those work too

#

thank you for all your help chicken and everyone else

#

have a good day/night

#

<3

smoky reef
#

wholesome skunity moment? impossible