when I tell my player to pick up (or interact with) objects, I want him to go over to that object first, but I don't want that to initiate an animation sequence of him going there. in other words, I want to have the option of "changing my mind" while the character is still walking over to the object.
how can I acomplish that..?
thanks.
It requires a fair bit of scripting. Here's an example for the interact mode:
// main global script file
int interactwith=-1; // declare interact queue
function on_mouse_click(int button) {
interactwith = -1; // stop queued interact commands (put before ProcessClick)
//...
}
export interactwith; // export interact queue for use in rooms
// Main header script
import int interactwith; // import interact queue for use in rooms
// room script file
#define ID_BLUECUP 201 // define object 1 id for interact queue
function room_a() {
// script for room: Repeatedly execute
//...
if (character[GetPlayerCharacter()].walking == 0) { // if player has stopped walking
if (interactwith != -1) { // if he was set to interact with something
if (interactwith == ID_BLUECUP) { // if he was to interact with object 1 (blue cup)
ObjectOff(1); // remove object 1 from room
AddInventory(22); // add inventory item for object 1
}
// ...more objects here
interactwith = -1; // reset interact queue
}
}
//...
}
function object1_a() {
// script for object1: Interact with object
MoveCharacter(GetPlayerCharacter(), GetObjectX(1), GetObjectY(1)); // start moving player character to object
interactwith = ID_BLUECUP; // put object 1 in interact queue
}
The use of the ID_BLUECUP definitions is because characters are handled the same way in the global script, so if you were to put the object number in the interact queue (for example 1), it could also mean character 1 (or hotspot 1 in room scripts).
That's why I use IDs 100-199 for hotspots, IDs 200-299 for objects and IDs 300-399 for characters. These numbers are arbitrary, so you could just use higher numbers if you have a lot of characters. It's only important that all characters/objects/hotspots have unique IDs for the queues.
First of all, thanks alot!
secondly, I need a clear-up about the room_a() function; should I copy it to the global script in the repeatedly section? I'm not quite sure where to stick it..
No problem, I'm glad to help. The script is off the top of my head, so report back if something doesn't work like you want.
Quotesecondly, I need a clear-up about the room_a() function; should I copy it to the global script in the repeatedly section? I'm not quite sure where to stick it..
You have to create the function from the room interaction button (labelled "i"). Double-click "Repeatedly execute" and choose "Run script". Put the script in there.
Edit:
I forgot to mention, you also have to empty the queues when the player leaves the room (when walking onto a region for example), so the interactions don't get triggered in the new room:
function on_event (int event, int data) {
//...
if (event == LEAVE_ROOM) {
interactwith = -1; // stop queued interact commands
}
//...
}