RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
The birth of a scripting language
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
XMark
Guitar playin' black mage


Joined: 30 May 2002
Posts: 870
Location: New Westminster, BC, Canada

PostPosted: Tue Oct 15, 2002 6:42 pm    Post subject: The birth of a scripting language [quote]

first of all, I'd like to say this: STL kicks massive amounts of butt. I got all the NPC's and other entities in the map in a vector of objects and it was just so easy to do!

Ahem.

Anyway, onto the scripting language. Each object on the map has a name, and when the player activates the object (either by stepping on it or "talking" to it) it will find that object in the map's scripting file. Nothing new so far, but what I'm planning is to use STL vectors to store variables dynamically introduced in the scripting. There will be two vectors, one for the local variables (like whether a door is open) and one for global variables (like setting a flag when a major objective is complete). Local variables are erased whenever you change maps, while the global variables stay. Both get put into save game files. If a variable is undefined at an IF statement, then it is considered a zero value.

Here's a wee example of what it will generally look like:

Code:

WALKINGDUDE
{
  if TalkedToDude 0 {
   poptext (Hello there, \1! I am a scripted person!\n Listen to me talk!\n)
   int TalkedToDude 1
   endscript
  }
  if TalkedToDude 1 {
   poptext (Dude! I already talked to you!\n)
   TalkedToDude = 2
   endscript
  }
  if TalkedToDude 2 {
   poptext (You know, you're really starting to bug me.\n)
  }
}
BOSSDUDE
{
  if KilledPirate 0 {
   poptext (Arr! I be pirate Pete! Die, ye scurvy dogs!\n)
   startbattle PiratePete
   global KilledPirate 1
   endscript
  }
  if KilledPirate 1 {
   poptext (Arr! Ya beat me... I better get a new job. I always wanted to be a lumberjack.\n)
  }
}


I think I could pull something like that off without too much difficulty. I just need to figure out a way to break up a string into individual words seperate by spaces and carriage returns and then I'm off to the races!
_________________
Mark Hall
Abstract Productions
I PLAYS THE MUSIC THAT MAKES THE PEOPLES FALL DOWN!
Back to top  
Guest






PostPosted: Tue Oct 15, 2002 7:18 pm    Post subject: [quote]

How about having script variables. Mirc scripting and lord2 both have them. $string1 = (Henry The Eight)
Back to top  
mandrakestl
Guest





PostPosted: Tue Oct 15, 2002 7:20 pm    Post subject: [quote]

Quote:

string into individual words seperate by spaces and carriage returns and then I'm off to the races


one word: strstream (or stringstream in latest STL compliant compilers)

google it, and the world is yours.
Back to top  
white_door
Icemonkey


Joined: 30 May 2002
Posts: 243
Location: New Zealand

PostPosted: Fri Oct 18, 2002 8:13 pm    Post subject: [quote]

Another option is to use flex, its will allow you to create a C file that will read in a file and return a stream of seperate symbols it can even to advanced pattern matching so you can do stuff like ignoring whitespace or not, getting strings in as whole symbols (like everything between " and ") and ignoring everything after a // for comments.. whatever you want.

I think there might be a c++ version of flex too.. but I never was bothered to find out.
Back to top  
Moira
Super-Pretty Uber L33t Death Princess


Joined: 31 May 2002
Posts: 25
Location: PA, USA

PostPosted: Sat Oct 19, 2002 8:13 pm    Post subject: [quote]

yeah, flex rocks. There is (i think) a C++ wrapper for flex used in the flipcode article...or it might just be one for VC++, i forget. I know on Linux there is one.....could be portable.
_________________
"I like you. You have spunk, and moxy."
---
"He's got a box with a demon in it that draws pictures. Do what the madman says and he will give you gold."
Back to top  
Nexinarus_lazy_(Mr_Moose)
Guest





PostPosted: Sun Oct 20, 2002 9:07 pm    Post subject: heh all i do is... [quote]

I just make a simple script language like:

Code:

var, a
choice, a, Have i seen you?, Think so, Not that i know of, .
if, a, =, 2, no
    message, Oh i think i remember you
    end_script
no:
    message, Damn im sure i remember you..

but then again i dont use/know c++ much heh... awell.
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum