2.71 String problems

Started by AdamM, Mon 12/02/2007 03:51:41

Previous topic - Next topic

AdamM

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:

Code: ags
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:

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


Now this completely baffles me, and nothing I try will fix it... help!

Gilbert

Just change that line to:
character[EGO].Name = buffer;

AdamM

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.

Gilbert

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.

AdamM

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. :)

Gilbert

No, it's just because of the migration to OO-style scripting in the V2.7 branch.

SSH

You can uncheck "Enforce new strings" and the old code should work...
12

monkey0506

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).

Gilbert

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.

SMF spam blocked by CleanTalk