Question about object animation loop and auto-complete.

Started by jwalts37, Sat 13/07/2013 21:03:26

Previous topic - Next topic

jwalts37

Hey guys,
My name is Josh and I recently started helping my brother in-law with the game hes making with AGS.
Let me first say I am no stranger to compiled/interpreted programming languages but I am completely new to AGSscript. Only been working with AGS and its scripting language for a month or two. I have a background with c# and php but mostly for web based applications. This is my first time doing any sort of game development. AGS confuses me and frustrates me with some of the things it does and some of the odd ways it works but I keep working at it. I find that I have trouble sometimes with the simplest things.

----------------------
Here's my first issue:
----------------------
So theres a room with a bunch of animated background objects doing simple stand-in-one-place animations. But theres a guy who has a cart of lobsters that he pushes across the room. We called him "oLobsterMan". He Comes on the screen from the left side and walks across to the right and off. That was all fine and dandy but I wanted to make it so he would back and forth with some time in between. It seemed SO simple but I had such a hard time figuring it out. I ultimately figured it out but to me it seems that there would be a simpler, more-efficient way of doing this. By the way. His view is called "LobsterCartMan" and LOOP 0 is his animation when hes facing right and LOOP 1 I took the same sprites and used the "flip all frames in loop".  So LOOP 1 is him facing left.

So at first, to have him just walk across the room I had this inside the "room_Load()" function:
Code: AGS

function room_Load()
{
    ...
    the other room objects being set visible, solid, SetView, and Animate
    ...  
    oLobsterMan.SetView(LOBSTERCARTMAN); 
    oLobsterMan.Animate(0, 5, eRepeat, eNoBlock, eForwards);
    oLobsterMan.Move(400, 194, 1, eNoBlock, eAnywhere);
}


The next thing I tried was this:
In the "room_RepExec()" function:
Code: AGS

function room_RepExec()
{
    if (!oLobsterMan.Moving)
     {
         oLobsterMan.StopAnimating();
         oLobsterMan.Animate(1, 5, eRepeat, eNoBlock);
         oLobsterMan.Move(-100, 202, 1, eNoBlock, eAnywhere);
     }
}

So now He walked across and walked back. But like I said, I wanted him to keep going back and forth with some time in between. So after doing ALOT of searching on the forums, reading and reading. I thought maybe it would be best to do it with a timer. So I added this in the "room_AfterFadeIn()" function:
Code: AGS

function room_AfterFadeIn()
{
    SetTimer(1, 500);
    .....
    rest of room/character code
    .....
}


And then down in the "room_RepExec()" function I put this:
Code: AGS

function room_RepExec()
{
    
    if (IsTimerExpired(1))
     {
         oLobsterMan.Animate(1, 5, eRepeat, eNoBlock);
         oLobsterMan.Move(-100, 202, 1, eNoBlock, eAnywhere);
         SetTimer(1, 500);

  
    if (!oLobsterMan.Moving && !IsTimerExpired(1))
     {
        oLobsterMan.Animate(0, 5, eRepeat, eNoBlock, eForwards);
        oLobsterMan.Move(400, 194, 1, eNoBlock, eAnywhere);

     } 

  }

}

It worked! BUT. I honestly feel like i'm doing this the hard way and there's a more efficient, easier, simpler way to do this.

I have one more issue.
The intellisense/(auto-complete) in AGS. When I open the game, ill open a script up and start typing "oLob" and the full object name shows up. Works just fine. Then ill run the game, or sometimes ill open another room or work on another script and then when i type "oLob" NOTHING comes up. And ill scroll through the autocomplete box and NONE of my objects show in there anymore. The only thing that comes up for him is "oLobsterMan_Interact" I have to close the program and re-open it. I seem to have to do this every 30 seconds. And it gets REALLY REALLY frustrating. Sometimes it works, then all of a sudden it doesnt. But it seems to only do this with objects. Everything else in the auto-complete come up just fine every time.
I apologize about the long and drawn out post guys but I figured i'd be thorough in my explanation of what im trying to do and what i've tried so far. Ive read through hundreds of forum posts, and maybe Im just not using the right words in the query.
If anyone has any suggestions on the animation and/or the auto-complete issue please let me know. Id really appreciate any and all feedback. Thanks guys!
-Josh


Khris

Regarding your auto-walking, that's pretty much the way to do it, yes. There's no much simpler way to make characters move in the background.

Regarding the auto-complete window: it works very well and reliable, but you have to know how it works internally.
The list it will display is updated every time you switch tabs; there's no need to restart AGS. So for instance whenever I want it to update to reflect additions I have made to a script, I press Ctrl-Tab twice, which will switch to another tab and right back, forcing an update.
Another thing I have learned to do is to close brackets right away. For instance when I add a loop, I'll write "while (x < 50) {", then immediately add x++; and the closing } before starting to put stuff inside the loop. Same with Strings and functions. I do this because otherwise the parser can get really confused, and I've had the quick selection dropdown at the top shrink from dozens of functions to five or so because I hadn't closed my braces properly. I'm not sure this will affect the auto-complete, too, but I wouldn't be surprised if it did.
The other thing is that the auto-complete window is actually more "intelligent" than you give it credit for. If it shows everything but room objects, chances are that you cannot actually use their script names in the current scope, for example in an inventory item's _Interact() function. (In a global context, you can only refer to a room's objects or hotspots using the respective arrays object[] and hotspot[].)
It will also not show functions that are defined further down in the script and thus not usable in the current line.

Basically, it's not the auto-complete window's fault, it's that you're doing it wrong :P

jwalts37

Khris,

Thank you so much for your reply. This is all so new to me. About the auto-complete. I didn't to come off as saying that it sucks and I was smarter than it. I apologize for coming off that way. Something you said actually helped my brother-in-law and I figure out the issue. You said something about scope. So I went back and looked and I wasn't using any of these objects' functions globally, they were all inside the rooms script. So my brother-in-law (who's worked with AGS for much much longer than I) said maybe the room needs to be opened in order for the script to be able to access the rooms objects ...DUH..(I felt extremely stupid!) and sure enough, he was right! It worked!. See, I had just opened the rooms script and closed the actual room editor. So thank you very much for helping me/us figure this out. I really appreciate it! Everyday I learn some new quirk about AGS. Its very picky. But I think AGS is an incredible piece of software. Something i'm REALLY starting to enjoy learning and working with. Take Care!
-Josh

Khris

Quote from: jwalts37 on Tue 16/07/2013 20:55:38So my brother-in-law (who's worked with AGS for much much longer than I) said maybe the room needs to be opened in order for the script to be able to access the rooms objects ...DUH..(I felt extremely stupid!) and sure enough, he was right! It worked!. See, I had just opened the rooms script and closed the actual room editor.
Actually, no.
There's no reason why the room would have to be opened for a script that's referring to room objects to work (or for the objects to show up in auto-complete), and it doesn't make any sense either (so much for "DUH"). And as I suspected, it isn't the case; in fact you don't even have to save the room for a newly created object to appear or be usable, I typed the script name "oTest" into the object's field, switched over to the room script and there it was, as soon as I had typed "ote". Then I closed the room, and it worked just fine afterwards, too.

Not sure what you did wrong, are you using the latest beta or something? Or some older version? The last official, stable version is 3.2.1, and unless stated otherwise, that's the one I'm using.

RetroJay

I am sorry to jump in here.

Khris.

When I had problems a while back you said that you were using the 'Draconian version'.
I switched to the 'Draconian version' and it solved my probs.
Are you still using this or not?

If not why?

You know that I consider you as 'My mentor'.

Yours, as always,
Jay.

Khris

Hi Jay, yes, I'm still using some Draconian alterations, but the differences are in the engine mostly (like the sound panning business). There shouldn't be any changes to the behavior of the editor or the auto-complete window.

Snarky

Quote from: Khris on Tue 16/07/2013 20:26:23
Regarding the auto-complete window: it works very well and reliable, but you have to know how it works internally.

It really doesn't. Even with Ctrl-tabbing back and forth, it often fails to pick up autocompletes. Since I've been working with the betas recently I don't remember the specifics from most examples of it being definitely broken in 3.2.1, but one that comes clearly to mind is that the autocomplete list never includes enum types.

Khris

Could you give a concrete example? Can you confirm that it won't show room objects in the room script?
Is there any consistency to how it supposedly fails?
All I have noticed is that it sometimes doesn't pick up local variables that have just been introduced. But again, forcing an update fixes this. What it does is show variables multiple times though.

(Just to re-iterate: I don't expect the ac-window to work as long as there are unclosed functions and the like. It usually does if you have just opened one, because it hasn't updated yet, but if you switch to a script tab with the game being in a state in which it won't compile, it's not surprising that the list won't be accurate. It's not AI.)

Enum types are never included though, true.

Snarky

Quote from: Khris on Wed 17/07/2013 09:44:47
Could you give a concrete example? Can you confirm that it won't show room objects in the room script?
Is there any consistency to how it supposedly fails?
All I have noticed is that it sometimes doesn't pick up local variables that have just been introduced. But again, forcing an update fixes this. What it does is show variables multiple times though.

I've definitely had cases where nothing short of restarting the editor would force it to detect new names. I vaguely recall having trouble with room scripts, but can't say for sure that it wasn't one of the other limitations you mention.

Like I said, I'm currently working with the 3.3 betas, but today I experienced two autocomplete failures: First, the one already mentioned here, where partyChar, a local instance of a custom struct (AtbCharacter) defined in a separate script file, is not picked up by the autocomplete, either while typing the name, or for the members/methods when typing the "." Nothing fixes this (not even restarting the editor), even though the code compiles and runs fine. It seems to have something to do with the name, since identically declared instances called things like testName work fine. (If someone wants to look into the Intellisense code, I suppose I could send them my project.)

Second, I was calling a function (that I'd already defined), and even though the function name itself autocompleted, on typing the opening parenthesis I didn't get any hints about the argument types or names (I think there was just one argument, an int). Tabbing around made no difference. Just finishing the line made the code compile.

This is the kind of behavior I experience frequently with the editor. There's probably some consistent pattern to it, but I'm damned if I know what it is.

Adeel

I have had few cases in AGS 3.2.1, when the auto-complete simply failed to pick up my newly declared variables (most of time, I use Global Variables). I had to do the same as Josh has stated: Closing the editor and then opening it again in order to update it.

SMF spam blocked by CleanTalk