• 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
BaneTrapper

Lua scripting

10 posts in this topic

Hello.


Lua scripting

Any suggest for Lua scripting tutorials, are there any good ones?

 

Also why would learning lua scripting be any good?

0

Share this post


Link to post
Share on other sites

Also why would learning lua scripting be any good?

Why are you asking to learn it, when you don't see any benefit in it ? blink.png

 

There's no supreme language, there are only use-cases in which one language is better suited than an other one. So, what is your use-case ?

 

When you need tutorials about lua,take a look at its homepage doc-section. Most often googling for "lua + problem" lead me to examples. Lua isn't really hard at all.

Edited by Ashaman73
2

Share this post


Link to post
Share on other sites

Also why would learning lua scripting be any good?

 

If you write the "base code" for a game in C++, you can use Lua scripts to write the logic for the game. Lua feels more like VB than C++, so if you are more familiar with VB, you can use Lua to capture that while still holding on to the advantages of C++.

2

Share this post


Link to post
Share on other sites

Why are you asking to learn it, when you don't see any benefit in it ? blink.png

I see benefits from learning lua...

 

If you meant on

 

Also why would learning lua scripting be any good?

It would be nice to know what experienced users see most beneficial and most useful from lua. And also what is just good for or why would .

 

 

Also why would learning lua scripting be any good?

That should be my question, thanks.

 

 

There's no supreme language, there are only use-cases in which one
language is better suited than an other one. So, what is your use-case ?

Witch is supreme language... totally agreed, Each has it own "I would be better at this then others"

My use-case would be to expand my knowledge, also the tools i can use. I am pretty limited of what i can use, knowledge wise.

 

One example would be, why do people wanna learn how to kill vampire? its possible that they will never find them self fighting vampires, but still people learn it...

 

 

When you need tutorials about lua,take a look at its homepage doc-section. Most often googling for "lua + problem" lead me to examples. Lua isn't really hard at all.

I did say "Any suggest for Lua scripting tutorials"( As in, i was looking for a tutorial that is approved that is good ). And most possibly i didn't stretch the question enough, or well enough to put my point on, i had issues with c++ tutorials when i was starting ( i will explain with short code )

 

void func(int* a)
{
}
int main()
{
int b;
func(&b);//Here he spoke as it was passed as a reference ( but the operator & in this case provides a memory address)
}

As a newbie, i thought "that" was happening, but then when you see on other guy "what" happens you are like... But the other guy said that "this" is happening and the big clash of WTF is happening and what is correct and what is wrong appear?
 

Edited by BaneTrapper
0

Share this post


Link to post
Share on other sites

If the game code is structured right, Lua would allow rapid prototyping. Imagine that there is no compile button.

This makes it possible to be in a highly productive state for longer periods of time. Rather than making a change and then wait to re-compile. The user

just makes a change and re - run the game. 

 

Embeding Lua is not the hardest thing in the world.

Here is one good example tutorial (in my opinion): http://forums.tigsource.com/index.php?topic=22524.0

 

If you think that scripting is needed to fulfill a certain goal in your game, go for it. If it doesnt work right, at the very least, you would have learned something new hehe.

1

Share this post


Link to post
Share on other sites

I learned Lua there: http://www.lua.org/pil/contents.html

Its a whole book, they put it on their website when a new version of the book/Lua came out, but its still good I think.

 

A while ago I was writing some scripts for a Minecraft addon called Computercraft, so if you have a Minecraftaccount and like playing around while learning, have a look at that mod, its like programming a little robot (with Lua).

 

Although I don't really need Lua anymore, IMHO its always good to see how other languages look like, work and what patterns people use with different languages.

0

Share this post


Link to post
Share on other sites

Personally, i've just made my first project that use lua for a file renamer program. Since i could not find a way to build an UI that was easy to use and could do everything i wanted to, i decided to let lua do the dirty job of generating the files name using any algorithm i wished, without the need for recompiling the program. Another thing you could do with it is to use it to initialize variables and settings when you start a project for example, so you dont need to recompile it either.

 

I found this code somewhere, then modified it a little. It make lua very easy to use:

 

#ifndef _LUA_SCRIPT_H_#define _LUA_SCRIPT_H_#ifdef __cplusplus//----------------------------------------------------------------------//#pragma comment (lib, "lua51.lib")#pragma comment (lib, "lua5.1.lib")extern "C" {	#include "lua.h"	#include "lualib.h"	#include "lauxlib.h"}//----------------------------------------------------------------------//#include "Windows.h"#include //----------------------------------------------------------------------//using namespace std;class CLuaScript {protected:	lua_State *L;public:	CLuaScript();	~CLuaScript();	void InitLua();	void CloseLua();	void ResetLua();	bool LoadScript(string scriptfile);		void CallFunction(string name);	bool SafeCallFunction(string name, char *err = NULL);	string GetGlobalString(string name);	void   SetGlobalString(string name, string value);		double GetGlobalNumber(string name);	void   SetGlobalNumber(string name, double value);		bool GetGlobalBoolean(string name);	void SetGlobalBoolean(string name, bool value);};#endif#endif //_LUA_SCRIPT_H_
#include "LuaScript.h"CLuaScript::CLuaScript(){	L = NULL;	InitLua();}CLuaScript::~CLuaScript(){	CloseLua();}void CLuaScript::InitLua(){	if(!L){		L = lua_open();		luaL_openlibs(L);	}}void CLuaScript::CloseLua(){	if(L){		lua_close(L);		L = NULL;	}}void CLuaScript::ResetLua(){	CloseLua();	InitLua();}bool CLuaScript::LoadScript(string scriptfile){	ResetLua();	bool value = true;	try {		luaL_dofile(L, scriptfile.c_str());	} catch(...) {		value = false;	}	return value;}void CLuaScript::CallFunction(string name){	//call script function, 0 args, 0 retvals	lua_getglobal(L, name.c_str());	lua_call(L, 0, 0);}bool CLuaScript::SafeCallFunction(string name, char *err){	//call script function, 0 args, 0 retvals	lua_getglobal(L, name.c_str());	int res = lua_pcall(L, 0, 0, 0);	if(res > 0){		const char *pErrMsg = lua_tostring(L, 1);		if(!err){			string Caption;			Caption = "Lua: Error in function " + name + "().";			MessageBox(0, pErrMsg, Caption.c_str(), MB_OK);		} else {			sprintf(err, "%s", pErrMsg);		}		return false;	}	return true;}string CLuaScript::GetGlobalString(string name){	string value = "";	try {		lua_getglobal(L, name.c_str());		const char *pValue = lua_tostring(L, -1);		if(pValue)			value = pValue;		lua_pop(L, 1);	} catch(...) {		}	return value;}void CLuaScript::SetGlobalString(string name, string value){	lua_pushstring(L, value.c_str());	lua_setglobal(L, name.c_str());}double CLuaScript::GetGlobalNumber(string name){	double value = 0.0;		try {		lua_getglobal(L, name.c_str());		value = lua_tonumber(L, -1);		lua_pop(L, 1);	} catch(...) {		}	return value;}void CLuaScript::SetGlobalNumber(string name, double value){	lua_pushnumber(L, (int)value);	lua_setglobal(L, name.c_str());}bool CLuaScript::GetGlobalBoolean(string name){	bool value = false;		try {		lua_getglobal(L, name.c_str());		value = lua_toboolean(L, -1) != 0;		lua_pop(L, 1);	} catch(...) {		}		return value;}void CLuaScript::SetGlobalBoolean(string name, bool value){	lua_pushboolean(L, (int)value);	lua_setglobal(L, name.c_str());}

 

That might not be the best wrapper out there, but it do the job fine for a simple project.

Edited by jbadams
Restored post contents from history.
1

Share this post


Link to post
Share on other sites

On Zerobeat's note about it not being compiled, you could use Lua to make it easier for others to write "mods" for your games(if your into that). I really like the open source model, and an easy to use and understand scripting language supports that well.

1

Share this post


Link to post
Share on other sites

Embeding Lua is not the hardest thing in the world.

Here is one good example tutorial (in my opinion): http://forums.tigsource.com/index.php?topic=22524.0

 

If you think that scripting is needed to fulfill a certain goal in your game, go for it. If it doesnt work right, at the very least, you would have learned something new hehe.

I will check it up.

As you said, at least i will know more. I am not expecting to master lua, simply to learn and maybe use it to my advantages.

 

 

 

I learned Lua there: http://www.lua.org/pil/contents.html

Its a whole book, they put it on their website when a new version of the book/Lua came out, but its still good I think.

 

A while ago I was writing some scripts for a Minecraft addon called Computercraft, so if you have a Minecraftaccount and like playing around while learning, have a look at that mod, its like programming a little robot (with Lua).

 

Although I don't really need Lua anymore, IMHO its always good to see how other languages look like, work and what patterns people use with different languages.

That is some amount of tutorial i will surely check that up.

Also for computer craft ^^ as much as i would like to try it out, i got no minecraft :(.

Learning to see how i like it, if i don't like it at least i know it partially and if i ever need it, well its gonna be easier to pick up.

 

...

Thanks for sharing the code

 

On Zerobeat's note about it not being compiled, you could use Lua to make it easier for others to write "mods" for your games(if your into that). I really like the open source model, and an easy to use and understand scripting language supports that well.

Open source is what i am aiming for.

0

Share this post


Link to post
Share on other sites

Lua is one of the common languages being used.  It has some advantages for certain uses and many people prefer it in those situations.  Lua is fairly common in game development, especially when multiple languages are included in the game source code. Learn what the strengths and weaknesses are of Lua in order to know when and where to use it.

 

A comprehensive book with exercises is the best way to learn, but there are some decent online tutorials for beginners. 

 http://lua-users.org/wiki/TutorialDirectory

0

Share this post


Link to post
Share on other sites

Plow through the documentation to decide if it's smething you want to apply to what you already know about programming, if anything.  Otherwise you could learn it with an Engine like Love2d which should give you room to experiment.  Lua is also very "this is how it is" as far as syntax so I say give it a shot if you find other languages a bit tedious.

Edited by iGoogleThis
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