Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AdamM on Mon 12/02/2007 03:51:41

Title: 2.71 String problems
Post by: AdamM on Mon 12/02/2007 03:51:41
When I was building my game in 2.70, I had a script (which I think I nicked off someone else on these forums but can't remember who) in the first room (the splash screen) that triggered an InputBox asking for the player's name. This would then be stored in buffer, StrCat'd a surname onto it, and then StrCopy'd to character[EGO].name.

The player character's name is simply that, 'character[EGO].name', so that it can be used in things like looking at oneself:

Display("That's me, %s.", character[EGO].name);

I upgraded to 2.72 so that I could use a module that required it. Upon trying to compile I was told that "'name' is not a public member of 'character'" and suggested I capitalise it. Grumbling, I did, and upon compiling found the error message had changed to:

Type mismatch: cannot convert 'String*' to 'string'

It references the line that says:

StrCopy(character[EGO].Name, buffer);

Now this completely baffles me, and nothing I try will fix it... help!
Title: Re: 2.71 String problems
Post by: Gilbert on Mon 12/02/2007 04:33:27
Just change that line to:
character[EGO].Name = buffer;
Title: Re: 2.71 String problems
Post by: AdamM on Mon 12/02/2007 11:04:45
Hey, that worked! Why though? Is StrCopy obsolete? I can't access the help file for some reason, so I can't find out if that's the case.
Title: Re: 2.71 String problems
Post by: Gilbert on Mon 12/02/2007 11:12:58
Yes, the whole string format was revamped to the new String format since V2.71. There're actually HUGE changes in each version of the V2.7 branch.

You need to be careful when you want to upgrade the AGS version your game's using, since changes/fixes in the package may break stuff. Remember to backup your game files when you make such a decision, so whenever things go wrong using new version you can still keep on using the old version with the backed up source.
Title: Re: 2.71 String problems
Post by: AdamM on Mon 12/02/2007 12:22:29
I got into the CHM, and it does indeed say StrCopy is now String.Copy, or in fact just two strings seperated by =. Go figure. Does a code update always necessarily have to break everything that went before in order to work?Ã, Grr. :)
Title: Re: 2.71 String problems
Post by: Gilbert on Mon 12/02/2007 12:46:37
No, it's just because of the migration to OO-style scripting in the V2.7 branch.
Title: Re: 2.71 String problems
Post by: SSH on Mon 12/02/2007 13:37:12
You can uncheck "Enforce new strings" and the old code should work...
Title: Re: 2.71 String problems
Post by: monkey0506 on Mon 12/02/2007 20:10:28
You can't use StrCopy with a String though can you? Because Character.Name is now a String property...(I haven't tested it, so I could be wrong, but it doesn't seem like it would/should work).
Title: Re: 2.71 String problems
Post by: Gilbert on Tue 13/02/2007 01:32:22
I think the option only solve problems occasionally, mostly with user defined variables and functions, it's still recommended to fix the codes to follow the required format.