i am programing my game, allmost is working but i have a great problem...
when you make clic in hotspot the dialog start correctly, then, when you have to use an object in the inventary the dialog for the action start correctly, but the something its working very bad, when you make clic in hotspot allways its shoot the dialog that de caracter animated will talk without using none object
my code:
// main global script file
//--------------------------------------------------------------------------------------------------------------
// Largo's Savegames with Screenshots
//--------------------------------------------------------------------------------------------------------------
// Definitions
// Define screenshot width
#define SL_WIDTH 320
// Define screenshot height
#define SL_HEIGHT 240
// Define default screenshot
#define SL_EMPTY_SPRITE 2
// Variables
String text; // Stores the typed text
int saveslot = 0; // Stores the selected savegame slot
int totalsaves = 0; // Stores the total number of savegames
DynamicSprite *screenshot; // Stores the screenshot
// Functions
function sl_save() {
Wait(1);
screenshot = DynamicSprite.CreateFromScreenShot(SL_WIDTH, SL_HEIGHT); // Create screenshot of current game
if (screenshot != null) {
btnSaveScreen.NormalGraphic = screenshot.Graphic; // Display current screenshot
}
txtSaveName.Text = ""; // Clear Text box
lstSaveGames.FillSaveGameList(); // Fill List Box with saved games
lstSaveGames.SelectedIndex = -1; // Deselect savegame slots
totalsaves = lstSaveGames.ItemCount; // Count how many saved games there are
gSave.Visible = true; // Opens the save GUI
gSave.Centre(); // Centres the save GUI
mouse.Mode = eModePointer; // Set the pointer cursor
}
function sl_load() {
lstLoadGames.FillSaveGameList(); // Fill List Box with saved games
lstLoadGames.SelectedIndex = -1; // Deselect savegame slots
totalsaves = lstLoadGames.ItemCount; // Count how many saved games there are
gLoad.Visible = true; // Opens the load GUI
gLoad.Centre(); // Centres the load GUI
mouse.Mode = eModePointer; // Set the pointer cursor
}
//--------------------------------------------------------------------------------------------------------------
#sectionstart game_start // DO NOT EDIT OR REMOVE THIS LINE
function game_start() { // called when the game starts, before the first room is loaded
game.screenshot_width = 640;
game.screenshot_height = 480;
}
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
{ // put anything you want to happen every game cycle in here
if (gInventory.Visible == true)
{
if (mouse.x > 210 && mouse.x < 810 && mouse.y > 160 && mouse.y < 560)
{
if (mouse.IsButtonDown(eMouseRight))
{
gInventory.Visible = false;
}
}
}
}
#sectionstart on_key_press // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(eKeyCode keycode) { // called when a key is pressed. keycode holds the key's ASCII code
if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
if (keycode == 17) QuitGame(1); // Ctrl-Q
if (keycode == 363) sl_save(); // F5
if (keycode == 365) sl_load(); // F7
if (keycode == 367) RestartGame(); // F9
if (keycode == 434) SaveScreenShot("screenshot.bmp"); // F12
if (keycode == 19) Debug(0,0); // Ctrl-S, give all inventory
if (keycode == 22) Debug(1,0); // Ctrl-V, version
if (keycode == 1) Debug(2,0); // Ctrl-A, show walkable areas
if (keycode == 24) Debug(3,0); // Ctrl-X, teleport to room
}
#sectionstart on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) { // called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1)
{ // Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button == eMouseLeft)
{
if (gInventory.Visible == false) //If the inventory window is closed
{
if ((GetLocationType(mouse.x, mouse.y) == eLocationNothing) && (GetWalkableAreaAt(mouse.x,mouse.y) != 0))
{
ProcessClick(mouse.x,mouse.y, eModeWalkto); //Clicked on JUST a walkable area
}
else
{
if(player.ActiveInventory == null)
{
ProcessClick(mouse.x,mouse.y, eModeInteract); //If we've clicked on a hotspot or object or character etc.
}
else
{
ProcessClick(mouse.x,mouse.y, eModeUseinv); //If we've used the inventory on a hotspot or object or character etc.
}
}
}
}
//ProcessClick(mouse.x,mouse.y, mouse.Mode);
else //if (mouse.IsButtonDown(eMouseRight))// right-click, so cycle cursor
{
//mouse.SelectNextMode();
if (gInventory.Visible == false)
{
gInventory.Visible = true;
mouse.Mode = eModeInteract;
Wait(5);
}
else
{
gInventory.Visible = false;
}
}
}
#sectionstart interface_click // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) { // OBSOLETE, NOT USED IN AGS 2.7 AND LATER VERSIONS
}
#sectionstart unhandled_event
function unhandled_event (int what, int type) {
}
function dialog_request(int param)
{
if (gInventory.Visible == false)
{
gInventory.Visible = true;
mouse.Mode = eModeInteract;
}
else
{
gInventory.Visible = false;
}
}
// Save GUI
function gSave_OnClick(GUI *theGui, MouseButton button) {
lstSaveGames.SelectedIndex = -1; // Deselect savegame slots
}
function btnSaveOK_OnClick(GUIControl *control, MouseButton button) {
if (lstSaveGames.SelectedIndex >= 0) { // If you've selected a savegame slot
saveslot = lstSaveGames.SelectedIndex; // Get the selected savegame
text = txtSaveName.Text; // Get the typed text
if (screenshot != null) {
screenshot.Delete();
btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
gSave.Visible = false;
mouse.Mode = eModeWalkto;
Wait(1);
SaveGameSlot(lstSaveGames.SaveGameSlots[saveslot],text); // Overwrites the selected game
}
else { // Save the game in a new slot
if (totalsaves < 50) { // If the savegame limit is not reached (50)
text = txtSaveName.Text; // Get the typed text
if (text == "") {
Display("Please enter a name for your savegame."); // If player didn't enter a name, tell them
}
else { // Proceed as usual
if (screenshot != null) {
screenshot.Delete();
btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
gSave.Visible = false;
mouse.Mode = eModeWalkto;
Wait(1);
SaveGameSlot(totalsaves+1,text); // Saves game (text as description)
}
}
else Display("All save slots are full. Please overwrite a previous save.");
}
}
function btnSaveCancel_OnClick(GUIControl *control, MouseButton button) {
gSave.Visible = false;
mouse.Mode = eModeWalkto;
if (screenshot != null) {
screenshot.Delete();
btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
}
function lstSaveGames_OnSelectionChange(GUIControl *control) {
// Updates textbox contents when selecting an existing slot
txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}
// Load GUI
function gLoad_OnClick(GUI *theGui, MouseButton button) {
lstLoadGames.SelectedIndex = -1; // Deselect savegame slots
}
function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
if (lstLoadGames.SelectedIndex >= 0) {
saveslot = lstLoadGames.SelectedIndex; // Gets the selected slot
gLoad.Visible = false;
mouse.Mode = eModeWalkto;
if (screenshot != null) {
screenshot.Delete();
btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]); // Restores the selected slot
}
else if (totalsaves>0) Display("Please select a savegame.");
else Display("There are no savegames yet!");
}
function btnDelete_OnClick(GUIControl *control, MouseButton button) {
if (lstLoadGames.SelectedIndex > -1) { // You've selected a saveslot
saveslot = lstLoadGames.SelectedIndex; // Gets the selected slot
DeleteSaveSlot(savegameindex[saveslot]); // Deletes the savegame
if (screenshot != null) {
screenshot.Delete();
btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
lstLoadGames.FillSaveGameList(); // Fill List Box with saved games
lstLoadGames.SelectedIndex = -1; // Deselect savegame slots
totalsaves = lstLoadGames.ItemCount;
}
else Display("Select a savegame to delete.");
}
function btnLoadCancel_OnClick(GUIControl *control, MouseButton button) {
gLoad.Visible = false;
mouse.Mode = eModeWalkto;
if (screenshot != null) {
screenshot.Delete();
btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE; // Resets the screenshot
}
}
function lstLoadGames_OnSelectionChange(GUIControl *control) {
// Updates screenshot display when selecting a different slot
saveslot = lstLoadGames.SelectedIndex; // Gets the selected slot
screenshot = DynamicSprite.CreateFromSaveGame(lstLoadGames.SaveGameSlots[saveslot], SL_WIDTH, SL_HEIGHT);
if (screenshot != null) {
btnLoadScreen.NormalGraphic = screenshot.Graphic; // Updates the screenshot
}
}
ACTION HOTSPOT EXAMPLE:
function hplanta_Interact()
{
player.Walk(77, 501, eBlock, eWalkableAreas);
player.Say ("Esa planta no me interesa.");
}
function harboles_Interact()
{
player.Say ("Nunca me gustaron los árboles y mucho menos estos.");
}
function harboles_UseInv()
{
player.Say ("Eso no tiene sentido.");
}
function hcamino_WalkOn()
{
player.ChangeRoom(2, 152, 613);
}
function hcamino_Interact()
{
player.Walk (965, 462, eBlock, eWalkableAreas);
player.ChangeRoom(2, 152, 613);
}
Thank!.
I'm not trying to be rude, but seriously, you can't expect anyone to just parse through your entire script to debug it for you. Trim it down to just the line or function that the error is in. :-\
Edit: Also, your title and description of the problem are very vague. I understand you're not a native English speaker, but if we can't understand 1) what's taking place and 2) what you want to be happening then we can't figure out any more than you can what's going wrong.
Yeah, it's hard to make heads or tails of this; I think he is using an object on a hotspot and wants to know how to find out which inventory was used, could this be it?
Mariano:
function harboles_UseInv()
{
if (player.ActiveInventory = iHacha) {
player.Say("...");
}
else player.Say ("Eso no tiene sentido.");
}
ALSO: FIND SOMEBODY WHO SPEAKS ENGLISH AND SPANISH AND GET THEM TO HELP YOU POSTING.
Quote from: Khris on Thu 04/11/2010 09:35:45
ALSO: FIND SOMEBODY WHO SPEAKS ENGLISH AND SPANISH AND GET THEM TO HELP YOU POSTING.
Even though this may well be the case for him/her, is it really necessary to put this in all CAPs? Think before
you post. :P
I have said it to him before but it didn't seem to stick obviously. So I put it in all caps and bold in the vain hope it'll produce something this time.
It probably won't and I don't really care, but I did think before posting.
You on the other hand seem to be negatively biased when evaluating the helpfulness or tone of my posts. Maybe that's worth a thought. Just saying.