## Oysi's 3D Rendering & Physics Engine

Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

### Re: Oysi's 3D Rendering & Physics Engine

Haha! Of all the things, it's the console you want to know about. xD

Very well.

veethree is indeed correct, it does loadstring. At first it sets up an environment for the console to use, and adds in all the elements from _G, such that it works like any other script. Then in the main script I put in all the stuff I want it to have extra, variables and such. And I use this separate environment because all my stuff is local, which doesn't translate over to different environments (unlike globals). On top of that, whatever global variables you define (x = 2 for example) will still work on the preceding calls as well. Then it's just a matter of opening the console, registering what you type (which you can do with love.textinput), and running whatever.

Really the only difficult part I suppose would be:

Code: Select all

local func, err = loadstring(code)
if func then
local success, result = coroutine.resume(coroutine.create(func))
if success then
-- everything worked just fine, and if the thingy returned anything, it's 'result'
-- (it can also return several values, at which point you need to pack it in a table and such)
else
-- runtime error, the error is 'result'
end
else
-- compile error, the error is 'err'
end

Or if you want to see how I made it, check this.

Take note that I never got around to rewriting it. So it's really just a prototype. But it does what I needed it to do, and very easy to use. Just call those functions through their respective love functions, and you're pretty much good to go.

Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: Oysi's 3D Rendering & Physics Engine

A question, perhaps. Is there here a real gain in using coroutines ?

Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

### Re: Oysi's 3D Rendering & Physics Engine

In this case, probably not. In this case, pcall should work the same way.

In different scenarios, coroutines are extremely helpful. For the purposes of a console, I guess the main advantage is the fact that you can yield a coroutine, and then potentially resume it later on (and repeat). Which allows you to do things like wait 3 sec, wait for an event, etc...

Creator
Prole
Posts: 3
Joined: Sat Oct 17, 2015 10:01 am

### Re: Oysi's 3D Rendering & Physics Engine

Why do you do this?

Showing us your awesome engine without any code to learn from. Why?

bobbyjones
Party member
Posts: 720
Joined: Sat Apr 26, 2014 7:46 pm

### Re: Oysi's 3D Rendering & Physics Engine

Bro don't worry we have a new better open source replacement. Love3d \o/
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.

Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

### Re: Oysi's 3D Rendering & Physics Engine

STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

### Who is online

Users browsing this forum: No registered users and 4 guests