Jump to content

Recommended Posts

Posted

Dear People of this Forum,

 

I want to transfer a string to the windows - clipboard on the Lua Leadwerks version.

 

how can I do so?

 

PS: how can I use Windows API in general with Lua?

 

thanks for your Help!

 

yours

Max Aigner

Posted
PS: how can I use Windows API in general with Lua?

 

You don't. It has to be exposed somehow to Lua. Either you do that manually or see if someone else has already done that in the Lua community (as it's not really LE specific).

  • Upvote 1
Posted (edited)

You can try this:

https://github.com/luapower/winapi/blob/master/winapi/clipboard.lua

but you probably need to disable the Lua Sandbox in the Editor and you will not be able to use this in the Leadwerks Game Launcher.

 

Or i can probably make you a library with Lua ffi,

but that will definetly require you to disable Lua Sandboxing and prevent publishing to the Leadwerks Game Launcher.

 

 

//Edit:

here i added it to my small library.

https://cloud.software-sl.de/index.php/s/JLiv6hkd9koCLms

 

copy both files to your root directory of your game. (where your exe is)

 

and just add in your Main.lua or App.lua right at the top the line:

import("LEAddon.lua")

 

then you can use

addon.SetClipboardToText("This will end up in the clipboard")

 

or

local clipboardtext = addon.GetTextFromClipboard()

Edited by beo6
  • Upvote 1
Posted

Hello Beo6!

that looks very nice!

I tried to include it into the main function after I copied the DLL and the lua file into the Folder where the EXEs are.

just when I add the

import("LEAddon.lua")

into the main file on the very top, it prompts an error:

 

attempt to call global 'require' - a nill value.

 

do I have to change some more?

I am quite new to lua

 

 

yours

Max

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...