Skript

Skript

788k Downloads

Wait in if statement branch causes the other branch to be delayed

Closed this issue ยท 4 comments

commented

Skript/Server Version

[17:09:31 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[17:09:31 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[17:09:31 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[17:09:31 INFO]: [Skript] Server Version: 1.21.8-81-55de442 (MC: 1.21.8)
[17:09:31 INFO]: [Skript] Skript Version: 2.12.1 (skriptlang-github)
[17:09:31 INFO]: [Skript] Installed Skript Addons: 
[17:09:31 INFO]: [Skript]  - skript-reflect v2.6 (https://github.com/SkriptLang/skript-reflect)
[17:09:31 INFO]: [Skript]  - skript-placeholders v1.7.0 (https://github.com/APickledWalrus/skript-placeholders)
[17:09:31 INFO]: [Skript] Installed dependencies: None

Bug Description

syntax errors after conditions

Expected Behavior

parsing errors

Steps to Reproduce

on damage:
  if {boosters::*} contains attacker:
    if attacker has cooldown for attacker's tool:
      cancel event
      stop
    set damage to damage * 2
    wait tick
    set attacker's cooldown for attacker's tool to 5 second
  else:
    set damage to 0 # can't be used after wait
function teleporttosky(p: player) :: boolean:
  loop 15 times:
    teleport {_p} to location 5 blocks above {_p}
    return true # can be used only in functions?
  return false # can be used only in functions?

Errors or Screenshots

[17:25:03 INFO]: [Skript] Reloading test.sk...
[17:25:03 INFO]: Line 15: (test.sk)
[17:25:03 INFO]: The return effect can only be used in functions, custom expressions, sections, custom syntax parse sections and custom conditions
[17:25:03 INFO]: Line: return true# can be used only in functions, ...?
[17:25:03 INFO]:
[17:25:03 INFO]: Line 16: (test.sk)
[17:25:03 INFO]: The return effect can only be used in functions, custom expressions, sections, custom syntax parse sections and custom conditions
[17:25:03 INFO]: Line: return false# can be used only in functions, ...?
[17:25:03 INFO]:
[17:25:03 INFO]: Line 10: (test.sk)
[17:25:03 INFO]: Can't change the damage anymore after the event has already passed
[17:25:03 INFO]: Line: set damage to 0# can't be used after wait
[17:25:03 INFO]:
[17:25:03 INFO]: Encountered 3 errors while reloading test.sk! (41ms)

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
commented

these errors are fixed by transferring them to a separate function, but it is rather unpleasant that this cannot be used directly.

commented

since teleporting may cause chunks to load asynchronously, teleporting may have a delay. using

force teleport {_p} to location 5 blocks above {_p}

does not result in the same error for me. tested on 1.21.3 with Skript 2.12.1

commented

since teleporting may cause chunks to load asynchronously, teleporting may have a delay. using

force teleport {_p} to location 5 blocks above {_p}
does not result in the same error for me. tested on 1.21.3 with Skript 2.12.1

yes, the second problem is fixed with force teleport

commented

can confirm the damage issue on 1.21.3 with Skript 2.12.1.

on damage:
  if 1 = 2:
    wait tick
  else:
    set damage to 0
[13:14:50 INFO]: [Skript] Reloading x.sk...
[13:14:50 INFO]: Line 5: (x.sk)
[13:14:50 INFO]:     Can't change the damage anymore after the event has already passed
[13:14:50 INFO]:     Line: set damage to 0
[13:14:50 INFO]:  
[13:14:50 INFO]:     Encountered 1 error while reloading x.sk! (6ms)