start screen object buttons don't work

Started by octochan, Fri 03/02/2012 09:16:23

Previous topic - Next topic

octochan

I made a start screen as a separate room with "New Game", "Load Game", "Help" and "Quit" objects for buttons, but even though I set things for them to do on AnyClick, nothing happens.

I know the manual says to do the same thing with hotspots, does it not work with objects?

Also, then it says to move the player into the room where the game begins. Does that mean I have to set my character as not visible until I use the New Game button to move him into that room?

So far I've tried :

function New_AnyClick() {
cEgo.ChangeRoom(1); }

function New_AnyClick() {
player.ChangeRoom(1); }

function New_AnyClick() {
ChangeRoom (1); }

function New_AnyClick() {
NewRoom (1); }

The first two don't do anything, the last two just don't compile.

Help please?

cat

Is the event handler correctly connected with the object? Please do the following:
Open the room with the button object, select the object, in the properties window switch to the event tab. Verify the text in the field next to "Any click".

Are you sure that room 1 is the correct room where you want to change?

octochan

Yes, that's how I add all my functions. I've never scripted before, so it's extremely difficult for me to know how to add any script in a way I'm sure will work, so I use the AGS defaults as much as possible. Even then, it doesn't always work.   ::)

Akatosh

Did you make sure the cursor mode isn't set to Walk? I haven't tangled with AGS in years, but I seem to recall that the AnyClick event doesn't actually fire on any click.

That aside, I see no reason the second one shouldn't work.

octochan

Yes, the default cursor mode is walk. How do I change that to something else? I tried changing the StandardMode to False and setting the pointer cursor StandardMode to True, but the cursor still comes up as walk when it loads.

Akatosh

#5
Pointer is actually another special case, if I recall correctly. What you could do instead is insert something like

Code: ags

mouse.Mode = eModeInteract;


into the room script. Right-click on the room, select "Edit Room", switch to the "Events" pane, select "Enters room before fade-in" (or after fade-in, doesn't really matter), click on the little button. You should be greeted with a window containing a function called room_Load(); paste the above into that function and save. That should be it.

(If you want, you can make the Interact cursor temporarily look like the pointer; just add an appropiate line after setting the mouse mode. If you do, remember to change it back before the player leaves the room!)

monkey0506

Hold up everybody...

Akatosh is back?!? :o

[/off-topic]

The AGS engine doesn't like to let you disable eModeWalkto, but eModeWalkto doesn't fire any events other than on_mouse_click and GUI event handlers...and on_event...and so forth.

As Akatosh said, changing to eModeInteract should work.

octochan

#7
Coolness, I didn't know I was talking to a veteran!

Yes, everything works now. Thanks for the help!

One more question, what is the difference between player and character in the scripting, and is there a list somewhere I can see what functions and properties I can assign to the player?

Thanks again!

oooh, I just noticed your tip about the temporary pointer thing. thanks a lot!

monkey0506

player is just a pointer to an AGS Character (Character*) that always represents the current player character. This saves you from having to do something like character[GetPlayerCharacter()].Whatever().

By contrast, character is a global array of Character*s that allows you to access any Character by their ID. You would typically access specific characters by their script name, cEgo.Whatever(), cNPC.Whatever(), etc. If you need to do something to every character though, you would typically do that by looping through all of the characters like this:

Code: ags
int i = 0;
while (i < Game.CharacterCount)
{
  character[i].Whatever();
  i++;
}


For the record, there is no Character.Whatever function, but you could define one as an extender method if you wanted to. :P

As for a list of the available functions, see Character functions and properties in the manual. ;)

SMF spam blocked by CleanTalk