Tinting an object as the mouse moves over it?

Started by Iphigenia, Mon 29/06/2009 18:56:21

Previous topic - Next topic

Iphigenia

I'm a couple of days into my first AGS project and struggling to work out how to get the mouse to tint objects momentarily as it passes over them.

I've done a search, found, and attempted to utilise the code in this thread:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36056.0

but can't seem to get it to work. I keep getting a  'cannot assign intial value to global value pointer'.

If someone can explain the steps in a little more detail, I'd greatly appreciate it. I'm still not sure I've created the custom 'tint' property in the right place or fully understood how to create/position a rep_ex.

Thanks in advance.

Khris

rep_ex is short for repeatedly_execute. This is a function inside the global script.

Put the int line above the function, the rest of the code inside it, between "function repeatedly_execute() {" and "}".

GuyAwesome

#2
Is there a particular line of script that goes with that error? If so, that might help us narrow down why you're getting it...

Custom Properties are touched on in the manual, but step-by-step the process is:
- In the editor, open a room that contains objects you want to have tint. Make sure you're editing the Objects :)
- In the Object Properties panel ('Description', 'Image', 'UseRoomAreaLighting', etc.) select 'Properties' (at the bottom) and press the '...' button.
- If you haven't already created the 'Tint' property, click 'Edit Schema' in the window that appears, then right-click in the new window and select 'Add new property'. Name it 'Tint', add a description if you want, make it 'boolean' (the default type), with a default value of '0' (for false).
- Go through all the Objects you want to tint, and change their property value to 'True'.

(NOTE: If most objects should get tinted, make the default value '1' for true instead, and manually set it to False  for the ones you don't want to tint. If you want ALL objects to tint on mouseover, you can probably skip the Custom Property stage altogether...)

Hope that's a little clearer for you...

rep_ex means repeatedly_execute (as KhrisMUC beat me to saying :)), and already exists in the global script - no need for you to create it.

EDIT: One thing I notice about the code in the other thread, I don't think it'll allow you to tint object[0] (because 0 is used for the 'null' / no object setting). Setting tobj to -1 instead should fix that. You might have to declare tobj as -1 as well (or it won't work if object[0] is the first object you mouseover).
Code: ags

int troom, tobj = -1;

// and later, in the if (o == null) condition
troom = 0; tobj = -1;


Iphigenia

Thanks for the advice. I think I'm nearly there. I've created my custom object property and inserted the code within the GlobalScript. Now I just need to work-out why I'm getting a 'Error running function repeatedly_execute: Error null pointer referenced' message. It's linked to the line:

if (o.GetProperty("tint")) {

GuyAwesome

What exactly is in your repeatedly_execute?

What that error usually means, is you're trying to use a pointer that isn't currently pointing anywhere - in this case, that probably means that there's no Object under the mouse (and so 'o' is an invalid pointer). Khris's code accounts for that (the else after if (o == null)), so it's most likely just a misplaced brace somewhere in the copy/pasting.

Iphigenia

Brilliant. The added brace above else and declaring tobj as -1 has done the trick!  Many thanks for the help.

SMF spam blocked by CleanTalk