Telliamed on 17/4/2017 at 04:19
(
https://github.com/whoopdedo/tnhscript/)
tnhScript is being rewritten in Squirrel. This time as GPL code to encourage reuse and modification. I've started with the most frequently used scripts:
TrapMoveRelative,
TrapFadeOut,
TrapCamAttach, and
TrapFreezePlayer.
I won't be rewriting all of the old scripts either because they're not needed (
DoorFrobInert can just use the "Block Frob" property.) or aren't possible with squirrel.osm (
TrackAttach uses hooks.)
A few observations on Squirrel scripts. The first question I had was, "why an OSM?" You're wrapping an interpreted API over a thin API wrapper of a few select engine features. I would have hoped that any new scripting interface would replace the existing and limited script services. Integrating the VM in the engine gives you better control of the script lifecycle, access to more advanced features such as property/link/etc change notification and creating custom messages. And of course it would be much faster. Putting it in an OSM I felt was a hack when I did it with Lua. (And even before that with Python.)
But I was curious to see how squirrel.osm solved problems I had already experienced. Most of the porting of scripts has gone smoothly. Just a few bumps related to getting up to speed with the Squirrel language. But as far as creating scripts and message handlers its all been uneventful. And the way it deals with non-standard names is interesting, though I think slightly unnecessary. (The language does allow you to create non-alphanumeric names. You just have to use [] instead of dot notation.)
I am experiencing frequent crashes. Specifically, if a script aborts on an error I need to exit Dromed or else the next time Squirrel tries to load it will hang.
The differences between Squirrel and my own modules was filled in using a few custom methods. In particular, the design note param accessors. Typing 'X in userparams() ? userparams().X : default' too many times necessitated that. I'd still like to see that use case implemented in the API. If not the full type conversion of my libraries, at least something like userparams(key,def=null) to retrieve a name if it exists or return a default fallback.
And I can't get DarkGame.FadeIn to work. I'm not sure if I'm not using it correctly, but it should set the screen black then gradually transition to normal, the opposite of 'FadeToBlack'. Am I missing something?
Yandros on 17/4/2017 at 10:49
\O/ Thank you, Tom. I wish I could be of some help with your questions.
Zontik on 18/4/2017 at 06:32
What about CommandControl?
ZylonBane on 18/4/2017 at 13:46
Quote Posted by Telliamed
But as far as creating scripts and message handlers it's all been uneventful.
Badum-tsh.
LarryG on 18/4/2017 at 14:15
Quote Posted by Telliamed
And I can't get DarkGame.FadeIn to work. I'm not sure if I'm not using it correctly, but it should set the screen black then gradually transition to normal, the opposite of 'FadeToBlack'. Am I missing something?
This is just a guess, but is it possible that DarkGame.FadeIn doesn't set the screen to black, but just fades to normal from wherever it starts?
Daraan on 18/4/2017 at 17:03
Quote Posted by LarryG
This is just a guess, but is it possible that DarkGame.FadeIn doesn't set the screen to black, but just fades to normal from wherever it starts?
Sadly no. I switched so many switches while beeing blind.
I wonder why it also wasn't documented in the script services from 1.24 but well the function exists..
R Soul on 18/4/2017 at 20:24
The HRESULT value is -2147467259, but I don't know if the value means anything, or whether we can only go by the documentation's statement that negative means "failure".
Telliamed on 18/4/2017 at 21:47
Quote Posted by Zontik
What about
CommandControl?
What about it? Still of limited use. Though it does show up twice in my FM survey. (The_Farm and Godbreaker). So I've added it, all 5 lines.
Oh, in case you were wondering, the top 10 custom scripts are
* NVRelayTrap
* NVPhantomTrap
* IntrinsicPlaque
* InvSchema
* NVMetaTrap
* NVItemGiver
* NVFrobToggle
* TrapRenderFlash
* TrapMetaProp
* TrapMoveRelative
Out of 87 FMs. Which sounds low. Did I missed a folder when scanning?
Quote Posted by R Soul
The HRESULT value is -2147467259, but I don't know if the value means anything, or whether we can only go by the documentation's statement that negative means "failure".
Or 0x80004005 which is E_FAIL. :(
But it isn't E_NOTIMPL which was what I almost expected.
Quote Posted by ZylonBane
Badum-tsh.
:eww:
Zontik on 19/4/2017 at 07:32
I meant, doesn't it use hooks?
Quote:
the top 10 custom scripts are
I'm surprised. Nobody uses
OnScreenText???
Yandros on 19/4/2017 at 12:24
I use it extensively for all the subtitles in DCE (which was begun before NewDark supported them). It is more flexible than NV's comparable script.