Skript: Cannot do arithmetic involving 2 or more return value functions

Created on 12 Jun 2020  路  2Comments  路  Source: SkriptLang/Skript

Description

When attempting to perform any math operation that involves multiple return-value functions, Skript throws an error and the operation fails.

Steps to Reproduce

  1. Create a function that returns a number.
  2. Attempt to perform any math operation that calls the function more than once.
  3. Skript will report an error that "functions cannot be used here". The math operation will not be performed.

Sample Error:

Server Information

Server version/platform: Paper 1.12.2-1606
Skript version: 2.4.1 & 2.5-alpha-3
Tested with no addons installed.

Additional Context

Here is the test script I created to demonstrate this issue:

function getANumber() :: number:
return 2

command /testFuncReturn:
trigger:
set {_test} to getANumber() + getANumber()
send "%{_test}%" to the player

The command should send the number 4 to the player, but instead sends nothing.

bug lowest

Most helpful comment

using
set {_test} to (getANumber()) + (getANumber())
works, so it seems like you must surround both with ()

it is a long known skript bug I guess

All 2 comments

using
set {_test} to (getANumber()) + (getANumber())
works, so it seems like you must surround both with ()

it is a long known skript bug I guess

Might be worth mentioning that the following parses and works correctly:

function getNum() :: number:
    return 10

set {_result} to getNum() + getNum() + 1
Was this page helpful?
0 / 5 - 0 ratings