Script Tidy(is there any benefit in openmw)

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Script Tidy(is there any benefit in openmw)

Post by Chris »

Zini wrote: 23 Oct 2017, 19:08 We could. But what for?
To make scripting easier and more efficient at the same time. I still have nightmares when thinking about doing multi-choice message boxes in Morrowind's (and Oblivion's) scripting language. Like I said, you pretty much need to design a state machine in most scripts, when more often than not you just need to trigger some script code on specific events (like activating an object, changing cell, killing an enemy, etc).
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Script Tidy(is there any benefit in openmw)

Post by Zini »

Someone really doesn't like state machines. Early childhood trauma, maybe? ;)
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Script Tidy(is there any benefit in openmw)

Post by sirherrbatka »

Yes. State machines constantly screw me over :P
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: Script Tidy(is there any benefit in openmw)

Post by raevol »

I'm taking an automata class right now, the trauma is real...
User avatar
AnyOldName3
Posts: 2667
Joined: 26 Nov 2015, 03:25

Re: Script Tidy(is there any benefit in openmw)

Post by AnyOldName3 »

Event-based >>>>>> polling-based. This definitely needs to be a thing once we extend the scripting interface.
User avatar
Deltaxus
Posts: 39
Joined: 12 Aug 2017, 17:43

Re: Script Tidy(is there any benefit in openmw)

Post by Deltaxus »

Yes. State machines constantly screw me over :P
There is no better way to implement a lexer/parser than using a state machine. It all just comes down to manipulating strings on a tape. Almost all of computer science and mathematics can be formalized in this way (See Thue system/ Hilbert calculus).
User avatar
AnyOldName3
Posts: 2667
Joined: 26 Nov 2015, 03:25

Re: Script Tidy(is there any benefit in openmw)

Post by AnyOldName3 »

That doesn't necessarily mean that the programmer should be exposed to the state machine of it's going to be basically the same for every individual use. It's easier to generate it from a streamlined representation. In the case of lexers and parsers, there are parser generators that work really well and are easier to get right first time than creating the parser from scratch. Using events in Morrowind should be similar.
User avatar
Deltaxus
Posts: 39
Joined: 12 Aug 2017, 17:43

Re: Script Tidy(is there any benefit in openmw)

Post by Deltaxus »

The similarity in program design between programs I consider the greatest strength of automate based programming. It is at least (or strongly advised) to be able to go back to the basics at any given time. Indeed it's usually better to use a compiler-generator toolchain like flex and bison for lexer/parser (For example, The compiler for the Oblivion scripting language without code generation from ast only requires around 400 lines of lex code + 300 lines of yacc, I will post it soon), in order to properly optimize (if necessary) the output one still has to be able to quickly handle state machines. I simple love their simplicity and yet string connection to CS.
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Script Tidy(is there any benefit in openmw)

Post by Chris »

Deltaxus wrote: 25 Oct 2017, 01:05 The similarity in program design between programs I consider the greatest strength of automate based programming. It is at least (or strongly advised) to be able to go back to the basics at any given time.
The current way of running a script every frame isn't going away. There are still cases where it's useful, after all (not everything is best served with events). But if all you really need to do is wait for an event to do something, it's wasteful (both for the coder writing the scripts, and for performance) for the script to have to watch for the appropriate state change when the engine is already well aware of when the state change happens. Not to mention it's error-prone since each script is responsible for handling state changes properly, whereas the engine is necessarily well-tested at it.
User avatar
Deltaxus
Posts: 39
Joined: 12 Aug 2017, 17:43

Re: Script Tidy(is there any benefit in openmw)

Post by Deltaxus »

The current way of running a script every frame isn't going away. There are still cases where it's useful, after all (not everything is best served with events). But if all you really need to do is wait for an event to do something, it's wasteful (both for the coder writing the scripts, and for performance) for the script to have to watch for the appropriate state change when the engine is already well aware of when the state change happens. Not to mention it's error-prone since each script is responsible for handling state changes properly, whereas the engine is necessarily well-tested at it.
Yes and there is no trivial way to get rid of the always running scripts in Morrowind and Oblivion without breaking compatibility to vanilla assets.
I don't know which genius at Bethesda thought this was a proper approach.
Post Reply