Call Lua from Fun

Any information about the fun attribute is given here.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Posts: 3714
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Call Lua from Fun

#1

Post by Lobby »

If you, for whatever reason, want to combine Fun and Lua: There's an action to call Lua functions from Fun.

On the json side :json

Code: Select all

"action":{"type":"call","id":"$targetscriptdraftid","code":"functionName","frame":42}
On the Lua side (the script that is attached to the $targetscriptdraftid object) :lua:

Code: Select all

function script:functionName(x, y, lvl, frame)
  -- Do some stuff
end

Remarks:
-The "frame" parameter is there to pass custom information (an integer) to the function; you don't have to use it.
-If you don't provide a target script via the "id" tag all scripts that contain a function as specified by "code" will be called.
-In case there are mutliple scripts attached to the object identified by "id" all of their script:functionName functions will be called
-The target function has to be attached to a script as shown in the definition above (script:functionName)
-Return values of the function will be ignored by fun

For technical reasons you cannot access Lua from fun conditions. That is because fun conditions are optimized to be evaluated concurrently which is not supported by Lua.

User avatar
Hadestia
Inhabitant of a Megalopolis
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Call Lua from Fun

#2

Post by Hadestia »

Is these can <trlggered> local function such as GUI dialog inside that local function?
Thanks in advance

User avatar
Hadestia
Inhabitant of a Megalopolis
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Call Lua from Fun

#3

Post by Hadestia »

Passing of argument values seems wrong my script can't archive my target value from what I've set from fun

Post Reply Previous topicNext topic

Return to “Fun attribute”