Jump to content

Run sbx scene outside the editor


gordonramp
 Share

Recommended Posts

Great to be exploring the new editor. I need something clarified. When I make a scene which is saved as a .sbx file, how do I run that outside the editor? Can I run it with the Lua Engine? I found the spinning cube in Lua but is there any example Lua code to run a .sbx scene.

AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64.

Link to comment
Share on other sites

Guest Red Ocktober

hey G... in the root directory there are two example scripts that can be loaded and run from the script editor...

 

also... here's a quick and dirty example that worked for a scene i did in the editor... give it a try... substitue your scene path and set the camera so you can see the scene (or spin it)...

 

 

--Register abstract path
RegisterAbstractPath("")

--Set graphics mode
if Graphics(1024,768)==0 then
Notify("Failed to set graphics mode.",1)
return
end

world=CreateWorld()
if world==nil then
Notify("Failed to initialize engine.",1)
return
end

gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8)

camera=CreateCamera()
camera:SetPosition(Vec3(4,1,-10))
camera:Turnf(0.0,42,0.0)



scene=LoadScene("abstract::myfirst230.sbx")


while AppTerminate()==0 do

--camera:Turnf(0,AppSpeed()/12,0)
UpdateAppTime()
world:Update(AppSpeed())

SetBuffer(gbuffer)
world:Render()
SetBuffer(BackBuffer())
world:RenderLights(gbuffer)

DrawText(UPS(),0,0)
Flip(0)
end 

 

 

good luck...

 

--Mike

Link to comment
Share on other sites

Theoretically when you add this code block to the fpscontroller.lua, after the line fw=GetGlobalObject("framewerk"), it should make it runnable from outside Editor, but for some reason it crashes. Maybe Josh could check why?:

if fw==nil then
--Register abstract path
RegisterAbstractPath("")

--Set graphics mode
if Graphics(1024,768)==0 then
	Notify("Failed to set graphics mode.",1)
	return
end

--Create framewerk object and set it to a global object so other scripts can access it
fw=CreateFramewerk()
if fw==nil then
	Notify("Failed to initialize engine.",1)
	return
end
SetGlobalObject("framewerk",fw)
fw.main.camera.position.y=20
scene=LoadScene("abstract::tunnels.sbx")
end

If you change it to load train.sbx, then it doesn't crash, but the player doesn't collide with the terrain.

I tried scene:SetType(1), but there is no such command.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Hi Red..

That code partialy works,no skybox turns up..I also adapted the spinning cube by just adding the LoadScene() command, that also worked, but again no atmospherics.

 

Lumooga..

That's what is needed, a first person example (with and without a gun) that runs in Lua outside the Editor.

AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...