Jump to content

Changing from Indie Version to Standard (Using Indie Project with Standard Upgrade)


Defranco
 Share

Recommended Posts

I upgraded from Indie to Standard yesterday as I am interested in utilizing modules/apps and other benefits of programs like Neosis GUI which only works for C++.

 

I installed the DLC, and created a new project, using C++ instead of LUA.

 

My issue is moving my existing project over (my start.map) to the new project.

 

copy-paste of the map / texture / prefab / models , etc did not simply just work.

 

 

I had a look at Aggror's first tutorials 1-8 which covers Intro to C++, and models, and shapes, and other stuff using C++.

 

Do I need to start this first for the new project?

 

My existing project already works in Indie version by just hitting play. It loads the game fine.

 

 

Any help with this would be greatly appreciated. Let me know if I need to do a lot of set-up first, or if the existing project I worked on before should be able to just be copied over.

 

 

Edit; been reading other posts of users who upgraded. My understanding is that theres no default FPS character controller for C++ where as it has it in LUA. So I would need to do the follow along of Aggror's beginning tutorials to prepare the change over?

 

Edit2: I can get the map to copy, just can't run it. Gives a game.exe error. (I am assuming this is because the C++ isn't setup yet?)

Link to comment
Share on other sites

Ahh ok, the guide I had open before mentioned 2010.

 

I installed the VS2013, and it doesn't launch anything. It gives around 85-120 errors, then just closes.

 

Most errors are PDB errors, which I believe I can ignore, but theres also runtime errors (memory errors), .tex and .mat errors, which is weird as they dont give error in leadwerks editor.

 

Heres some of the last of the debug;

 

The thread 0x2204 has exited with code 1 (0x1).

The thread 0x1fbc has exited with code 1 (0x1).

The thread 0x2648 has exited with code 1 (0x1).

The thread 0xc40 has exited with code 1 (0x1).

The thread 0x2130 has exited with code 1 (0x1).

The thread 0x1d18 has exited with code 1 (0x1).

The thread 0xf68 has exited with code 1 (0x1).

The thread 0xf24 has exited with code 1 (0x1).

The program '[6912] MyGame2.debug.exe' has exited with code 1 (0x1).

 

 

Attempt to index global "app" (A Nil Value) (EDIT2: this error is caused by app.cpp something about null, or function.) nil & function are used in LUA, but not in C++, I didn't see any nil or function mentioned in app.cpp but there is 3 (NULL) as some things from the default are not defined.

 

 

I've tried build/rebuild, and running with and without debug.

 

 

EDIT; I solved error c4018 by replacing int i with size_t i on line 58 of main.cpp

Link to comment
Share on other sites

I switched it from 32bit to 64bit for debugging;

 

And it gives

 

2 errors, 1 warnings.;

 

Warning "C4267:'argument'conversion from 'size_t' to 'const int', possible loss of data - main.cpp line 33

 

Which says on line 33 "if (String::Right(settingsfile, 6) == ".debug") settingsfile = String::Left(settingsfile, settingsfile.length() - 6);"

 

 

Errors are; LNK1104: cannot open file 'lua51.lib'

And; IntelliSense enumeration value is out of 'int' range.

 

 

EDIT: for the LNK1104 error, in project properties, linker, input, the discrepancies field has a error - this could be the reason for it.

 

EDIT2: my file paths show x86, when changing it to 64bit, it wants 64bit file paths. But I have x86 file paths. so I guess I need to use 32bit debug.

Link to comment
Share on other sites

I can get it compiled,

 

Then when I go back to Leadwerks editor - most the start-up errors dissapear,

 

Its stuck on;

 

Script Error

 

attempt to index global 'App' (a nil value)

 

Line 10

 

-------------- this is referring to line 10 of the inventory.lua script from tutorial 16/17 by Jorn Theunissen

 

function Script:Start()

self.screenWidth = App.context:GetWidth()

 

 

It also gives warning: Lua Sandboxing is Disabled.

 

 

Now, if I remove the inventory.lua script from my player, the game runs.

 

However, it's ignoring my FPSplayer controller, its spawning me at 0.0.0 in the middle of the map, with fly mode/walk thru walls. I also cant interact with objects.

Link to comment
Share on other sites

That would explain it. Normally when you have a lua project. A window, context and world are created in the App.lua. When you make a project with C++, the app.lua does not contain these variables. When you create a C++ project, it has an app.lua equivalent but it is in C++.

 

The lua scripts are refering to App.window and App.context but since the app.lua doesn't contain these variables, the player and inventory scripts no longer work. You can replace those variables with the Window:GetCurrent() and Context:GetCurrent

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/window/windowgetcurrent-r628

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/context/contextgetcurrent-r632

Link to comment
Share on other sites

IMPORTANT EDIT:

 

I think I got the camera working now. I made a new project, and copied everything over except SOURCE folder. Then in vs2013 - i re-compiled, and ran a fast debug, and did a release.

 

Now the camera works as intended. Everything is working now except for the inventory script.

 

Working on replacing : self.screenWidth = App.context:GetWidth() - to something that works. Im learning!

 

 

 

#include "App.h"

 

using namespace Leadwerks;

 

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}

 

App::~App() { delete world; delete window; }

 

bool App::Start()

{

int stacksize = Interpreter::GetStackSize();

 

//Get the global error handler function

int errorfunctionindex = 0;

#ifdef DEBUG

Interpreter::GetGlobal("LuaErrorHandler");

errorfunctionindex = Interpreter::GetStackSize();

#endif

 

//Create new table and assign it to the global variable "App"

Interpreter::NewTable();

Interpreter::SetGlobal("App");

 

//Invoke the start script

if (!Interpreter::ExecuteFile("Scripts/App.lua"))

{

System::Print("Error: Failed to execute script \"Scripts/App.lua\".");

return false;

}

 

//Call the App:Start() function

Interpreter::GetGlobal("App");

if (Interpreter::IsTable())

{

Interpreter::PushString("Start");

Interpreter::GetTable();

if (Interpreter::IsFunction())

{

Interpreter::PushValue(-2);//Push the app table onto the stack as "self"

#ifdef DEBUG

errorfunctionindex = -(Interpreter::GetStackSize()-errorfunctionindex+1);

#endif

if (!Interpreter::Invoke(1,1,errorfunctionindex)) return false;

if (Interpreter::IsBool())

{

if (!Interpreter::ToBool()) return false;

}

else

{

return false;

}

}

}

 

//Restore the stack size

Interpreter::SetStackSize(stacksize);

 

return true;

}

 

bool App::Loop()

{

//Get the stack size

int stacksize = Interpreter::GetStackSize();

 

//Get the global error handler function

int errorfunctionindex = 0;

#ifdef DEBUG

Interpreter::GetGlobal("LuaErrorHandler");

errorfunctionindex = Interpreter::GetStackSize();

#endif

 

//Call the App:Start() function

Interpreter::GetGlobal("App");

if (Interpreter::IsTable())

{

Interpreter::PushString("Loop");

Interpreter::GetTable();

if (Interpreter::IsFunction())

{

Interpreter::PushValue(-2);//Push the app table onto the stack as "self"

#ifdef DEBUG

errorfunctionindex = -(Interpreter::GetStackSize()-errorfunctionindex+1);

#endif

if (!Interpreter::Invoke(1,1,errorfunctionindex))

{

System::Print("Error: Script function App:Loop() was not successfully invoked.");

Interpreter::SetStackSize(stacksize);

return false;

}

if (Interpreter::IsBool())

{

if (!Interpreter::ToBool())

{

Interpreter::SetStackSize(stacksize);

return false;

}

}

else

{

Interpreter::SetStackSize(stacksize);

return false;

}

}

else

{

System::Print("Error: App:Loop() function not found.");

Interpreter::SetStackSize(stacksize);

return false;

}

}

else

{

System::Print("Error: App table not found.");

Interpreter::SetStackSize(stacksize);

return false;

}

 

//Restore the stack size

Interpreter::SetStackSize(stacksize);

 

return true;

}

 

 

When I run the game with debug - in leadwerks editor, it works fine (except inventory script) - it starts as the FPSplayer controller.

when I just hit play, the camera starts at 0,-2,3 or something, and it has no-clip/fly.

Link to comment
Share on other sites

--This function will be called once when the program starts

function App:Start()

 

--Initialize Steamworks (optional)

Steamworks:Initialize()

 

--Set the application title

self.title="MyGame"

 

--Create a window

local windowstyle = Window.Titlebar

if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+Window.Fullscreen end

self.window=Window:Create(self.title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle)

self.window:HideMouse()

 

--Create the graphics context

self.context=Context:Create(self.window,0)

if self.context==nil then return false end

 

--Create a world

self.world=World:Create()

self.world:SetLightQuality((System:GetProperty("lightquality","1")))

 

--Load a map

local mapfile = System:GetProperty("map","Maps/start.map")

if Map:Load(mapfile)==false then return false end

 

return true

end

 

--This is our main program loop and will be called continuously until the program ends

function App:Loop()

 

--If window has been closed, end the program

if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

 

--Handle map change

if changemapname~=nil then

 

--Clear all entities

self.world:Clear()

 

--Load the next map

Time:Pause()

if Map:Load("Maps/"..changemapname..".map")==false then return false end

Time:Resume()

 

changemapname = nil

end

 

--Update the app timing

Time:Update()

 

--Update the world

self.world:Update()

 

--Render the world

self.world:Render()

 

--Render statistics

self.context:SetBlendMode(Blend.Alpha)

if DEBUG then

self.context:SetColor(1,0,0,1)

self.context:DrawText("Debug Mode",2,2)

self.context:SetColor(1,1,1,1)

self.context:DrawStats(2,22)

self.context:SetBlendMode(Blend.Solid)

else

--Toggle statistics on and off

if (self.window:KeyHit(Key.F11)) then self.showstats = not self.showstats end

if self.showstats then

self.context:SetColor(1,1,1,1)

self.context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)

end

end

 

--Refresh the screen

self.context:Sync(false)

 

--Returning true tells the main program to keep looping

return true

end

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...