Page 2 of 2

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

Posted: 23 Oct 2017, 21:57
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).

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

Posted: 24 Oct 2017, 11:12
by Zini
Someone really doesn't like state machines. Early childhood trauma, maybe? ;)

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

Posted: 24 Oct 2017, 11:59
by sirherrbatka
Yes. State machines constantly screw me over :P

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

Posted: 24 Oct 2017, 19:49
by raevol
I'm taking an automata class right now, the trauma is real...

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

Posted: 24 Oct 2017, 19:59
by AnyOldName3
Event-based >>>>>> polling-based. This definitely needs to be a thing once we extend the scripting interface.

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

Posted: 24 Oct 2017, 23:44
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).

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

Posted: 25 Oct 2017, 00:45
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.

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

Posted: 25 Oct 2017, 01:05
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.

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

Posted: 25 Oct 2017, 03:01
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.

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

Posted: 25 Oct 2017, 09:31
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.