This seems like a perfect solution for the user side of things for me, how would I implement the workings for an API like that on the other side?Robin wrote:I'd use a combination of callback functions and a few API functions for that (similar to the interface LÖVE exposes). For example:Frohman wrote:Well I was less concerned with how to go about obtaining the scripts, more about how to run them and how to allow them to interact with the game (obtain certain values from the game and also pass back instructions).For instructions, you could run them directly or use a queue to execute the instructions the user code gives back later.Code: Select all
function character.update(dt) -- do stuff if API.getMyCharacterX() > 10 * dt then API.goLeft(10 * dt) end end
Some pointers wanted regarding user created content
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Some pointers wanted regarding user created content
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Some pointers wanted regarding user created content
Ehm, how you would normally do it? If you want a queue rather than direct execution (maybe to prevent users from making all-powerful characters?), you would have things like:Frohman wrote:This seems like a perfect solution for the user side of things for me, how would I implement the workings for an API like that on the other side?
Code: Select all
queue = {}
function API.goLeft(n)
queue[#queue+1] = {"goleft", n}
end
actions = {}
function actions.goleft(n)
player.x = player.x - n
end
function doaction()
a = table.remove(queue)
actions[a[1]](a[2])
end
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], zingo and 0 guests