4ian / GDevelop

:video_game: Open-source, cross-platform game engine designed to be used by everyone.
https://gdevelop.io
Other
6.62k stars 724 forks source link

Function arguments names restriction #6621

Open f0nar opened 2 weeks ago

f0nar commented 2 weeks ago

Is there an existing issue for this?

Describe the bug

I found funny issue I am sure it is not super priority task but I think it is useful to know

The key is that we cannot use any name as parameters for expression and condition functions (possibly action too, I didnt check it yet)

I created function of expression and condition type with parameter named "Number" and return type "Number". Once I used it I receive error that Number is not function. The key is that after gdevelop function transpilation we receive js function with parameters named as ones in gdevelop. So we will have parameter Number of number type and later you are trying to use global Number function to process returned value. Here is the issue)

I think it is might be super unobvious for guys who didnt have coding experience.

I see three solutions:

Steps to reproduce

  1. Create custom extension
  2. Add function of expression and condition type
  3. Add to it parameter with "Number" name
  4. Make it return Number
  5. In function eventsheet create js code block and add there
    const numberParam = eventsFunctionContext.getArgument("Number");
    eventsFunctionContext.returnValue = Math.random() * 100;
  6. Use defined function in scene eventsheet

GDevelop platform

Desktop

GDevelop version

5.3.194

Platform info

No response

Additional context

No response