Hi there. I'm new at AGS. The name's Fenthick and I'm making my first game.
I've been following the webpage's tutorial, and I'm stuck at 3th step. I'm trying to pick up an object from the floor (a key) and add it to the inventory. I named the key object "oKey", and for the inventary object I'm using the default "iKey".
So I added that script to pick the key,
function okey_pickup()
{
oKey.Visible = false;
player.AddInventory(iKey);
GiveScore(5);
}
But it don't really works. I've been hours trying to pick up the stupid key from the floor, but it doesn't moves, and it doesn't appears in my inventory.
Do you know what's up here? Of course, the key is in a walkable zone.
thx for reading, I'll wait for an answer ;)
I think the problem here is that you are using the Pick up -event when you are not in fact using the Pick up cursor. The default "hand" cursor in AGS is the Interact-cursor, which I assume you are using. So instead of making an event for Pick up object, make an event for Interact object and see what happens.
Have you added:
import function okey_pickup();
into your 'Global Script Header' yet?
Please ignore terrorcell's post.
In the event pane of the key object, click "pick up object", then click the ...-button next to it.
This will generate a function named "oKey_PickUp()". Move your code in there.
Capitalization is important, but more important in this case is that the function is properly linked to the pick up key event.
Quote from: Pablo on Thu 10/04/2008 00:42:34
I think the problem here is that you are using the Pick up -event when you are not in fact using the Pick up cursor. The default "hand" cursor in AGS is the Interact-cursor, which I assume you are using. So instead of making an event for Pick up object, make an event for Interact object and see what happens.
100/100. It works with interact.
So, wich is the difference between interact, and pickup...??
PD: I want to make a lucasarts looking game =)
There's not inherent difference, they're just two different cursor modes with two different names. It just depends on what code you add to them. In this case you'd add code for the interact mode as a 'use' (the player might say "I can't use it" for instance) and code to the pickup mode as a 'get' (the player might take the object). Nothing's set in stone though, if you wanted to you could add the pickup code to the look cursor, and the player would take the object when the user looked at it.
There are a couple of cursor modes that are a bit different (like walkto, pointer, wait) but generally speaking the modes are down to how you interpret them.
Oh, and you can disable the modes you don't want to have in your game, and make new modes if you want some extra ones.
wow, thx. my doubt is clear now :D
I know I'm a bit far away from the main subject... :-\ but.. please, onedollar, you said that I can disable the modes I don't want, and add new modes. I've been looking for that option, but I'm not finding it. How can I do it?
Thx for your patience ;D
You're using AGS 3.0 yes?
To add a cursor you right click the mouse cursors tree and choose New Cursor. To remove a cursor permanently (careful, if you've referenced it anywhere in your script you'll probably break your game :)) you right click the cursor and choose Delete This Cursor. To remove a cursor from, say the default right-click cursor cycling thing (the mouse.SelectNextMode(); function) you do mouse.DisableMode(eModeWhatever); and likewise you can re-enable it with mouse.EnableMode(eModeSomething);. You'd probably want to do that kind of setup in the game_start function in the global script, which is called before your first room is loaded.
Now, writing code for when the user clicks on an object with the new mode... your new cursor mode doesn't appear in the list of events (something to be requested perhaps?) so you have to use the 'Any click on object' event and write something like.
function oThing_AnyClick()
{
if (mouse.Mode == eModeNewCursor){
//do something
}
}
Basically when the user clicks (with any cursor) on the object the game checks to see if the mouse's current mode is the New Cursor mode, then runs the stuff inside the if function if it is.