RPG Dialogue Scripting
BlitzMax Forums/BlitzMax Programming/RPG Dialogue Scripting
| ||
As the title, I know there have been a few threads around on the topic.. I have them all tabbed in my browser. I have no problem reading and storing data from a file/xml/whatever and assigning them to a game object (sign/npc/etc) What I'm stuck on is the concept of scripting actions into the dialogue file and converting that in-game into code. Does that make sense? For example, how would I take a script function, like below, and make it call a blitz function with the appropriate values. Script: [moveCharacter:10,30] Blitz: MoveCharacter(destX:Int, destY:Int) I figure coding something like: If(fileLines[x].Contains("moveCharacter")) MoveCharacter(self, <values go here>) Not so hard. But probably the part I've has least experience with, is actually storing all these actions in a list of some sort so they're all called in the right order. You're help is much appreciated and I normally don't post for help unless I've tried everything I can think of. Last edited 2012 |
| ||
I think you should look into Lua scripting, or perhaps BriskVM, but that one isn't free and BlitzMax already comes with a Lua module (2 actually). If you choose to use Lua you can use the luigi module to automate writing the glue code for BlitzMax so you can interact with your BlitzMax types in Lua. |
| ||
I'm having a little bit of a brain wave but I'm going out for dinner so I'll post my results soon. I think I've figured out how to store the actions in a list that will play them out in order when I call DialogueBox.Run() |
| ||
You could also use Reflection I think, though that would seem a bit hackish I think. |
| ||
I would separate left and right side of each line. The right side i would devide in a paramter-array() symbolic code: Global Value%[9] Text$=ReadLine(...) LeftPart$=Left(Text,Instr(Text,":")-1) SeparateValues Mid(text,Instr(Text,":)+1,-1) Select LeftPart Case "moveCharacter" MoveCharacter Value[0], Value[1] Case "AnyThing" AnyThing Value[0], Value[1], Value[2], Value[3] ..... End Select Function SeparateValues(Text$) local From%, Upto%, i% From=1 For i=0 to 9 Upto=Instr(Text,",",From) If Upto=0 then Value[i]=mid(Text,From,-1) Return endif Value[i]=mid(Text,From,Upto-From) From=Upto+1 Next End Function |