Some questions about love.thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
louie999
Prole
Posts: 46
Joined: Fri Mar 06, 2015 9:01 am

Some questions about love.thread

Post by louie999 » Tue Aug 25, 2015 3:14 pm

In the game I'm making I want it to be that people can mod my game, but I want to restrict the use of some functions by the user, can I do that by using love.thread?

Code: Select all

fun = true
school = true

function isItFun()
    if school then
       fun = false
    end
    if not fun then 
       me:explode()
    end
end

User avatar
Nixola
Inner party member
Posts: 1941
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Some questions about love.thread

Post by Nixola » Tue Aug 25, 2015 5:32 pm

I think a combination of [wiki]love.filesystem.load[/wiki] and [manual]setfenv[/manual] would be what you need.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Some questions about love.thread

Post by T-Bone » Thu Aug 27, 2015 1:11 pm

love.thread could be used like that, yes. The mod's code would run on a thread, and is allowed to affect the game code only via a well-defined thread-communication API. It's not the first thing I'd try, but it could work. There are some security issues you might want to think about; you probably want some kind of sandboxing anyway and then I don't think the separate thread would matter as much.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 13 guests