[SOLVED] Problem with setting the iconbar to on/off for specific rooms

Started by Fitz, Thu 07/04/2011 09:32:49

Previous topic - Next topic

Fitz

I'm probably missing something very obvious here - but I've tried a bunch of things and none is quite what I'd want. So basically, I have two kinds of rooms:
1. The interactive ones, where the actual game takes place
2. Rooms I use for non-interactive cutscenes.
In type 1, I'd like to have the Iconbar on all the time - as in the classic LucasArts games. Obviously, I want it off in type 2. But if I use the string

gIconbar.Visible = false;

for a given in the AfterFadeIn function, it only goes away when the room's faded in. Conversely, if I set the iconbar to "Initially Off" and use:

gIconbar.Visible = true;

for a given room after AfterFadeIn, it isn't there from the start, either, it goes on with a second's delay. It's much "cleaner" than the previous option, but it's still a bit messy. So then I tried to put that same string in the BeforeFadeIn fuction - but that doesn't seem to work, the iconbar doesn't go on at all. Is it that I'm doing something wrong here or is BeforeFadeIn used for something else entirely?

So what do I do to have the iconbar on/off as soon as the given room loads and before the fade-in is complete? Some global variable? Custom room function with boolean value?

Khris

Before fadein is exactly what you should use; did you properly link the function in the room event pane? Is it called at all?

Fitz

Hmm... I put this:

Code: ags
function room_BeforeFadeIn()
{
gIconbar.Visible = true;
}


right on top (after the //room script file, of course) after having set it to "Normal, Initially Off" in the Iconbar setting in the GUI section. Is there something I'm missing? AfterFadeIn works perfectly with just that.

Matti

Did you link the function via the lightning bolt icon or did you just copy/paste those lines?

Khris

Yeah, iirc the before fadein function that's generated by AGS is called room_Load by default.
Changing the name won't fix the problem though, like we said it must be linked.

Fitz

That fixed it, thanks! :D Matti guessed correctly, I was doing it backwards. Oh well, that happens when a cartoonist/writer tries programming ::)

Khris

Just for the sake of completeness, you also could've pasted "room_BeforeFadeIn" into the field in the events pane.

monkey0506

I think it might actually be worthwhile for the editor to look for functions in room scripts that would match the default name of otherwise unlinked events and attempt to link them automatically. If you were using a non-default name (like "room_BeforeFadeIn") then it wouldn't work and would have to be manually linked still..and of course automatic linking shouldn't override any manually linked events..but it would probably help AGS newbies out a lot (since this type of issue seems rather common).

Fitz

Khris: That's actually the problem - I completely overlooked the Events section for rooms (although I did use it and linked through it before for Characters and Objects) and just typed the commands in via the Room Script. My bad. Still learning :)

Monkey_05_06: I did try typing in "room_Load", as well, but that didn't work, either. Aaanyway... That's actually a great idea! Noobs like myself would really appreciate that.

Thanks again, now I can proceed with setting up other rooms before I come here again to bother you guys about something new ;)

monkey0506

With your response, I'm not entirely sure if it was clear to you, but I was talking about a potential modification to the editor..in any case, you got it working, so..yay! :=

Khris

Quote from: Fitz on Thu 07/04/2011 20:14:46I completely overlooked the Events section for rooms (although I did use it and linked through it before for Characters and Objects)

I thought you did use the After fadein event (which resulted in the original problem)...?

Fitz

Monkey: Yeah, I got that - I'm not THAt much of a noob ;) Just a bit incoherent when I'm trying to say too many things at a time.

Khris: I typed that in, too. ;D I'm THAT much of a noob :P

I think my general state of confusion about things stems from the fact that before I even started working on my little game, I watched about 30 of Densming's tutorials IN ONE SITTING, barely moving away from the puter. It helped me a lot, because that way I could get a better picture of what I could do in the game. But then again, while I took a lot in, I forgot a lot, understood some things and grew more and more confused about other stuff. But I'll learn :) Right now I'm re-watching the tutorials and watching the remaining dozen or so that I haven't seen - which caused some more confusion and raised some more questions I will elaborate on later ;)

TomatoesInTheHead

Sorry for continuing this offtopic thing a bit:

Quote from: monkey_05_06 on Thu 07/04/2011 19:12:23
I think it might actually be worthwhile for the editor to look for functions in room scripts that would match the default name of otherwise unlinked events and attempt to link them automatically. If you were using a non-default name (like "room_BeforeFadeIn") then it wouldn't work and would have to be manually linked still..and of course automatic linking shouldn't override any manually linked events..but it would probably help AGS newbies out a lot (since this type of issue seems rather common).

The way it works at the moment is also pretty inconsistent, most functions have to be linked, but some can't (rep_ex_always) and in the global script there is no linking at all for the predefined functions. Also, I find it confusing that the naming in the events pane and in the script differs so much, it would be better if the default name for "Before Fade In" would be "room_BeforeFadeIn", for example.
I think it would be best if a) there was no real linking - so the events pane still shows the available functions (and there should be such a thing for the global script, too), where you can jump to them or create them in the script, but it would not have any "linking" effect, and would also display any functions that are directly written/copied in the script; and b) if the function names were fixed, because what you write about having default function names overridden by other function names would probably also be too confusing.

Such a change of how the linking works would IMO be worthwhile especially to make it less confusing for beginners, but on the downside it would lead to some problems with backwards compatibility that would have to be taken care of...

Khris

Character, inventory and GUI events link to the global script. The only thing mildly inconsistent is the room rep_ex event.
Also, the current system may not be perfect, but changing it because every other newbie fails to read the tutorial properly surely isn't the way to go. Why not fix the tutorial instead by expanding the explanation?

Fixed linkage is out of the question; there are several situations where it is convenient to put one function name into multiple event fields, an example would be a custom inventory GUI that uses buttons as item slots.
Although one could always work around that, the current system is straightforward and simple.

TomatoesInTheHead

Quote from: Khris on Fri 08/04/2011 12:57:19
Character, inventory and GUI events link to the global script.
Oh, yes of course. I had events like on_mouse_click, game_start and such in mind.

Quote from: Khris on Fri 08/04/2011 12:57:19Fixed linkage is out of the question; there are several situations where it is convenient to put one function name into multiple event fields
True, I forgot that.

Quote from: Khris on Fri 08/04/2011 12:57:19
The only thing mildly inconsistent is the room rep_ex event.
Also, the current system may not be perfect, but changing it because every other newbie fails to read the tutorial properly surely isn't the way to go. Why not fix the tutorial instead by expanding the explanation?
In interface design they say "if a user does something wrong, it's always the system's fault" := Doesn't need to be that radical, but if a problem pops up regularly, it might be that the system just isn't too clear at that point. Changes that make the system less usable for experts or even take away possibilities, like the one you mention with one function for multiple events, should of course not be made, so my suggestions above are partly invalid.
Another try: Maybe the editor could display a warning message if the user writes or pastes a function with a default name instead of linking it?

monkey0506

Khris, I think you misunderstood what I was suggesting. I wasn't talking about "fixed" linkage at all. What I was saying was that if a particular event was not linked to any function at all and if a function with the default name for that event existed in the script, that perhaps linking it automatically might not be a bad thing? Hell, it could even be added to the massive conglomeration of user preferences. :P

With this route you would still be able to manually enter a custom event handler name..it would just make it simpler if you were copy/pasting an event handler from one room to another.

IMO this would actually be somewhat comparable to the refactoring done in Visual Studio when you change an event handler's name. Clearly not entirely the same, but the same basic principle applies I think.

TomatoesInTheHead

Quote from: monkey_05_06 on Fri 08/04/2011 19:15:24
Khris, I think you misunderstood what I was suggesting. I wasn't talking about "fixed" linkage at all.
But I was :P

monkey0506


SMF spam blocked by CleanTalk