Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Splitting strings  (Read 5635 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'
Splitting strings
« on: August 23, 2008, 07:30:36 AM »

Hi all

I've added some code to the load game script, to take the first sixteen digits of the game description as a stored date and time:

Code: [Select]
    var SlotDate;
var q = Game.GetSaveSlotDescription(SaveSlot);
var StringSplit = String(q);
var l = StringSplit.Length;
Game.Msg(StringSplit+" "+l);
  if(l > 16)
    {
SlotDate[i] = StringSplit.Substr(0, 16);
    Game.Msg("i is:"+i+"  SlotDate is:"+SlotDate[i]);
    SlotButton.Text = StringSplit.Substr(16, l-16);
    }
  else
    {
    SlotButton.Text = Game.GetSaveSlotDescription(SaveSlot);
    }
It seems that either the .Length or the String isn't working because although I know the game descriptions are over sixteen characters in length, the l>16 condition is not being met.  I've tried to test it with a Game.Msg, but that never displays.

What am I doing wrong? Why is the length of the string not being returned and why do neither  of the Game.Msg instructions display?

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

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Splitting strings
« Reply #1 on: August 23, 2008, 07:46:26 AM »

Try:

Code: WME Script
  1. var SlotDate;   
  2. var q = Game.GetSaveSlotDescription(SaveSlot);
  3.  
  4. var StringSplit = new String(q);
  5. var l = StringSplit.Length;
  6.  
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: Splitting strings
« Reply #2 on: August 23, 2008, 08:50:23 AM »

Hi Meta

Thanks for the suggestion, but...

Actually, I'd just changed it from new String to String to see if it would make any difference. I'd had the same effect with new String already. Must be something else?

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

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
Re: Splitting strings
« Reply #3 on: August 23, 2008, 08:54:01 AM »

Hi, I have the same type of thing in my game. Except in ours, I needed to add to the save game description. Here is the code:

Code: [Select]
StrObject = new String(Game.GetSaveSlotDescription(0));
pos = StrObject.IndexOf(",");
subStr = StrObject.Substring(0, pos);
StrObject = new String(" Points - "+points1+"");
subStr = subStr+StrObject;
Game.SaveGame(0, subStr);

Hopefully that makes sense.
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Splitting strings
« Reply #4 on: August 23, 2008, 09:17:07 AM »

Thanks mylesb

I've no problem with appending the date to the save description, that works great. It's when I'm trying to parse the date out again that the String don't do its thing.

1) varible.Length returns null
2) Game.Msg produces no output

Anybody any ideas why Length returns null the way I've used it?
Code: [Select]
var q = Game.GetSaveSlotDescription(SaveSlot);
var StringSplit = String(q); // var StringSplit = new String(q); produces same result
  var l = StringSplit.Length;

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: Splitting strings
« Reply #5 on: August 23, 2008, 09:25:08 AM »

null or zero?
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: Splitting strings
« Reply #6 on: August 23, 2008, 09:36:12 AM »

Actually, can't be sure because Game.Msg puts nothing on the screen (the other problem). If I've indexed the variable correctly, a static should display the part of the string that contains the date as parsed from the save description - it displays 'null'.

So I'm guessing null. Sorry I can't be more precise.
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

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
Re: Splitting strings
« Reply #7 on: August 23, 2008, 10:16:42 AM »

Hey,
Ok so I'm not really sure why it's not working. I also had to get the name out of the save description which worked for me but sadly i found a better to do what i needed so i deleted the code.

If you want to check what length is returning. Store the value of length in a global variable and then have a look in the debug window.

Cheers ::beer
Myles Blasonato
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Splitting strings
« Reply #8 on: August 23, 2008, 11:13:57 AM »

Quote
so i deleted the code
  Aargh! Pity.

Quote
Store the value of length in a global variable and then have a look in the debug window
Good idea. Thanks for that, I'll give it a try.

 ::beer Mind if I join you?  ::beer
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

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Splitting strings
« Reply #9 on: August 23, 2008, 11:42:08 AM »

Hi Myles

I set up a global object, stored in it both the string and the length of the string. Ran it again (twice) and got:

-----------------------------------------------------------------
---------- wme 1.8.006 crash report: 23-08-2008, 11:39 ----------
-----------------------------------------------------------------
wme.exe caused a EXCEPTION_ACCESS_VIOLATION in module wme.exe at 001B:0043FE88, CBGame::IsDirectXBound()+39000 byte(s)
EAX=00000007  EBX=0B9F480F  ECX=00000000  EDX=00000000  ESI=00000000
EDI=00000000  EBP=00C5DDE8  ESP=0012FD48  EIP=0043FE88  FLG=00210202
CS=001B   DS=0023  SS=0023  ES=0023   FS=003B  GS=0000
Stack trace:
001B:0043FE88 (0x00C5DDE8 0x00000000 0x00C51358 0x00000000) wme.exe, CBGame::IsDirectXBound()+39000 byte(s)
001B:00C51401 (0x00000000 0x00C51358 0x00000000 0x00000000) <UNKNOWN>
001B:00C5DDE8 (0x00C51358 0x00000000 0x00000000 0x00000000) <UNKNOWN>

Hello Mnemonic - over to you, dear chap.

Cheers
 
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

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
Re: Splitting strings
« Reply #10 on: August 23, 2008, 03:56:18 PM »

Hi,
Get rid of that global you made and change var l to global l. You should have the following code after that:
Code: [Select]
var SlotDate;
var q = Game.GetSaveSlotDescription(SaveSlot);
var StringSplit = String(q);
global l = StringSplit.Length;
Game.Msg(StringSplit+" "+l);
  if(l > 16)
    {
SlotDate[i] = StringSplit.Substr(0, 16);
    Game.Msg("i is:"+i+"  SlotDate is:"+SlotDate[i]);
    SlotButton.Text = StringSplit.Substr(16, l-16);
    }
  else
    {
    SlotButton.Text = Game.GetSaveSlotDescription(SaveSlot);
    }

Cheers ::beer
Myles Blasonato
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Splitting strings
« Reply #11 on: August 24, 2008, 03:45:12 PM »

Thanks Myles.

I didn't change the code in the end, except to take Metamorphium's suggesting of putting back the 'new' I'd take out. Then I rebooted the machine. Then it all worked. Go figure.

Cheers   ::thumbup
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.049 seconds with 24 queries.