Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scripting


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 aanthonyz1   Members   -  Reputation: 137

Like
0Likes
Like

Posted 01 January 2013 - 08:34 PM

I am having an issue with scripting. Im writing a Text Based RPG Game in C++ but I have a question about scripting. What would the best method be for writing out the story without directly writing every line in my C++ program?



Sponsor:

#2 Servant of the Lord   Crossbones+   -  Reputation: 19662

Like
1Likes
Like

Posted 01 January 2013 - 09:08 PM

By 'scripting' do mean mean the story script / NPC chat? Or do you mean a scripting language?

 

You can load data from files (which is very important). Use the data loaded from files to create the content of your game.

You can use scripting languages to even load logic from files, but for a text-based RPG that's probably not needed (unless that's what you're looking for).


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#3 Krohm   Crossbones+   -  Reputation: 3129

Like
0Likes
Like

Posted 02 January 2013 - 02:57 AM

My only experience with scripted RPGs was TES3: Morrowind.

It was a surprisingly painful experience as everything was essentially text-based and going through a rather buggish compiler/interpreter combo.

 

In general the part of the story I've looked at was just a set of if(...) switches based on conditional events.

There's of course a lot of advantages from not having those conditions in the engine code.

The higher amount of abstraction made it fairly easier to build complex entity relationships and I liked the idea of having a single scripting language to do everything from story to entity scripting.

 

Years ago I collaborated with a friend of mine in writing a text-based single-player MUD (it was supposed to be a real MUD someday).

The story was similarly based, with conditions to be set to true to evolve the world from a state to the other. It never satisfied me, but the whole thing was a akin to a quick hack rather than something serious so it was ok.

 

Looking back, I'd try to model a state machine using an appropriate language for story while dialogue and entity scripting would probably use yet another system.



#4 RobMaddison   Members   -  Reputation: 708

Like
0Likes
Like

Posted 02 January 2013 - 09:22 AM

Similar to Krohm, I've written single and multi-player text MUDs (multi-user-dungeons), in both java and c++ and was heavily involved in working on our implementation of an lpmud at Plymouth University more years ago than I can remember.

I would recommend doing a google for 'lpmud', you can still download the drivers for it and get it up and running fairly painlessly on both Linux and windows.

The general idea behind it was that it was an extended version of C that added object orientation. It's main core was an interpreter which read files in this hybrid of C and 'LPC' (named after its creator Lara Pensj, sp??) and turned them into game objects with specialised and generic functionality.

If you do google it, you will no doubt find example files showing you how it looks and it will give you lots of ideas. Unless you want to use someone else's MUD engine, you may need to either write your own interpreter (gets pretty complicated but very addictive) or look at using an existing scripting engine (Lua?). I don't have any experience with Lua but I believe you might be able to put something together using that, c++ and some form of data modelling (XML?).

It's a really interesting and unfortunately somewhat-forgotten genre and one that holds many great memories for me so if you need any further help, don't hesitate to ask, it's great to hear people still wanting to investigate it.

Good luck

#5 simast   Members   -  Reputation: 119

Like
0Likes
Like

Posted 02 January 2013 - 12:05 PM

I have just finished embedding Google v8 JavaScript engine in my game. The API is simple and flexible and quite easy (once you get past the basic concepts, such as contexts and Local/Persistent handles). The point is that JSON is a subset of JavaScript so you can employ the same v8 engine for data description (JSON) and scripting (JavaScript).

 

Writing your own scripting language and interpreter in the year of 2013 is just silly. You would be surprised how complicated modern-day scripting virtual machines are. For example, v8 does not interpret anything - it compiles the script directly to machine code. Furthermore, it patches the code on-the-fly optimizing it even further. Theoretically your v8 JavaScript code can run faster than C++.



#6 BCullis   Crossbones+   -  Reputation: 1813

Like
0Likes
Like

Posted 02 January 2013 - 02:15 PM

You can load data from files (which is very important). Use the data loaded from files to create the content of your game.

I'm just going to restate this one for simplicity, given that some responses are getting into much more complex territory.  I apologize if this is missing the mark, but your post sounds fairly new to game programming, given that you're dealing with a C++-based text-based game.  You'd be best-served in that instance just writing your various text data to text files, and having your code read from those files to get the text you want in-console.  Look for a tutorial or resource on file I/O in C++ and that should get you most of the way there.


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#7 Khatharr   Crossbones+   -  Reputation: 3006

Like
0Likes
Like

Posted 02 January 2013 - 03:51 PM

The general idea behind it was that it was an extended version of C that added object orientation. It's main core was an interpreter which read files in this hybrid of C and 'LPC' (named after its creator Lara Pensj, sp??) and turned them into game objects with specialised and generic functionality.

Lars Pensjo. He's an active community member here and he's awesome. biggrin.png

Edited by Khatharr, 02 January 2013 - 03:52 PM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS