Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / New Script System - Very Helpful

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Dec 2006 20:48 Edited at: 4th Dec 2006 20:56
My last script system didn't seem to get much of a response, and though I thought it was useful at first, I remembered that it could only work with one script at a time. Well, I started completely from scratch, and this one can support multiple scripts, and also data statements.


A little talk:
We're all going to have to face it. We all want to make the most awesome game in the world, and while it's in our heads, we want to do it quick. The fact of the matter is, that we can't just sit dwn and do it. It takes alot of planning, determination, experience, and, what I think is most important, organisation and structure. Part of that comes into play when loading data.
When I started, I started off just making/loading objects and placing them through DBPro.Then reality hit me when I started X-Ball. I didn't get very far with that game, but the reason I even got that far was because I had external data, and it wasn't all one annoying lump of ugly code. And yet, it was still untidy, because I had countless files for small things, and they all had a different layout, which made it hard to read data for each seperate type of file, which, in turn, made my program untidy and unmanagable. I went on like that for a while because I could work out how to do anything about it. I didn't know how to add objects and remove them whenever I wanted. (I'll tell you, DBPro's text commands may seem pretty useless, but even with the few that are provided, and the magic of functions, you can recreate any command you like)

I came up with my MapScript library too, which was half-way descent. The reason it was, was because the files didn't have one certain layed out structure, and by that, I don't mean they were unstructured. What I mean, is that with old data files, say for a level loading thing, the object directory would come at line 1, it's texture at like 2, etc... With MapScript, I came up with a way to check if a command was there, and if it was, read it's contents. The thing that made things most helpful to me, was that I couldadd an infinite amount of objects into the game, without having to change any script reading code. This was my big break, and I still use my MapScript because of that very reason.

So, now, I have finally developed a system, that is useful for almost anything, games, applications, or anything. I could use it to make my own programming language, really. I could use it to load levels. I could use it to load in objects. Basically store any data I like, and because the data you make doesn't mean anything until you tell it to, it can be as flexible as you want.

So, here is a small example of a script file that stores data about two of my guitars.


The command is guitar. That isn't any sort of command, but with the functions provided you can easily check what each and every command is called. The parameter for the guitar command is the type, which I have chosen to be "Electric" or "Acoustic". These dont mean anything either, but they can easily be checked to see what they are. You of course don't have to have only one parameter, you can have as many as you wish.
Then, there is a long data list about each guitar. Yes, that can all be read too, every one seperatelly. I can't personally think of anything I could achieve from this particular example, but it was a good example to show off what it's functions are.

The code can also be written like this:


or like this:


like this:


Or infact, even like this:


But umm.. yeah, that's silly


So now I have proven to you what it's capable of, here are the functions for DBPro.

If you have any trouble understanding them, just ask.

So now I have perfect external data storage for my stuff, and I can load levels, enemy positions, weapon positions, display modes, or anything, really easy.

P.S. I also intend to make some script writing functions. If anyone has any ideas for script writing/reading functions, just tell me.


P.P.S. It's my birthday today. It would be wrong of you not to comment on my awesome 2 days worth of work

[edit]
Someone bin the old post please? It's just a wasteof space apparently anyway

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Dec 2006 20:57
I like the concept of it.
I understand the structure of your data storage. But could you please specify the output of it? Does it save the words to an array? If yes, what array is it (zsScript seems to store only the number of words)?

And... of course... HAPPY BIRTHDAY!!!

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Dec 2006 21:05 Edited at: 4th Dec 2006 21:06
zsScript actually only stores the whole code in 1 big, long line, which makes it easier to split it up into it's components. That's the reason for the semi-colons ( ; ) and why the code can be split up any way.

My last script saved it all to an array, but I decided to try something a little different this time. Instead of storing everything into one array at once, then retrieving the data using functions like getCommand() etc, I made it so it did that particular action when you called that function. So, there isn't any output unless you want there to be, i.e.


Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Dec 2006 21:56
How about an example demonstrating all of its capabilities?

Looks cool. Nice job. Happy birthday.

-Mansoor Siddiquie

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 4th Dec 2006 23:12
uber nice work now all you need is a make me a mmorpg script uber , 500 billion players , 60 billion levels , 10000000000000000000000000000000000000 ping and a max player of -1 then every n00b can make there cruddy mmorpgs in seconds

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Dec 2006 23:13
Yeah.... it doesn't have commands lol. If you want to make a command to make that game, be my guest lol.

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 4th Dec 2006 23:19 Edited at: 4th Dec 2006 23:20
ok here i wrote it in the first 50 after isaw your reply




see ? enjoy

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Dec 2006 23:23 Edited at: 4th Dec 2006 23:26
It doesn't work like that, lol. Read the freakin' thread.

[edit]
Xeno. Good idea! Might give Chris a little more understanding of it

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 4th Dec 2006 23:26
Fine here



anyway back on topic

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Dec 2006 23:44 Edited at: 4th Dec 2006 23:48
Ok. Here's a basic example. I really don't know why I added parameters and data columns. They're exactly the same thing . Oh well, I guess you can split up different types of data.

DBPro code:



Script:


Oops, forgot to put the ability for remarking. Better do it now.

[edit]
And variables

General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 5th Dec 2006 10:32
Looks good, but i wont be using it as i have my own scripting system.
Anyway good coding!

Beware, Killing chavs is not a crime, but is the only way to cure the earth
Vist www.scratchyrice-dev.co.uk
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 5th Dec 2006 20:54
Thanks mate

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Dec 2006 23:03
Updated:

Now supposed better data managements, and basic variables.

So far what you can do with variables is:
Return a command number from a command, which can be used as a parameter in other commands.
Make a variable from a data structure using the dim command.

The data management has been updated, and you no longer call data by number, but by name, so you would write it like this:



...and retrieved like this:


Here's how you would return a command number, and how to use it in the script:


The parameter inside doSomething would be equal to 1. If you made another command under the first one, and called it something else, like HelloWorld then HelloWorld would be equal to 2.
The command number can be got from DBPro too, using the function:


The other type of variable useage is like this:


What happens here is:
I create a command, and put two pieces of data in, name, and age. I also returned the command number for quick reference.

I then used the dim command, and put in which command I'm refering to (I could also use a number if I wanted). Then in it's data column, I created the variable name, and then the data name from the command number used.

I then used the variable, in the setName command.

I intent to make it if the command refered to in the dim command is 0, you will be able to set your own values without refering to an array.


Here's a basic example of how to use all these changed. A really crappy example at that.



And ofcourse, the undated functions + plus some extras like string functions that I use in it. After I've got a little further with this I'll release some info on how to use the functions.



Comments or Critics? Maybe some ideas too? Reply with whatever you have

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 14th Dec 2006 23:11
Cool

Maybe make the part where you get command data a bit shorter?

-Mansoor Siddiquie

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Dec 2006 23:13 Edited at: 14th Dec 2006 23:15
You can lol, instead of this


Just do this





[edit]
Or do you mean the DBPro function?

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 15th Dec 2006 00:10
I mean the DBPro function

string$=GCD(ScriptNo,CommandNo,"bleh"/"lol")

would be a bit more convenient

-Mansoor Siddiquie

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Dec 2006 11:15
Search/Replace often does the trick Xenoscythe

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Dec 2006 21:39
That's true, I'll keep it as it is for now, just so people know what it actually is, heh

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Dec 2006 22:00
Yesterday I found some bugs in my variable code, which gave me the chance to re-write how they work. Now they're a bit more UDT like.

Here's some random code:


Notice the variables in randomCommand are like per.namea, and per.nameb, where per is the return from the person command, and namea and nameb are it's data. Hahah, it's turning out pretty good now

Updated functions:


ConorH
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location:
Posted: 20th Dec 2006 19:09
Like the work Zoto

I made one for my own projects, that uses more BASIC like syntax, and requires the user to input his/her own commands (other than basic if/then, variable) in the source.

Learning C++ over christmas myself, and whilst Im still coming to
terms with the seemingly complex syntax, I wonder if your system could use a simpler style?

Just a suggestion, from a comparative novice

its my new rat tail dog!
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 21st Dec 2006 03:37
Haha, I guess I could, but I didn't makwe it look like that just for fun, heh. The reason it has that sort of syntax is because:
1 - I had to use the ; to split up all the commands, which is essential. Wouldn't need it if it was 1 command per line, but, that's not the case, heh.

2 - Since I wanted both parameters and command data, I had to use seperate symbols for them, brackets for parameters () and braces for data {}

3 - The syntax for this or C++ isn't that complicated at all I think when you see C++ you see all the {}s and things, and find it much different to what you're used to (DB I'm guessing), but, once you start to learn it, you'll find it's very structured and stable feeling

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 23rd Dec 2006 04:30
Its a pretty good idea, I think Ive seen it dont before in various ways but not with DBP.

Really if you took the time, you could rewrite all of the DBP commands internally and have it allow you to write DBP programs with simple text files.

Pretty sure thatd be illegal, so dont do it kids .

Sunflash
19
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 30th Dec 2006 06:43
You wouldn't need to rewrite the commands. Simply read a line from the file, then match it up with the proper DBPro command, and then execute the function, passing all the parameters mentioned in the txt file

"I must tell the Queen that a robin has seen Cludd hanging about. No, thats not right. I must tell the robin that Cludd has been hanging the Queen..." -Mossflower.
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 30th Dec 2006 07:41 Edited at: 30th Dec 2006 07:51
Save yourself alot of hassel and get Unity LUA for DBP

http://darkbasicpro.thegamecreators.com/?f=lua

As used by the pros..

Blizzard - Warcraft III
Bioware - Baldur's Gate
Lucasarts - Grim Fandango
Crytek - Far Cry
Sierra - Homeworld 2
Electronic Arts - Various Projects

It can save text files like


and accessed in DBP with something like



You can also use it for monster AI files as you can take executable code outside the compiled.exe!!!


Here is an example of how u call file code in DBP

REM LOAD FILE
r=load lua("Amazon.lua")

REM CALL THE FUNCTION
lua set function "moveAmazon",3,1

REM PUSH DATA TO THE FUNCTION
lua push int 1
lua push int timer()
lua push float Get_Camera_Distance(1)

REM GET DATA BACK
Damage = lua return int()

REM VERY EASY TO STORE AND READ STRINGS
enemyName$ = lua get string("monsterName")



Here is an example of some monster AI i have in an amazon.lua text file

oldTimer = 0
function moveAmazon (objnum,timer,dist)

monsterName = "Amazon"
attackDistance = 3
moveSpeed = 0.2
attackStrength = 10
-- 1000 = 1 second
attackTimer = 2*1000

-- Get the position of the camera
cx,cy,cz = CamInfo()

-- Keep the Amazon on the floor
cy = 0

-- Move the Amazon if she is not yet at the camera
if dist > attackDistance then
PointObject(objnum,cx,cy,cz)
MoveObject(objnum,moveSpeed)
else
-- Do an attack if we are at the camera position and the timer allows it
if timer > (oldTimer + attackTimer) then
oldTimer = timer
return attackStrength,monsterName
else
return 0,monsterName
end
end
end

http://www.KumKie.com http://bulldog.servegame.com
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 30th Dec 2006 09:53
all i hear from gatorhex is get unity lua... anyway what I was going to say is

You could make a small tutorial for it so people can understand what it does. I just look and go ok its setting variables but what the hell for?

it would help a lot if you could do that

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Dec 2006 15:54
Kieran, sure thing, I'll hook something up in a minute


GatorHex, Unity may be a really good product, but I don't buy things off the internet, and this is my alternative, for myself and others. Please don't advertise other products to belittle my own work.



Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Dec 2006 17:02
Scripting System - Basic Tutorial
---------------------------------

This scripting system is very flexible, and can be used for practically anything you like. What is does basically, is give the the ability to read external data into DBPro. The

data could be anything, it could be data to store what your level should look like, it might be a set of commands you might want to execute at a certain time (though it is not a

programming language in itself, something similar could be made).

For example, say you were building a text based game, and you got to a certain spot, you might want it to print to the screen "Well Done!", this is easily done, for example,

your script could look like this:


Maybe you might want it to center text to the center of the screen, with big red letters...


This 'print' command isn't an actual command, but you can check your script for it, and make it a command of your own.
You will notice after the last brace } and before the semi-colon ; , there is a variable. This is the command return, which should be unique to all commands. It's good because

you may have lots of similar commands, but one of them has to special, for example, there may be lots of commands to make spheres, but one of them you might want to be a sky

sphere, you could check all the commands will you find "skySph" as the return.

You will notice on both examples I put a semi-colon ; at the end of the commands. These are needed so the commands can be recignised as seperate commands.

You will also notice on the first example I used parameters, and on the second one I used some form of data statements. The difference is not big, but it is much easier to work

with data statements, but parameters are quicker. The parameters are numbers, so you have to retrieve them by the number they are, i.e.
"makeCube(1,100,200,300)"
Parameter 3 would be "200".

With data statements, you call them by name, so it doesn't matter if you take one out, you'll still get the one you called.
Parameters always come first, and are between brackets (), you don't need data statements, but if you do, you have to use braces {}.
All parameters have to be split up using commas, and so do data statements, even if they are arranged in vertical order.


Using it in DBPro

Well first you have to actually copy and paste the functions into your project, or an include file (I will give you the updated functions at the bottom).
Then you have to call "startScript()", that basically sets up all the arrays and stuff.

To read a script is very easy.

You call "readScript()", the parameter for this is the file name you want to read. It returns the script number. Since this can support multiple scripts, it will return the

number of the script. You refer to the script you want to get data from by using that variable.

Without giving a long boring explanation, here are the usefull functions there are:
- startScript() - Call once at the start of your project
- readScript(file$) - Returns the script number. Enter the filename you want to read.
- getCommandCount(script) - Returns the number of commands in a file. Enter the script number as a parameter.
- checkCommandCount(script,command$) - Returns the number of commands in a script that matches command$
- checkCommand(script, command number, command$) - Will check is a certain command is what you passed in (not case sensitive)
- getCommandLine(script, command) - Gets the whole command (including parameters and data)
- getCommand(script, command) - Returns just the command
- getCommandReturn(script, command) - Look above to see what the command return is.
- checkCommandReturn(script, ret$) - Will return the command number that returns the ret$ variable.
- getParameterCount(script, command) - Returns how many parameters a command has.
- getParameterType(script, command, parameter num) - Returns 2 if it's a string, otherwise returns 1.
- getParameter(script, command, parameter num) - Returns the value of a paramater, this will always be a string, even if in the script it's a number. Using val() you an get a

number.
- getCommandDataCount(script, command) - Returns how many data things there are in a command.
- getCommandData(script, command, data$) - Returns the value that somes after the = sign in a data statement. I.e. name="Zotoaster", if yu search for "name" it will return

"Zotoaster".
- getCommandDataNum(script, command, number) - Returns the command data, but this is called by number.
There's more, I have to first explain how the variables work on this


Variables - Not quite what you think
Variables in this are not like in DBPro, and there's no maths parser, so you can't use them exactly the same way.
Variables are actually just the data statements, but can be called by other data statements too.
For example, I declare the screen width and height:


You first need a return value. You can then refer to the screen width and height in other command data, for example, to draw a line across the screen,


Do you see how that works? It's the return, a dot, and then the data you wish to use.

More Commands
- getVariable(script, var$) - Just like command data, but you need the return, and the dot. So this will scan all commands.
- getVariableCount(script) - Returns the amount all command data in the whole script
- getVariableNum(script, num) - Return the numbered variable - not very useful I must say
- getVariableVal(script, num) - Just like the above, but returns the actual value - still not too useful.
These commands are very pointless in DBPro, but I made them to make it easier to program the variables into the system. I don't see much use for these.

There are also other commands, but they aren't really needed.


Syntax
The way you can code in this is very flexible, and each command can be spead over as many lines as you like, so long as you have the semi-color at the end, then it's fine.

This is an example of making a box for example.


You could also do it like this:


Or like this:


As I said, it's very flexible.

One thing that you can't miss out is remarks Since this looks already very C#/C++-ish, I just made it so you can do remarks using two forward-slashes //Hello.


Examples

Here's a good example of a simple level I was making for my new game, 'Bad-Ball'.


The way to actually parse that is easy, I started by looping through all the commands, checking for a command, if found, get it's parameters and data, e.g.


It's relativelly simple to use.


Notes
Yep. It may sound like learning another language, but it would be your own language after all. I not dont have hundreds of commands for one level anymore, and to add another

level doesn't require any more commands in DBPro, and they are easy to change. I also use it to set sync rates, screen dimentions, and it keeps my project organised.

Here are the updates functions:


You will see all the string and file functions underneath. The system relies on these, so they have to be here. You can use them too if you like


Happy coding

GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 30th Dec 2006 19:38 Edited at: 30th Dec 2006 21:11
Quote: "GatorHex, Unity may be a really good product, but I don't buy things off the internet, and this is my alternative, for myself and others. Please don't advertise other products to belittle my own work.
"


The LUA system is free. It's an industry standard C++ module/download.
Unity for DBP is an official wrapper to it sold by TGC.

I'm not trying to belittle your work, in fact I recommend your thread to Kieran who didn't want to spend another £12.

I was in the same place once, writing a script system, but i took the view, "why re-invent the wheel when the wheel only costs £12" my time in hours spent reinvienting it would cost more. I wasted 2 days on it which I caluculated cost £100 of my time, then I thought "sod it, spend the extra £12!", hehehe.

Peace man

http://www.KumKie.com http://bulldog.servegame.com
ConorH
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location:
Posted: 30th Dec 2006 20:25
@GatorHex
Zoto's system may not be as functional or robust as Lua, which is only £12, but its not only a great way to learn, its also fun. I remember when I made a half decent script system, around the same time as Torey 's Darkscript and Unity were kicking about for the first time. Even though there were superior alternatives, I still wanted to make my own because I'd never done it before. I speak for myself though, and Zoto may have made his for different reasons, but Im sure he was aware of Unity when he began (its on the TGC Main page after all )

its my new rat tail dog!
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 31st Dec 2006 20:18
Wow you have done some work! Ok I got the function in my project.
I am calling startScript() at the top. I made a txt file called test. Then I call readScript(file$). I get an error file does not exist. I know I missed something or I dont know how it works yet
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 31st Dec 2006 20:22
Is file$ in the same directory as your game? If it is and it still gives the error try doing 'set dir$' and setting the current directory to your game directory. If it still doesn't work, tell me

dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 31st Dec 2006 20:34


It still says file dont exist when I change the dir so I changed it back
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 31st Dec 2006 20:39
lol You replace file$ with the file you want to read lol

like:


dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 31st Dec 2006 20:44
Ok I did try that It just showed the blank screen. In test.txt
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 31st Dec 2006 20:58
As I said before, print isn't actually a command. There aren't any command at all, you have to create them, and that's basically what the functions are for

For example, to make commands, you would do this:


dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 31st Dec 2006 21:42 Edited at: 31st Dec 2006 21:46
Ok I see in DBPro


in the script file




so what is going on is we are checking checkCommand to get the file and in that if there is a command that was reference from DBPro then make a varible and use getParameter to store info from each element each element is seperated by a comma, that last number in getParameter is the element. This is great this is what I need. Thanks for saving me some money. I was going to buy unity Tuesday
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 31st Dec 2006 21:50 Edited at: 31st Dec 2006 21:53
Unity is much more functional, if it wasn't he would just give it away for free. I dont buy things from the net, so I just make my own. This seems to work fine for me, I haven't had any need to unity (though it probably could make anything easier).

[edit]
Glad you find mine useful though

dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 31st Dec 2006 22:08
For my gun the script could be like


In DBPro



CreateGun() function is a function with a bunch of variables and those variable get populated with the script above, so yeah I can see the use of this
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 31st Dec 2006 22:10
It's good to see you find this usefull

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Jan 2007 00:07 Edited at: 4th Jan 2007 00:10
I'm in the process of making a new better script system. This one enables you to put commands withing other commands (I am so far behind lol), so it will enable you to make functions, and have multiple scripts inside one big script. For example, having two maps:



As you can see, I'm going to have a sort of OO type of thing going. Don't know yet how it's going to turn out, but we'll have to see

So far the way to call each command is just doing:

command$=parseCode(scriptNo,"map1>trees"), so command$ would return "tree1.Position(x,y,z); tree2.Position(x,y,z);"

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Jan 2007 15:23
And here is a small snippet of what it would look like now.



The way the code is set out makes it easy to execute only sections of it. I.e., if I wanted to execute all of it, I would do:
executeScript(checkData(script$,"maps"))

If I only wanted to execute the first map, I would do:
executeScript(checkData(script$,"maps>map1"))

If I only wanted the bushed from the second map:
executeScript(checkData(script$,"maps>map2>bushes"))

As you can see there's a sort of OO feel to some of it. You can't make classes, but there's one built in at the moment called 'object'. This gives it some descent mapping capabilities. So for example I could do:


Position was the only function I got to put in, but seeing I did everything yesterday, I think I made descent progress

It can also have variables. Unlike the last one, these are real, haha.
For example, if I wanted a variable to be printed (no actual print command, it's a scripting engine, you can make it print if you like):


It doesn't have maths marser or anything of the sort, you you couldn't do:
print 3+4;
or
print var1$+" - lol";
Which is unfortunate, but not terribly needed.

Anyway, time to add more classes and functions!

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th Jan 2007 07:05
I re-wrote it today because of how slow it was to load, and it's been improved.

I decided to forget about variables and stuff and concentrate on some more important stuff. For example, after much trying, I have finally worked out if statements. They can't yet use variables, infact they can only use numbers. I have also made functions, which work pretty well, thought for some reason one function can't call another. I don't know why, I'll have to work on that.

Here's a basic example:


As you can see, you call the function inside 'main' (doesn't have to be called that). The actual function declaration has to not be within another block (a part encapsulated in {braces} ).

You can see the 'if(10-9=1)' part. There are a few things about this. First, the condition has to be in brackets, which I prefer anyway. There are only numbers working so far on this, not variables or strings. You can see it has a basic maths parser (can't do brackets yet), so you could just do 'if(1=1)'. You don't actually have to do the if statement at all, it was just for show, heh.

There are 4 operators for if statements. Even though this has a C-Style syntax, the operators are different. First of all, the equals one doesn't look like '=='. Also, the 'not equal to' operator isn't like '!=', it's actually a little siggle '~'. (My tokenizer can only check for one letter, heh).


So that's it so far. What I have to do yet is fix the ifs more, to make them use strings and variables. So I'm going to have to make variables, and parameter passing too (which I'm not sure is going to be so easy... at all).

I was hoping after that I could work on maybe making some structs or classes, but because DBPro cant have an array within a type, it would be very challenging. Maybe too challenging for me.

Anyway, I'll post the DBPro code once I'm more ahead.

Kohaku
20
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 6th Jan 2007 10:51
Keep it up Zotoaster! That's some nice scriptage.


You are not alone.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Jan 2007 20:22
I restarted... again.. Ifs and functions started to get buggy, and I stupidly decided to make variables after everything else, and everything just got very out of hand, especially since I couldn't have an array of variables, seeing I already had an array of scripts. If DBPro could have arrays within types this wouldn't have been a problem, but unfortunatelly that's not the case.

I have remade it, and as far as I'm concerned it's as good as it's going to get. I don't really need much more capabilities, but if I ever find I do i'll try to improve it.

It is possible to make your own "compilers" for the scripts. I have already started on one for game maps. Here's what a level looks like in the script:

...and it's fast too. That's about as good as I need it at the moment.

Here are the DBPro functions:


Which include the core string functions, which I have developed over time and make the scripting possible, and one file function, that gets the number of lines in a file.

Here is a small example of how you can make a 'compiler'. This is the mapping functions:


With that, you just do 'loadMap(map$)' and it loads the map completelly. Ahh, the beauty of scripting... (I am never going to find a girl, am I? )

Enjoy

Login to post a reply

Server time is: 2024-11-23 22:01:39
Your offset time is: 2024-11-23 22:01:39