New script Language

Have an idea or great plots for Egoboo? Post them here!

Moderator: Developers

User avatar
bitnapper
Tome Mimic (Module Baker)
Tome Mimic (Module Baker)
Posts: 135
Joined: Fri Jan 30, 2009 3:33 pm
Location: Somewhere near the alps
Contact:

New script Language

Post by bitnapper »

The current script system is very outdated and clunky.

I have something more BASIC-like language in mind with more powerful conditional statements.
Example:

Code: Select all

// Show the character's location 
ShowBlipXY(DEF_SELFX,  DEF_SELFY, DEF_BLUE) 
//Follow the leader!
IF StateIs(STATE_SPAWNED) THEN
 	SetState(STATE_FOLLOW) 
END IF

IF StateIs(STATE_KILLED) THEN // This reduces the height of the char
    PlaySound(6) 	
    //Last words
    IF TargetIs(TARGET_ONSAMETEAM) THEN  // Fragged!
        SendMessage("Sir_%n_has_fallen...")
    ELSE IF TargetIs(TARGET_SELF) THEN  // No, just a damage tile
        SendMessage("%n_wasn't_very_careful.")
    END IF
    DropMoney(DEF_SELFMONEY)  // Drop money
    SetBumpHeight(45)
END IF // StateIs(STATE_KILLED)
Indention of Text doesn't matter because that is solved with the "END IF"-Statement.
The number of function names is highly reduced.
Messages can be written directly into the scripts so "messages.txt" is not needed anymore.
Two beer or not two beer... rather a malt whisky
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

I agree that a script system such as this would optimize and clean up the Egoboo scripting system. It would also add incredibly a lot more options and power to the scripter.

message.txt is also used by enchant.txt so enchant files should be updated to read strings directly instead of referring to message.txt as well.

It seems we would eliminate the need of tmpargument, tmpdistance and tmpturn as well. How would we do number comparisons?
(eg. IfXIsLessThanY ----> IF DEF_SELMONEY < 56 )

One thing: We would need to make a converter that updates all the old script to the new type. Who has time and effort to implement this? :P
User avatar
bitnapper
Tome Mimic (Module Baker)
Tome Mimic (Module Baker)
Posts: 135
Joined: Fri Jan 30, 2009 3:33 pm
Location: Somewhere near the alps
Contact:

Post by bitnapper »

It seems we would eliminate the need of tmpargument, tmpdistance and tmpturn as well.
Thats correct, the arguments are encoded with to the procedure/function call.
How would we do number comparisons?
(eg. IfXIsLessThanY ----> IF DEF_SELMONEY < 56 )

Code: Select all

IF CharHas(DEF_SELFMONEY) < 56 THEN
   DoStuff
END IF
Comparision functions for "IF"-Statements needed:
<, >, <=, >=, =, <>, AND, OR
Comparision values MAX 32765. Conditions can be concatenated by "AND" or "OR". For "Random" it could be a function call. There can be other functions which return TRUE or FALSE for comparison, too.
Who has time and effort to implement this?
I could deliver a code framework who has to be filled with all the codes to translate, which is in the first place a work ho needs diligence -- declaring a lot of strings and the functions it's translated to.
Two beer or not two beer... rather a malt whisky
User avatar
octagon
Darkshine Knight (Extremist fanatic)
Darkshine Knight (Extremist fanatic)
Posts: 2589
Joined: Sat Feb 20, 2010 1:07 pm

Post by octagon »

I agree. The tmparguments make everything painfully complicated.
My (sunken) netbook contained a suggestion similar to bitnapper's, and an example of how the Lumpkin's script would look in my syntax system - but I thought more of a c++ish syntax with functions and {} and stuff- C syntax is better overviewable and debuggable than the usage of written Thens and Ends.

You gotta take care, though. Never change a running system. Compatibility should be ensured.
I think I can't help you much. I admit I am quite a pseudo coder - my programming and scripting experiences limit to easier HTML stuff, c4script and ...TI Basic (shame on me :oops:).
User avatar
penguinflyer5234
Sheep (Developer)
Sheep (Developer)
Posts: 3025
Joined: Wed Jul 23, 2008 1:39 am
Location: Best Southwest

Post by penguinflyer5234 »

What was the point of Lua anyway? (birdy, I'm asking you)
...
bgbirdsey
{]-[0{0|307 (Developer)
{]-[0{0|307 (Developer)
Posts: 1864
Joined: Wed Jul 23, 2008 4:22 am
Location: Minnesota, USA

Post by bgbirdsey »

It is an embeddable and extensible language, unlike most available scripting languages.

There also exists a very good program which can make an interface between our code and the scripting language.

Making your own language is a recipe for disaster.
User avatar
Maxaxle
Darkshine Knight (Extremist fanatic)
Darkshine Knight (Extremist fanatic)
Posts: 4035
Joined: Fri Jul 25, 2008 8:16 pm
Location: San Diego, CA
Contact:

Post by Maxaxle »

Assuming Egoboo was moved to a more optimized script language, would it be less laggy? Less functions and if/and/else-type stuff = less processor usage = less lag?

Yeah, I don't really know what I'm talking about, but I'd rather just have my question answered.
"Failing to plan is planning to fail."
Bug me if you want to play a game.
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

Any "lag" issues Egoboo has is caused by either physics calculations or graphics rendering. Profiling has shown that the scripting system only is a small part of the slowdown process.
User avatar
Maxaxle
Darkshine Knight (Extremist fanatic)
Darkshine Knight (Extremist fanatic)
Posts: 4035
Joined: Fri Jul 25, 2008 8:16 pm
Location: San Diego, CA
Contact:

Post by Maxaxle »

Zefz wrote:Any "lag" issues Egoboo has is caused by either physics calculations or graphics rendering. Profiling has shown that the scripting system only is a small part of the slowdown process.
Great! :D
"Failing to plan is planning to fail."
Bug me if you want to play a game.
User avatar
bitnapper
Tome Mimic (Module Baker)
Tome Mimic (Module Baker)
Posts: 135
Joined: Fri Jan 30, 2009 3:33 pm
Location: Somewhere near the alps
Contact:

Post by bitnapper »

I'll add an example of the decoder binary to text to the SVN anyway. (It's one for binary Scripts from the 'Eye of Beholder I' RPG.

The decoder is simple, and the encoder should not be harder to code.

The hardest would be the translator from the existing script language to a new language. What ever it might be.
Two beer or not two beer... rather a malt whisky
User avatar
octagon
Darkshine Knight (Extremist fanatic)
Darkshine Knight (Extremist fanatic)
Posts: 2589
Joined: Sat Feb 20, 2010 1:07 pm

Post by octagon »

What about variables, too?
It would be great if you could for example save certain objects in variables (local or global), so you could access them in scripts...

MoveToObject(SporkChest);

or

var Bumper = WhoeverBumped;
User avatar
bitnapper
Tome Mimic (Module Baker)
Tome Mimic (Module Baker)
Posts: 135
Joined: Fri Jan 30, 2009 3:33 pm
Location: Somewhere near the alps
Contact:

Post by bitnapper »

The script language shold not become too complicated.

Goto an Object can be mimiced by a 'teleport' to the position of the object. If I remember correct, such objects are at a fixed position

It shouldn't be too hard to add the possibility to set variables.

I added the proposal with example files to the SVN. Please take a look at it.
Two beer or not two beer... rather a malt whisky
User avatar
octagon
Darkshine Knight (Extremist fanatic)
Darkshine Knight (Extremist fanatic)
Posts: 2589
Joined: Sat Feb 20, 2010 1:07 pm

Post by octagon »

That MoveToObject thing was supposed to be a command - I thought there was something called MoveToObject that i. e. makes a critter walk to another one or an item... My error.

It was just an example, though.

Thanks for putting it into the SVN, by the way...
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

Making your own language is a recipe for disaster.
What about birdsey comment? Care to explain why this is the case?
bgbirdsey
{]-[0{0|307 (Developer)
{]-[0{0|307 (Developer)
Posts: 1864
Joined: Wed Jul 23, 2008 4:22 am
Location: Minnesota, USA

Post by bgbirdsey »

The lure is that designing your own scripting language seems easier or cooler than embedding an existing language.

The problem is that existing scripting engines that are fully developed (Perl, Tcl, Python, Ruby, Java, Lua, visual basic scripting language, ...) have many thousands of man-hours in development and debugging.

I have worked on 3 projects where the major impediment to future development was the scripting language: POV-Ray, Egoboo, and SoulFu. At least the language in Egoboo is not buggy, though it is often difficult to figure out how to program a certain task. The SoulFu scripting engine was a nightmare, and the POV parser was junk and almost impossible to maintain.

It would literally take someone 10 hours to figure out how to use SWIG to embed any of its supported languages. I know I couldn't design a working scripting language in that amount of time.
Post Reply