Progress

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Diziet Sma wrote:
At least we is consistently inconsistent.. :lol:
Indeed!
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Ahruman wrote:
To better support strict mode, and to avoid buggy scripts carrying information across games, I intend t reload scripts whenever the game resets in 1.74 and forward. This means:
  • The reset() handler will no longer be called. Instead, a new instance of each script will be run, and startUp() called.
  • There will be no persistent timers.
Good to know (aargh), but the missionVariables are not accessible at this point. Will this change?
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I can’t guarantee that offhand.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Since someone didn’t see fit to include it in the release notes, I thought I’d bring this back from the archives:
Ahruman wrote:
*spins the wheel of unexpected new features*

And this week’s grand prize is… data-driven crosshairs. This means that crosshair shapes are now loaded from a config file. But that’s not all! They can also be overridden by any HUD plist by adding a crosshairs dictionary. But that’s not all! The size, thickness and colour of crosshairs can also be overridden by any HUD plist with the keys crosshair_scale (default: 32), crosshair_width (default: 1.5) and crosshair_color (default: greenColor) respectively. But that’s not all! Oh wait, yes it is. Except for the minor detail that crosshair width is now proportional to window size, just like everything else.

The format of the crosshairs.plist entry is simple: each entry is an array, whose elements are arrays of six numbers, each such array representing a line segment. The first three numbers are alpha, x and y for one end of the line segment, the other three numbers are alpha, x and y for (surprise!) the other end.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Svengali wrote:
Good to know (aargh), but the missionVariables are not accessible at this point. Will this change?
What do you mean with not accessible. In the past they were just nil for a Jameson, but could already be set by code. ups-courier initialises its variables on starUp() and they always changed and still do with the new way. And on reset() the variables from a saved game were already available. For ups it works both the old as the new way, without need to change the code.

My target reticle.oxp did not work anymore as in only read in the variable on reset() because it was stupid to read it on startUp() as you already knew it was nil than. Now I changed the code so startUp() calls reset() on startup and it works again. But that this fix works, also implies it already reads in missionVariables on the new startUp().
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Currently this.reset() is called when a save-game is loaded (or the game restarts due to a space-bar moment), but if you just start a game with the default new Jameson all you get is this.startUp(), and never this.reset().

So I think the question will be if this.reset() is removed, when the script first begins (and fires this.startUp) the saved game is not yet loaded (along with its stored missionVariable settings) so whether that will cause a problem or not to scripting and their setting/reading of missionVariables. We may need a this.saveGameLoaded or somesuch event, which is a little nonsensical as that is partially what this.reset is anyway.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Thargoid wrote:
....So I think the question will be ...the saved game is not yet loaded (along with its stored missionVariable settings).
What was unclear with the last sentence of my previous message? I thought I pretty explicit wrote the variables were read in at that point, just as before.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

So essentially this.startUp is actually going to become this.reset, with the addition that it is triggered at first game start as well (to cover new Jamesons where currently this.reset is not triggered)?

Seems a sensible economy to me as in most cases the workload is duplicated anyway (or one calls the other), just to get around this.reset not being called without a save-game load or a spacebar moment.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Thargoid wrote:
So essentially this.startUp is actually going to become this.reset, with the addition that it is triggered at first game start as well (to cover new Jamesons where currently this.reset is not triggered)?

No, they are fundamentally different. startUp() is called for newly loaded scripts, while reset() is called for existing script objects. In the old model, scripts were loaded once at startup and were responsible for completely resetting their state when reset() was called. In the new model, old script objects are thrown away and new ones are created.

From a scripting perspective this happens to occur at the same time reset() was called, but the script does not have to worry about resetting any of its properties that it might have altered before, for instance. (If your scripts for 1.73 and earlier aren’t doing this in reset(), they’re broken.)
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Then mine are certainly broken. :oops:

Praise the Ahruman for making them whole again with 1.74! :wink:
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Thanks Ahruman for clarifying this.

@Eric+Thargoid: Yes, I know about the behaviour (as you've already said, Eric) in v1.72+v1.73. The only question was if this behaviour changes for v1.74 and how this works now - but meanwhile I've tried Dizzies installer, so no question anymore .-) I've to tweak a few things now, but that's the risk of scripting with/for testversions. So wherever we are ending - it will be good (plus sensible economy, Thargoid).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Svengali wrote:
The only question was if this behaviour changes for v1.74 and how this works now - but meanwhile I've tried Dizzies installer, so no question anymore .-) I've to tweak a few things now, ....
As far as I looked through mine scripts and several others, I think none is affected by this change (with the exception of the reticle.oxp)
All scripts that were set up as:

Code: Select all

this.startUp = this.reset= function()
or

Code: Select all

this.startup = function()
{
  // one time stuff
  this.reset()
}

this.reset = function()
will work correct for both versions. And that are far the most of the scripts.
And Ahruman is right that there is a real risk not every scripter resets its own variables correct on reset. I already had an oxp that after reloading a new commander, used variables from the old commander.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Flasher memory consumption in 1.73.3: 324528 bytes.
Flasher memory consumption in trunk: 336 bytes.

Exhaust plume memory consumption in 1.73.3: 324528 bytes.
Exhaust plume memory consumption in trunk: 2028 bytes.

Every other entity type is also 12300 bytes smaller.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

That's a good one, Ahruman!

The flasher memory eater has been exterminated!

:D

L
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Ahruman wrote:
Flasher memory consumption in 1.73.3: 324528 bytes.
Flasher memory consumption in trunk: 336 bytes.

Exhaust plume memory consumption in 1.73.3: 324528 bytes.
Exhaust plume memory consumption in trunk: 2028 bytes.

Every other entity type is also 12300 bytes smaller.
Wow! That's a better trick than Derren Brown! How did ya do it?
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
Post Reply