SkCheese

Addon SkCheese 1.0.1

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

erenkara

Member
Jan 4, 2022
39
3
18
18
erenkara submitted a new resource:

SkCheese - The smelliest Skript addon.

SkCheese is an addon that adds 2 new functionalities to Skript.

1) Switch Cases

A switch case is a multi-way branch statement. Based on the value of the expression given, different parts of code can be executed quickly. Unlike your average else if tree, a switch case directly jumps to the code instead of going through each condition one by one. This comes...


Read more about this resource...
 
I would like to start with thanking you for this wonderfull addon, it was something that I was looking for.

There is any chance of adding a default option to switch statement?

Code:
switch {game::state}:
    case "running":
        //code
    
    default:
        //code running in case of not meeting any case
 
I would like to start with thanking you for this wonderfull addon, it was something that I was looking for.

There is any chance of adding a default option to switch statement?

Code:
switch {game::state}:
    case "running":
        //code
   
    default:
        //code running in case of not meeting any case
hello, yes this is planned but no ETAs on when it will come out.
 
What can you do with SkCheese? You said switching but switching what?
switch is a keyword in a lot of languages that lets you run a block of code depending on the value
its like using lots of else if after one another but unlike else if it skips to that block of code instantly rather than trying each condition
they have other differences too though

Code:
set {_var} to 2
switch {_var}:
  case 1:
    broadcast "var is 1"
  case 2:
    broadcast "var is 2
  case {_a}: # wouldn't work, you can only use literals here
    broadcast "var is a"

# vs. else if

set {_var} to 2
if {_var} is 1:
  broadcast "var is 1"
else if {_var} is 2:
  broadcast "var is 2"
else if {_var} is {_a}: # unlike switch, this would work
  broadcast "var is a"
while "else if" checked if {_var} is 1 then skip to the next one, the switch section instantly skips to that part of the code without even checking if its 1
but it comes with the cost of not being able to use variables or other non-literal values
 
so SkCheese just replaces else if with case (integer)?
it doesn't exactly replace it, its just another way of doing conditions
and it doesn't have to be an integer
Code:
set {_var} to "ab"
switch {_var}:
  case "ab":
    broadcast "its ab!!"
 
it doesn't exactly replace it, its just another way of doing conditions
and it doesn't have to be an integer
Code:
set {_var} to "ab"
switch {_var}:
  case "ab":
    broadcast "its ab!!"
ah ok! So could you do
Code:
case {_var}
?
 
Also how did you get the Addon Tag and the download button on this page?
You can add the addon tag if your resource is well, an addon
for the download button you just upload the file to skunity rather than having an external download
 
ah ok! So could you do
Code:
case {_var}
?
no you cant, case only accepts literal values
{_var} could be anything when the code is ran so its a non-literal

literal examples: 5, "hello", string, 2.5
non-literal examples: {_var}, player's ping, 4 + {_var}
 
no you cant, case only accepts literal values
{_var} could be anything when the code is ran so its a non-literal

literal examples: 5, "hello", string, 2.5
non-literal examples: {_var}, player's ping, 4 + {_var}
got it