AGS 2.71 Final 2 - Politically Correct Edition

Started by Pumaman, Sun 05/06/2005 23:32:14

Previous topic - Next topic

GarageGothic

Problem solved. It turned out that the the error in:

Code: ags
string buffer;
if (GetSaveSlotDescription(101, buffer) == 0) {


wasn't actually in THAT piece of the code, although that was the script line number returned in the error message. The problem was in the code run after the if statement.

Another stupid oversight on my part was that I'd changed "string" to "const string" in my global script, but forgot to update their import statements in the script header.  ::)

I can now compile and report that sprite rotation works perfectly!

monkey0506

#101
Well, I finally gave in to temptation and downloaded the beta on my grandfather's computer...And I did some testing.  It would seem to me that the '=' (equal sign) DOES do a content copy on Strings instead of a pointer copy.  Which IMO is the way that it should be.  Here's the code I used:

Code: ags
#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
  String StrA = "this is some text";
  String StrB = StrA;
  Display("%s - 1", StrA);
  Display("%s - 2", StrB);
  StrA = StrA.Append("some more text");
  Display("%s - 3", StrA);
  Display("%s - 4", StrB);
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


And the text that was displayed was as follows:

this is some text - 1
this is some text - 2
this is some textsome more text - 3
this is some text - 4

I came to the conclusion that it does a content copy because if it was a pointer copy then surely StrB would have been displayed as "this is some textsome more text - 4", right?  In any case, I find the content copy much preferable to a pointer copy.

I did find something that I would consider a bug when trying to type:

Code: ags
// main global script
String StrA = "this is some text";


I got an error saying that you cannot initialize a global pointer.  At least in the case of Strings, I think that you should be able to assign initial values.

As for the question I asked earlier about String arrays, I have done some testing now...and I think there may be a problem:

Code: ags
// main global script file

String MyStrs[10];

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
  MyStrs[0] = "MyStrs[0]";
  MyStrs[1] = "MyStrs[1]";
  MyStrs[2] = "MyStrs[2]";
  MyStrs[3] = "MyStrs[3]";
  MyStrs[4] = "MyStrs[4]";
  MyStrs[5] = "MyStrs[5]";
  MyStrs[6] = "MyStrs[6]";
  MyStrs[7] = "MyStrs[7]";
  MyStrs[8] = "MyStrs[8]";
  MyStrs[9] = "MyStrs[9]";
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


The problem is that when I try to compile, I get an error:

Quote from: Error---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:

In: 'Global script'



Error (line 8): Type mismatch: cannot convert 'const string' to 'String*'



Do you want to fix the script now? (Your game has not been saved).
---------------------------
Yes   No   
---------------------------

"Cannot convert 'const string' to 'String*'"...On a wild guess I tried putting the text on the left side and it said that a variable is required on the left side of an assignment.  I figured that much.  So is this a bug or are String arrays not going to be allowed?

That's about all I have for you today.  Later.

Edit:

I'm beginning to think that String arrays won't work at all.  I typed the following code:

Code: ags
// main global script file

String MyStrs[10];

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
  String str = "something";
  Display(str);
  str = "something else";
  Display(str);
  MyStrs[0] = MyStrs[0].Append("this is some text");
  Display(MyStrs[0]);
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


As I already said, typing "MyStrs[0] = "this is some text";" produces an error, so, as you can see, I tried Appending some text.  This produced an error as well.  First the following was displayed (as it should have been):

something
something else

Then the game exited with the following error:

Quote from: Error---------------------------
Adventure Game Studio
---------------------------
An internal error has occured. Please note down the following information.
If the problem persists, contact Chris Jones.
(ACI version 2.71.872)

Error: run_text_script1: error -6 running function 'game_start':
Error: Null pointer referenced
in Global script (line 12)


---------------------------
OK   
---------------------------

So the append function didn't work since the pointer was still null.  So I tried adding a line "if (MyStrs[0] != null) ...", and it produced yet another error:

Quote from: Error---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.71.872)

in Global script (line 13)

Error: Null string supplied to CheckForTranslations

---------------------------
OK   
---------------------------

The above game_start function is the entire code for the game apart from the default script of the Default game template...and I just checked the help manual, and it turns up that CheckForTranslations is an internal function of AGS. (Line 13, btw, is "Display(MyStrs[0]);").  So by enclosing line 13 into the if statement, the String is neither stored nor displayed.  So...will this be fixed or will String arrays not be allowed just as string arrays were not allowed before them?  Personally, I would prefer the first, but it's not really up to me, which is why I'm asking.

Pumaman

QuoteI was asking if a String object was a pointer.  Which I'm presuming that it is based on your comments.

Yes, it is.

QuoteActually from the manual, I thought using the = assigment is a content copy rather than a pointer copy (but now it appears as pointer copy), simply because of the following line you wrote in String.Copy() of the manual:
"Returns a new copy of the specified string. You should not normally need to use this, since strings can be assigned using the = operator."

You are right in that this statement in the manual would be wrong and confusing if strings can modified. In the current version strings cannot be modified, so there is no difference from a users' point of view as to whether you use Copy() or = . However, if Chars[] was writable for example, then there would be a significant difference and a reason to use Copy().

QuoteIn my opinion, since AGS is a game creation package for ease of use, maybe it's worth discussing whether = for Strings works as a content copy or a pointer copy.

Again, the way that Java/C# get around this question is simply by making string content read-only. That way you don't need to know whether it's a pointer or content copy because the result is the same.

Quotechanging a character in the middle will become complex, compared to StrSetCharAt() we already have for old strings.

It wouldn't have to be. There could easily be a function that worked like this:

str = str.ReplaceCharAt(4, 'X');

that way you still get the ease-of-use of SetCharAt, but the actual string content isn't changed and therefore you don't have issues of pointer vs content copies.

QuoteIt would seem to me that the '=' (equal sign) DOES do a content copy on Strings instead of a pointer copy.
I came to the conclusion that it does a content copy because if it was a pointer copy then surely StrB would have been displayed as "this is some textsome more text - 4", right?

No, it is a pointer copy. But from your point of view as a scripter, it doesn't matter because as you note the result is the correct one.

Notice the key line of code:
StrA = StrA.Append("some more text");

This doesn't actually change StrA -- it creates a new string and then does a pointer copy of the new string into StrA. In other words, it's short for this:

String StrNew = StrA.Append("some more text");
StrA = StrNew;

If you just did this:
StrA.Append("some more text");

on its own, it would do nothing. StrA is not actually modified, but it returns the modified string (which is just thrown away in this case).

QuoteAs for the question I asked earlier about String arrays, I have done some testing now...and I think there may be a problem:

String arrays do not currently work as you've discovered, but I will fix them before the Final.

monkey0506

Okay.  Well than I guess that clears up the issues that I just edited my post about.  Glad to hear that we will be having String arrays...but any word on putting them in structs?  You said that you would like to implement this, so I was just wondering whether I should expect it or not.  I'm really happy with the work that you've done here Chris!  Keep it up (PLEASE  ;D)!

Also, I would like to comment on the new String.Format function.  I like the fact that it is static so we no longer have to create buffer strings to format things like label text.  It will be nice when I get home to be able to type something to the effect of:

LucasLbl.Text = String.Format("%s", GetModeText());

Of course I just made that up right now, that's not what it will really look like, but it's much nicer than:

string buffer;
StrFormat(buffer, "%s", GetModeText());
LucasLbl.SetText(buffer);

So good job Chris, and thank you!

RickJ

Re: Sound and Music file names
Quote
Yeah, after all, all the multimedia functions would have to be changed to accept file names instead of numbers which is a lot of work for relatively little gain in my opinion.  What I do is set up enums in the main script header ...
Would be neat if these could be created and included in the header automatically.   We wouldn't need to copy sound and music files to SoundNN or MusicNN files.   

On another and vaguely related topic, it would also be nice if the sprite import mechanism would retain the file name so that it could be displayed along with the other sprite properties or so that it could be used as the default export file name.




Rui 'Trovatore' Pires

On that note I have to say that I disagree with RickJ, I find it quite helpful how it exports the sprites and names them whatever number they had. It's much easier for me. Just my opinion on a suggestion.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Gilbert

http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=227

But it's a bit going off topic now, let's stay with bug reports  for V2.71. I think suggestions related to the new String handling method is okay though.

edmundito

#107
I found a typo in the manual, under SetMusicVolume:

Example:

SetMusicVolume(-3);

will set the room volume to quitest.

---

Where's the other e? :)

Also, I don't know if this could be a bug, but SetMusicMasterVolume does not seem to completely mute music playing at 0. I've been using oggs to test this, and I can still hear the music playing in the background. Is this the way it's supposed to work? and if so, why? (I'm suspecting it has to do with SetDigitalMasterVolume, huh?)

Edit: Okay, Rui solved this for me: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=21010.0

BUT THE TYPO STILL STANDS! :P

strazer

According to the manual Character.FaceLocation expects screen coordinates when in fact it works with room coordinates.

monkey0506

I got an error message when trying to open a project I'm working on.  Actually it was about 100 - 200 errors.  Something about an error loading a sprite that didn't exist.  It also told me I may have deleted a sprite that was in use.  I got this error message before, and so I decided to wait a while on the Beta...but now it popped up again...I'm not really sure what the problem is, but re-importing the GUI took care of it (there is currently only one GUI and no scripts created from the GUI, so...no worries).  It didn't crash AGS, it just displayed a zillion errors telling me about all the missing sprites.  Thank goodness the enter key clears away those error messages.

Fribbi AGDI joker

This is the same thing what happened to my game. And it destroyed my game. Every sprites was lost. :'(

Pumaman

QuoteI found a typo in the manual, under SetMusicVolume:
QuoteAccording to the manual Character.FaceLocation expects screen coordinates when in fact it works with room coordinates.

Thanks, I'll fix these.

QuoteI got an error message when trying to open a project I'm working on.Ã,  Actually it was about 100 - 200 errors.Ã,  Something about an error loading a sprite that didn't exist.

That's quite worrying. What version of AGS was the project created with? Do you still have a copy of the game before you upgraded it so that I can try it myself and look into it?

QuoteThis is the same thing what happened to my game. And it destroyed my game. Every sprites was lost.

This is always a risk when using a beta version, and is why the original post in this thread makes it clear to back up your game before trying out a beta :)

monkey0506

It's a new project that I'm developing from within this BETA.  It's the SM I've been working on.  So there's not a big ordeal with the sprites.  I only had about 21 - 22 sprites that were lost, so I reimported them.  But then I got about 10 - 15 errors per sprite...that was truly disturbing. :=  If you need me to I could randomly open and close AGS to try and simulate the error again... ::) Seeing as it was a random error with only the message about the corrupted (missing?) sprite and no other message...

Pumaman

Hmm, so it wasn't upgrading a game from a previous version then, it just randomly gave you the error when working with the beta?

You didn't happen to keep a copy of the game where it said the sprites were missing, did you?

monkey0506

#114
Yes, it did just randomly give me the error when working with the beta.  I did some stuff on it, saved it, came back later, and then I got the error.  I don't have a copy of the game with the "missing" sprites, but I will be sure to send one your way if it happens again.

EDIT:  I found a text file containing the messages displayed, if it helps at all...

http://www.sitesled.com/members/meleepta/agsedit.log

Also, I know you are at Mittens, but just curious as to how String data member support was coming.  Talk to you guys when you get back.  Have fun!

EDIT:  I'm trying to write this new script in the most up to date method, so I'm trying to use Strings in place of strings.  I must say, it's a lot nicer.  However, since I can't currently use them as data members, I'm still having to use char arrays for some of them.  That's not why I'm editing my post though.  I thought that I could return a String from the function to get around using a buffer parameter, but it gave me an error with returning a local string from a function...Although you can return local integral types from functions, I didn't get upset.  I decided I would just have to use a buffer parameter, so I used a String parameter.  However, when I actually called the function, the String I passed as the parameter was unchanged.  I kind of understand why, but it would be nice if we could get rid of having to use string buffer parameters altogether (I did use a string, and it works now).  So, I suppose that's all for now.

strazer

#115
Broken links in the manual:
  Tutorial -> Setting up the game -> "hotspot interactions"
  FAQ and Troubleshooting -> Game creation problems -> "here"
  Scripting -> Overlay functions and properties -> See Also: "MoveOverlay"

Edit:

Spelling:
  The run-time engine -> The demo game -> "available as a seperate download" => separate
  The run-time engine -> The Wavetable Synth MIDI driver -> "only available seperately => separately
  Tutorial -> Setting up the game -> Conversations -> "The Dialog Editor is quite self-explanitory => explanatory
  Tutorial -> Setting up the game -> Game options -> Use letterbox (320x240 / 640x480) resolution -> "The screeen will be "letter-boxed"
  Tutorial -> Setting up the game -> Game options -> Number dialog options -> "as well as seperating the options" => separating
  Tutorial -> Setting up the game -> Advanced room features -> Importing a file as the walkable area mask -> "draw these in the editor itsself"
  Other features -> The text parser -> "all words seperated by the comma will match"
  Other features -> Translations -> "You can now give this file to your translaters." => translators
  Other features -> Lip sync -> "Seperate the letters by forward slashes."
  Scripting -> Script modules -> "split your code into more managable chunks" => manageable
  Scripting -> Character functions and properties -> Character.LockView -> "used to perform
animations with charaters" => characters
  Scripting -> File functions and properties -> File.Error -> "whether an error has occured"
  Scripting -> Object functions and properties -> Object.MergeIntoBackground -> "if a game event has occured"
  Scripting -> Game / Global functions -> IsKeyPressed -> "numeric keypad can have inconsitent keycodes" => inconsistent
  Scripting -> Game / Global functions -> RunAGSGame -> "as if it had been launched seperately"
  Scripting -> Game / Global functions -> SetGameOption -> "a seperate command to change them"
  Scripting -> GUI control functions and properties -> GUIControl.SetPosition -> "create dynamically resizable GUIs" => resizeable
  Scripting -> GUI control functions and properties -> GUIControl.SetSize -> "create dynamically resizable GUIs" => resizeable
  Scripting -> Maths functions and properties -> Maths.DegreesToRadians -> "Since the trigonometic functions" => trigonometric
  Scripting -> Mouse functions and properties -> Mouse.ChangeModeGraphic -> "This permenantly changes" => permanently
  Scripting -> Multimedia functions -> SetMusicMasterVolume -> "This is slightly mofidied by" => modified
  Scripting -> Multimedia functions -> SetMusicVolume -> "set the room volume to quitest" => quietest
  Reference -> Interaction events -> "following events are avialable in" => available
  Reference -> Scripting event reference -> on_event -> "depends on which event has occured"

Gilbert

Shuuuu... These are for the V3.0 Service Release Premium Edition, otherwise he has nothing to fix and add after V3.0 is finished. :=

Rui 'Trovatore' Pires

Bug. I toyed with the possibility of making an IF template, and using properties as placeholders of descriptions. But when I tried to give a property a description which I suspected was too long (and was already mentally making workarounds for), and pressed ENTER... the editor quit. Just like that. No error message. No game saving. No nothing, it just quit. And when I booted it up again, no errors at all - but it was as I had left it only when I had last saved.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pumaman

QuoteYes, it did just randomly give me the error when working with the beta.  I did some stuff on it, saved it, came back later, and then I got the error.  I don't have a copy of the game with the "missing" sprites, but I will be sure to send one your way if it happens again.

That is worrying. Has this happened to anyone else?

If it happens again, as well as saving a copy of the files for me to look at, can you try deleting hte "sprindex.dat" file, and then renaming the "Backup_acsprset.spr" to "acsprset.spr" and see if it comes back to life?

QuoteI thought that I could return a String from the function to get around using a buffer parameter, but it gave me an error with returning a local string from a function...

This is now safe with the new Strings, so I'll look into fixing it so that you can do this.

QuoteBroken links in the manual:

Thanks, I'll fix all these when I get a moment.

Quotewhen I tried to give a property a description which I suspected was too long (and was already mentally making workarounds for), and pressed ENTER... the editor quit.

Thanks for the report, this is now fixed in beta 4.


Anyway, Beta 4 is now up. This replaces all the built-in functions that used to take a "string buffer" parameter with versions that return a String instead. As usual, the manual links have been set up so you can easily find the new one.

Also, you can now use arrays of Strings, and the "noloopcheck" keyword allows you to bypass the while loop iteration checks since it was causing problems for some people.

Let me know of any problems.

monkey0506

#119
Woohoohoohoo!!! ;D

You ROCK Chris!!!

Edit:  I found that noloopcheck doesn't appear in the function import if you import the function to a struct.  It only appears in the definition or else it tries to make noloopcheck the function name, which causes an error.  And it's not documented that it shouldn't appear in the import...

Edit:  I didn't do any super extensive testing because I realized that I still can't use Strings as data members...and there were other problems that I realized with my script that just kind of shut me down for a while...I'll come back to it later and let you know if I find anything else.

SMF spam blocked by CleanTalk