• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Migi0027

Mono or Lua - Scripting

12 posts in this topic

Hi guys,

 

so currently I've got a very vague implementation of Mono Embedded C#, and also of Lua, but I'd rather focus on on or the other. I've been focusing on mono, but I'm slowly realizing that it gets complicated, especially because of the data types which needs to be passed between c# and c++. On the other hand Lua hasn't really been troubling me, and I really like the syntax and everything, it's simple and fast.

 

so I've considered completely removing (or just disabling) the Mono Embedded Runtimes, and focusing completely on using Lua as a scripting language.

 

What are your opinions on this?

 

Thank you for your time.

-MIGI0027

Edited by Migi0027
0

Share this post


Link to post
Share on other sites

Depends entirely on what you're using your scripting for.  If you plan to implement large amounts of code in script - especially performance-sensitive stuff - then go Mono.  If you're just using it for glue and high-level logic, the ease of integrating Lua is nice.

1

Share this post


Link to post
Share on other sites

I never worked with Lua, but worked with mono for a considerable while, and I loved most of it. I just had a base class that dealt with the object glue (store a pointer to the native object, get the native object from the mono object and that kind of stuff) and passed structs by ref between native<->script with no problem at all. Even arrays were pretty easy to pass from C++ to Mono

 

What kind of datatypes are you having trouble with?

0

Share this post


Link to post
Share on other sites

You mean pointers to structs or to objects?

 

Here's an example of me passing a pointer to a C++ on-stack struct:

bool RayCastResults::call_internalAddResultOrdered( RayCastResult& result )
{
	MonoObject* excep = nullptr;

	MonoObject* resObject = mono_value_box( _domain, _classResult, &result );

	_method_internalAddResultOrdered( _obj, resObject, &excep );
	if( excep )
	{
		mono_print_unhandled_exception( excep );
		return false;
	}

	return true;
}

"_classResult" is: "_classResult = mono_class_from_name_case( img, "Engine.Physics", "RayCastResult" );"

Which on C# side is:

using System;
using System.Collections.Generic;

namespace Engine
{
	namespace Physics
	{
		public class RayCastResults
		{
			private void internal_AddResultOrdered( RayCastResult result )
			{
				...
			}
		}

		public struct RayCastResult
		{
			public override string ToString()
			{
				return string.Format("[RayCastResult] distance: {0}", distance);
			}

			public float distance;
			public CollisionObject body;
			public Shape shape;
			public Vector3 normalWorld;
			public Vector3 pointWorld;
		}
	}
}

If passing a pointer to an object, you just need to pass the MonoObject* pointer. Sometimes it's a good idea to have internal methods on C# side where you do some processing on the C++ passed data before calling the real final method.

Edited by mdias
0

Share this post


Link to post
Share on other sites

Thanks for the info, I'll test it soon.

 

What about if I keep Mono for the game mechanics, like generating the world and the game logic, and Lua for objects/actors which do not need complicated tasks.

0

Share this post


Link to post
Share on other sites

I just noticed I posted an example passing the struct by value instead of reference. I don't have the code at hand but as far as I remember, to pass as reference you just pass a normal C++ pointer as an argument to the method.

 


What about if I keep Mono for the game mechanics, like generating the world and the game logic, and Lua for objects/actors which do not need complicated tasks.

Like I said, I never worked with Lua, so I'm not familiar with it's strengths or weaknesses. However, it looks weird to me that different parts of the engine are scripted with different languages.

I don't know if it applies to your project, but I'd abstract away all interactions with scripting so you could script any part of the engine with any or multiple implementations (including Mono, Lua and others) with relative ease. Maybe this way you could stick to just one of the scripting engines like you want and implement an other at a later stage if the need arises.

 

Regarding "Lua vs Mono" I believe you'll have to tell more about the kind of project you're working on.

0

Share this post


Link to post
Share on other sites

 

 

Regarding "Lua vs Mono" I believe you'll have to tell more about the kind of project you're working on.

 

Well, I like to say I'm building an engine, though I develop on this engine as my game develops, like I suddenly realize, I need "that", so, I go and implement it and use it.

 

Though in the beginning till now I've just been trying to implement features and working on the flexibility of the engine, and now I'm actually starting doing something with it, in this case, a small game.

 

But, the small project I'm currently doing is a sandbox, where the player can place any objects and create his own shapes and stuff, it's still very vague, but I'm liking the progress. So I'd like to move the whole world generation and logic to a scripting environment.

0

Share this post


Link to post
Share on other sites

I like using Lua. It is very easy to understand and very flexible. You can make arrays work the way you want them to (doesn't use arrays, uses tables) and you can make classes work the way you want them to (no object oriented programming, so no classes, but you can fake it easily). 

0

Share this post


Link to post
Share on other sites

I like Lua since the simple nature of it forces you to think carefully what to do with scripts and what to do with c/c++ for example. as mentioned Lua tables are very flexible and pretty fast so you can do a lot of crazy things with them.

 

In my current project I do all the per frame update stuff with c++ and Lua just take care of callbacks and define objects

0

Share this post


Link to post
Share on other sites

LUA as well :) It's easy, small and fast. And most of all, it makes me feel like its just a small addition to the rest of my code and not some bloated monster that wants to take over and dominate everything.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0