Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Save script putting data in wrong button  (Read 2870 times)

0 Members and 1 Guest are viewing this topic.

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Save script putting data in wrong button
« on: August 24, 2008, 04:00:24 PM »

Hi all

For out 'save' window, I've used Mnemonic's new save script - the one that stacks the savegames oldest first - and shaped the window pretty much the same, except to add a static to display the date the save was made.

To my now weary eyes, it looks as though Mnemonic's save window script and mine are functionally identical - yet Mnemonic's script puts <<new saved game>> in Button 1, and on mine it somehow invents the notion of putting it in button 2.

I've taken these scripts apart, modelled them in Excel and on paper and I just cannot see where it's getting the idea to set the 'SlotButton' reference to '2' instead of '1'.

Mnemonic's script says this and puts the text in button 1:
Code: [Select]
  for(var i=0; i<NumSlotButtons; i=i+1)
  {
    var SaveSlot = LastUsedSlot - ScrollOffset - i;
    var SlotButton = this.GetControl(i+1);

    SlotButton.Pressed = (SaveSlot==(LastUsedSlot-SelectedSlot));
    if(SaveSlot >= 0)
{
  SlotButton.Disabled = false;
  if(Game.IsSaveSlotUsed(SaveSlot))
        SlotButton.Text = Game.GetSaveSlotDescription(SaveSlot);
      else
        SlotButton.Text = "<new saved game>";
}
else
{
  SlotButton.Disabled = true;
  SlotButton.Text = "";
}
  }

  var SelSlot = LastUsedSlot - SelectedSlot;
  if(Game.IsSaveSlotUsed(SelSlot)) Thumbnail.SetImage("savegame:" + SelSlot);
  else Thumbnail.SetImage(null);
}

Whereas mine says this and puts the text in button 2
Code: [Select]
  for(var i=0; i<NumSlotButtons; i=i+1)
    {
    var SaveSlot = LastUsedSlot - ScrollOffset - i;
    var SlotButton = this.GetControl(i + 1);
    SlotButton.Pressed = (SaveSlot==(LastUsedSlot-SelectedSlot));
    if(SaveSlot >= 0)
  {
  SlotButton.Disabled = false;
  if(Game.IsSaveSlotUsed(SaveSlot))
    {
    // date manipulation code
        var SlotDate;
    var q = Game.GetSaveSlotDescription(SaveSlot);
    var StringSplit = new String(q);
    var l = StringSplit.Length;
var ix = i+1;
SlotDate[ix] = StringSplit.Substr(0, 16);
SlotButton.Text = StringSplit.Substr(16, l-16);
}
  else
    {
        SlotButton.Text = "<new saved game>";
}
  }
else
  {
  SlotButton.Disabled = true;
  SlotButton.Text = "";
  }
}


There are no saved games to worry about BTW.

If I've done somethong stupid, feel free to tell me in your own words. I can take it.  :-[   
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Save script putting data in wrong button
« Reply #1 on: August 25, 2008, 01:47:12 AM »

Of course it's wrong...

Code: WME Script
  1. else
  2. {
  3.         SlotButton.Text = "<new saved game>";
  4. }
  5.  

in your case belongs to wrong block. In Mnemonic's case it's correctly if (SaveSlot >=0) while in yours it's if(Game.IsSaveSlotUsed(SaveSlot))
This way the else block never executes the first time around.


Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Save script putting data in wrong button
« Reply #2 on: August 25, 2008, 09:48:41 AM »

Hi Meta,

Thanks for putting your time into this. In that case, could you please clarify if there is a difference between how 'if' statements with curly brackets and those without are executed? Because to me, they both have a nested if - it's just that Mnem's doesn't have brackets. If you put brackets in the middle if-else, the code looks the same in both cases. So have I misunderstood the use of brackets?

To me, this looks as though that instruction is in the same block. I still don't get what's different.

Thanks


Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Save script putting data in wrong button
« Reply #3 on: August 25, 2008, 10:23:51 AM »

The scripts look indeed functionally identical. Try changing:

  var SlotButton = this.GetControl(i + 1);

to:

  var SlotButton = this.GetControl(ToString(i + 1));
 
so that GetControl really returns the button named "1", not the control at index 1.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Save script putting data in wrong button
« Reply #4 on: August 25, 2008, 11:11:19 AM »

Thanks Mnem, that has indeed fixed it for both the save and load tables. There didn't seem to be anywhere the script could be getting the idea to use button 2.

Ah well - using a numeric as a string interchangeably turned out too good to be true after all :(

Thanks for your time

Cheers

BTW - other than that, while taking apart your code for the save screen, I was struck by its elegance - thought you might like to know

Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com
 

Page created in 0.056 seconds with 24 queries.