Jump to content
  • Advertisement

Best way to add an interactive scripting language to a game

Recommended Posts

I am thinking of making a game like screeps, where you use actual programming to control the game, but I'm not sure about the best way to do this.  I'm probably going to use lua or javascript for the language, and I would like to represent units in the game as objects that the user can command and modify, with restraints based on the actual game, like how screeps does it.  However, I am not sure how to get started.  I think I have to use C or C++ and then embed the languages, but I'm not sure where to go from there, for example, having objects in lua actually correspond to units in the game.  Are there any resources that explain how to do this?  Also, I'm not concerned about the graphics of the game whatsoever, it might as well just be a text adventure as far as I'm concerned, I just want the user to be able to control the game through scripting.

Share this post


Link to post
Share on other sites
Advertisement
18 minutes ago, h8CplusplusGuru said:

One thing you could do besides script-binding, is you could have a language that the user programs in, they submit their program, you check it for validity and then do some magic on it, and then - - send it to g++. 

Isn't that what embedding a script is?

Share this post


Link to post
Share on other sites
1 minute ago, h8CplusplusGuru said:

No, it's executing a script ( lua ) vs running a binary ( say from c++ ).

Do you know of any resource that show how to do this?

Share this post


Link to post
Share on other sites
2 minutes ago, h8CplusplusGuru said:

which one

Either, whichever one is more popular or easier.  I just need a way for the game to be controlled in real time by the scripts.

Share this post


Link to post
Share on other sites
2 hours ago, h8CplusplusGuru said:

ok, so I understand how to add functions from C++ to a lua environment.  But what I'm looking for is how to add an object (a unit from the game) from C++ to a lua env for the user to access, and when the user does something with the object in the lua script, it is reflected in the actual game.

Share this post


Link to post
Share on other sites

You could also offer some kind of node based scripting language like an AI Robot game on Android (which name I forgott :P ) did. You wrote "programs" for your robots to solve quests against an opposing team of robots in it.

This could be something very simplified in UI like this childs toy from the 90s

image006.jpg

Share this post


Link to post
Share on other sites

  • Advertisement
  • Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Shtabbbe
      I've had a game idea for a while, and I wanted to finally try to create it.
      Its a 2D open-world tile-based MMO. The concept is it is one world and multiplayer only, so everyone shares one world no matter region, platform, etc.
      I am having problems finding out what to use to start development, I tried Unity but saw some of the negatives and refrained and now im stuck, could anyone recommend some intermediate friendly 2D engines that can support what I am looking for? Preferably in languages that are or are somewhat like Java, C#, Python, JavaScript, Lua.
      Thanks for your help, im very new at this if you cant tell
    • By 3dmodelerguy
      A few questions about some c++ code
      So I am starting to get back into c++ after about 12 - 14 years away from it (and even back then, my level of knowledge was maybe a little above beginner) to do some game / SDL programming. I was following a tutorial to get at least a basic starting point for an entity component system and it works however there was some code that I don't quite understand even after looking around little.
      First pice of code is:
      T* component(new T(std::forward<TArguments>(arguments)...)); This seems to be assigning the `component` with the results of what is in the parentheses though normally I would expect this:
      T* component = new T(std::forward<TArguments>(arguments)...); Is this just syntax preference or does the compiler do something different with the parentheses (it is weird to me as when I see that, I think it is a function call)?
      The second piece of code I think I understand the general idea of what it is doing but some of the specific are escaping me:
      template <typename T, typename... TArguments> T& Entity::addComponent(TArguments&&... arguments) {   T* component = new T(std::forward<TArguments>(arguments)...); So from my understanding, the first line would basically take this:
      entity->addComponent<TransformComponent, int, int, int, int>(x, y, width, height); and take of the first item in the template and assign the to T and then "group" (not sure the correct term) the rest of the items as a collection of some sort and then the `...` on the second line would group the arguments (that would need to match the template group) that were passed in. Then the third line is effectively converting the template / passed in arguments to be called like this:
      TransformComponent* component = new TransformComponent(x, y, width, height); The parts that are a bit confusing to me is first the `&&`. From what I have read (from stack overflow), that symbol means rvalue reference or reference to an argument that is about to be destroyed. Not quite sure what it means by it about to be destroyed.
      The second part, which I think related to using `&&`, is the `std::forward<TArguments>`. The explainations that I have found so far as are bit confusing to me.
      I will continue to try to find the answer to these confusions but I though maybe someone here might have an explanation that might make more sense to me. I would also consider it quite possible that there is some prerequisite knowledge that I might not have (I mean I think I have a decent understanding of pointers and references) so if there is other stuff I should looking into, that would be great too.
    • By CountBram
      Hello I am looking for advice to what I should do next as I just completed the Unreal Developer Course on Udemy and now am at a lost as what to do farther as practice and to expand my knowledge. My background is 2 years studying college in Videogame Design and 3 years working on 4 years studying Software Engineering in college. I am mainly focusing on using my C++ knowledge with Unreal Engine to make indie games but I do also know Java, and C# as well, but I do not know Unity. I am welcoming any advice that can help with my current situation with my current skill set
    • By Andrea Richards
      If this is posted in the wrong forum or could use more tags, I apologise. This my first post.
      I am using ASSIMP to import FBX files for my system. Using Blender, I use Empties to create attachment points. Is there a way to get to these or detect these easily? The only way I can come up with is by going through the rootNode, and all of the child nodes, looking for names that match what I have entered. Which is quite cumbersome. Surely there has to be a better way of detecting an Empty ?
       
      Many thanks
       
      Andrea
       

    • By POKLU
      Hi there!
      I think this post may get slightly depressing, so, reader discretion is advised.
      I'm writing this to summarize what I did during my first game development process and hopefully someone will find it helpful.
      So, in 2016 I tried to make a futuristic racing game in Unity. It was just for fun and learning purpouses but I knew I want to try to put it on sale on Steam. I asked some of my friends if they would want to join me in the adventure. And this is probably the first thing not to do because if you ask anybody if they want to help you with creating and selling a game, they will say "sure, absolutely!" and then when you start to assign duties they never text you back again. And that's demotivating.
      Couple of months went by, and the game was more or less complete so I decided to put it on the thing that doesn't exist anymore, which is Steam Greenlight. I was extremely excited to see other people comment about my game (seriously it was super cool). My greenlight page wasn't the most popular one, but it was doing pretty good. Eventually the game passed, and was ready to be put in the store. This was truly amazing because it wasn't easy to pass the Greenlight voting.
      The game was kind of shitty as I look at it right now, but it was the best I could do back in 2016. It looked kind of like a 4/10 mobile game. Nevertheless people were interested in it since it was unique and there wasn't (and isn't) any games simmilar to it. I posted about it on some gaming forums and some Facebook groups, just to see what people would think about it. And every comment was always positive which made me super excited and happy. Eventually, my game went on sale.
      At the beginning my game was selling ok to me, but when I read other people's stories, I understood that my number of sales was below miserable.
      Back then Steam had something called 5 "Product Update Visibility Rounds" which means that when you update your game, you can use the "Visibility Round" and your game will somehow be very visible in the store. Essencially you get 500,000 views for one day. This used to dramatically (to me) increase sales, so I used 4 of them in like a week, which is exactly what you're not supposed to do. I left one round for later, because I knew that my game is not the best and I may want to remake it in the future, so the last round may be helpful to get some sales. After about 1,5 month the game was dead and it wasn't selling anymore. I was kind of disappointed but I was waiting to get my revenue.
      This is when I got my first big disappointment. On the Steam developer page, my revenue was about $1000 and when I got the payment, it turned out that half the people who bought my game had it refunded. So my total revenue (1,5 month) was around $600. So my game was completely dead. I abandoned it and moved on.
      About half a year later there was a Steam Summer Sale which I forgot I applied for and the game made $100. This was the point when I decided to refresh my game. I spent 6 months remaking it and when I was happy with the result, I uploaded it on Steam. I made a sweet trailer and everything and used the final "Visibility Round", expecting to revive my game and start the real indie dev life.
      Huge f*ing disappointment #2: As it turned out, Steam changed the "Visibility Round" and now it doesn't do anything because I didn't get 500,000 views in one day... I got 1,276 views in 29 days. 
      I started searching for a PR company. I messaged about 8 different companies and one contacted me back. I explained that my game is out already, but I recently updated it. The PR company was cool, very friendly and professional. Unfortunately a revenue share wasn't an option and they weren't cheap (for me). They understood that and not long after that, we made a deal. I won't get into the details, but everything went cool and my game was supposed to get some attention (press announcement). I even got a chance to put my game on the Windows Store, which again, was super exciting. Microsoft guys were extremely nice to work with so if any of you are planning to put your game on sale I strongly recommend considering Windows Store.
      For 4 months the PR company was instructing me on how to improve my game. It really was helpful, but come on, 4 months flew by. Although they were professional, suddenly we had a big misunderstanding. Somehow they didn't understand that my game is out already. Anyways, we were getting ready for the announcement and I had to make my website, which cost me some money. Also I had to buy a subscription for a multiplayer service for my game. (It uses Photon Network, I had to buy a subscription so more people could play online at the same time.)(Photon Network is great, strongly recommend it.)
      Disappointment #3: I bought a page promotion on Facebook. Estimated: 310,000 people interested, 40,000 clicks to my page. Reality: 0 people interested, 20 clicks to my page.
      The announcement happened.
      And nothing more. 80 Steam keys for my game went out for the press, 41 were used, 24 websites wrote about my game, 6 hateful comments, 2 positive, 17 more visits on my Steam page, 2 copies sold which doesn't matter because it's to little for Steam to send the payment.
      Estimated views of the press coverage: 694,000. Reality: probably less than 300.
      I don't give a f*ck at this point about my game which I have worked on for 10 months. I don't care about all the money I spent either. I don't blame anyone. I'm just not sure what not to do in the future. I guess the main lesson here is don't try to revive a game, just move on and computers suck at estimating things.
      Now I'm working on another game and I'm planning on making it free to play. I really enjoy making games, but it would be nice to have some feedback from the players.
      If any of you want to know something specific about my game or anything, feel free to ask.
      I expect nobody to see this post, so I'm probably going to paste it on some other forums.
      Cya.
      (sorry for the title being slightly clickbaiting)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!