Solved If world name contains ..

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

crazydred

Member
Jan 27, 2017
6
1
0
31
Is it possible to write something like:

code_language.skript:
 if world name contains "pvp_":
     wait 1 tick
(...)
 
Hello crazydred,

Thank you for posting on the SkUnity forums!

I think I may hold the solution to your problems!
You could use
Code:
%entity's world%
. As in
Code:
%player's world%
. Or you could do
Code:
world of %entity%
! These both return the name of the world then I'm pretty sure you would then be able to do something like:
Code:
set {_var} to %thing's world%
if {_var} contains "worldname":

Feel free to reply if you are confused.

Best regards,

Blitz
 
or create a list with all worlds starting by "pvp_" and use that
[doublepost=1485817802,1485817604][/doublepost]What I am trying to achieve is to condense something like this:

code_language.skript:
if world name is "pvp_smugglerspath" or "pvp_hollow" or "pvp_ice" or "pvp_dust" or "pvp_whitevalley" or "pvp_arena1":
    on step on slime block:
        wait 1 tick
        do something
 
I'm afraid that is not how events work. You can't use a event which is
Code:
on step on slime block:
within a condition which is the code after the
Code:
if
. But I seem to be confused, what are you trying to accomplish here?
 
A simple launchpad that works only on worlds starting with "pvp_"

code_language.skript:
on step on slime block:
    wait 1 tick
    push player forwards with force 2
    wait 1 tick
    push player upwards with force 1
 
Ah! Now I see! So you could probably use something like this!
code_language.skript:
on step on slime block:
    set {_var} to event-player's world
    if {_var} contains "pvp_":
        wait a tick
        push player forwards with force 2
        wait a tick
        push player upwards with force 1
 
  • Like
Reactions: crazydred
Ah! Now I see! So you could probably use something like this!
code_language.skript:
on step on slime block:
    set {_var} to event-player's world
    if {_var} contains "pvp_":
        wait a tick
        push player forwards with force 2
        wait a tick
        push player upwards with force 1

Does not work, I made this debug and I get:
pvp_whitevalley
not pvp


code_language.skript:
on step on slime block:
    set {_var} to event-player's world
    send "%{_var}%"
    if {_var} contains "pvp_":
        send "pvp"
        wait 1 tick
        push player forwards with force 2
        wait 1 tick
        push player upwards with force 1
        play "ITEM_FIRECHARGE_USE" to player at volume 0.5
        #show 10 "slime" particles at location of player for player offset by 0, 0, 1
        set {launched::%player%} to true
    else:
        send "not pvp"
 

Does not work, I made this debug and I get:
pvp_whitevalley
not pvp


code_language.skript:
on step on slime block:
    set {_var} to event-player's world
    send "%{_var}%"
    if {_var} contains "pvp_":
        send "pvp"
        wait 1 tick
        push player forwards with force 2
        wait 1 tick
        push player upwards with force 1
        play "ITEM_FIRECHARGE_USE" to player at volume 0.5
        #show 10 "slime" particles at location of player for player offset by 0, 0, 1
        set {launched::%player%} to true
    else:
        send "not pvp"
That means that the name of the world is infact pvp_whitevalley, so change
Code:
contains "pvp_"
to
Code:
contains "pvp_whitevalley"
.
 
Well, you could use my addon? It's called Vixio here: https://forums.skunity.com/resources/vixio-1-0-8-the-best-discord-addon-on-the-market.19/ It's a Discord addon but it has `starts with` in it! So then you could use:
Code:
if {_var} starts with "pvp_"
SkUtilities may also have it?
It would be easier to use:
code_language.skript:
on step on slime block:
    set {_contains} to subtext of "%player's world%" from 1 to 4
    if {_contains} is "pvp_":
        # do stuff

...Or you could shorten that to:
code_language.skript:
on step on slime block:
    if subtext of "%player's world%" from 1 to 4 is "pvp_":
        # do stuff

on step on slime block:
    if "%subtext of ""%player's world%"" from 1 to 4%" is "pvp_":
        # do stuff

I might have messed up on the second example of the second code snippet, as I wasn't sure if two percent signs are required inside of an expression.
 
  • Like
Reactions: Blitz
It would be easier to use:
code_language.skript:
on step on slime block:
    set {_contains} to subtext of "%player's world%" from 1 to 4
    if {_contains} is "pvp_":
        # do stuff

...Or you could shorten that to:
code_language.skript:
on step on slime block:
    if subtext of "%player's world%" from 1 to 4 is "pvp_":
        # do stuff

on step on slime block:
    if "%subtext of ""%player's world%"" from 1 to 4%" is "pvp_":
        # do stuff

I might have messed up on the second example of the second code snippet, as I wasn't sure if two percent signs are required inside of an expression.
Hey! I didn't even know that was possible ;O. You really do learn something new everyday!
 
Thank you @mathhulk examples 1 and 2 work flawlessly
Thank you @Blitz

Final launchpad code:
code_language.skript:
on step on slime block:
    if subtext of "%player's world%" from 1 to 4 is "pvp_":
    #only launchs players in worlds which name starts with "pvp_"
        wait 1 tick
        push player forwards with force 2
        wait 1 tick
        push player upwards with force 1
        play "ITEM_FIRECHARGE_USE" to player at volume 1
        #show 10 "slime" particles at location of player for player offset by 0, 0, 1
        set {launched::%player%} to true
      
on damage:
    if damage cause is fall:
        if {launched::%victim%} is true:
            cancel event
            set {launched::%victim%} to false
on join:
    set {launched::%player%} to false
on death:
    set {launched::%player%} to false
on load:
    delete {launched::*}
 
  • Like
Reactions: Blitz
Status
Not open for further replies.