New inventory item flashing

Started by James Kay, Thu 11/12/2003 15:08:25

Previous topic - Next topic

James Kay

I did a search but came up with nothing specific. If there is a thread or tutorial on this already, slap me in the face and post me the URL with deserved scorn, please.  :)

So I have my own inventory GUI(1) which is all working and lovely. And I want to player to be shown any new ovject flashing on and off in this GUI.

So I have a script:
    GUIOn(1);
    UpdateInventory();
    AddInventory(3);
    Wait(10);
    LoseInventory(3);
    Wait(10);
    ---repeated---
    GUIOff(1);


I read in the manuals that the GUI doesn't get updated until the script has run its course, so I've included the UpdateInventory(); command. I even tried it after every AddInventory and LoseInventory command, but guess what: nothing.
The game waits because of all the Wait(x); commands but the inventory window does not show.
This is both for objects placed in the room as hotspots (for really small objects - don't want to make this into a pixelhunting game). But to no avail.

Any ideas on what I am doing wrong (other than trying to write scripts without being a programmer) ?

Scorpiorus

#1
Hello  James Kay,

Hmm, you add another inventory item, right? But what if you have one already? Add(Lose)Inventory() function actually adds(takes away) one certain item altering thier amount. So, if the player has 1 item#3 then the AddInvnetory() adds another one - so it has 2 now. And Lose Inventory substracts and you have 1 again and thereby the player doesn't lose the item.

Try that:

GUIOn(1);
---- repeatedly in while() -----
LoseInventory(3);
UpdateInventory();
Wait(10);

AddInventory(3);
UpdateInventory();
Wait(10);
------------------------------------
GUIOff(1);

EDIT: btw, both LoseInventory() and AddInventory update the inv window by themselves, therefore you don't even need to call UpdateInventory() one. ;)



~Cheers

James Kay

Nope, that's not it. I don't use the "AddInventory" scriptline until after I open the GUI. But just in case I tried adding an extra LoseInventory line. To no avail. The GUI still doesn't show up at all.   :'(

Scorpiorus

But didn't you check start-with-this-inv-item option?

If it doesn't help put a display:

GUIOn(1);
---- repeatedly in while() -----
LoseInventory(3);
Display("item (3) amount: %d", character[GetPlayerCharacter()].inv[3]);
Wait(10);

AddInventory(3);
Display("item (3) amount: %d", character[GetPlayerCharacter()].inv[3]);
Wait(10);
------------------------------------
GUIOff(1);

it should display 0 then 1, again 0 etc... :P

James Kay

"start-with-this-inv-item" is not ticked.

I added the code: it does indeed say 0 - 1 (I repeated it three times to be certain, and it does say 0 - 1 - 0 - 1 - 0 -  1, so that doesn't seem to be the problem.

:-[

Scummbuddy

I dont have the manual with me where I am, but what about changing the inv image with SetInvItemPic or something like that. (You could have it flash that way with like a faded pic of it, to a bright version of it.)

If anyone wants to jump in here and correct me.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Scorpiorus

Yeah, Scummbuddy is right - this should work better because I've just checked and found out that AddInventory function makes an item to be the last one in the inv. window. :P and that might be the reason ;)

~Cheers

James Kay

Ooh, that would be cool, to have an alterate image of the same object flash on and off.
But as it stands I can't even get the Inventory GUI to appear yet, let alone switch image (or switch them on or off). This is odd as I use the GUIOff and GUIOn messages effectively when writing "look at" scripts for inventory items (otherwise the text appears offset to the character for some reason).


Scummbuddy

do you have it set as a popup modal?
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Scorpiorus

QuoteBut as it stands I can't even get the Inventory GUI to appear yet
this one makes me to re-read you original question and I have realized (just now :)) the problem in showing that GUI.

ok, so you have an object, then you pick it up and then a GUI is displayed and you want an inv item flashing in that inv window, yes? :P

James Kay

Correctomundo.
I have a custom INVENTORY GUI, (1) as it happens, and it's a pop-up type. It works fine everywhere else in the game, though I had a problem with text alignment running the DisplaySpeech script for look-at-inventory actions, so I added a GUIOff(1); before and GUIOn(1); after the DisplaySpeech line and that solved the problem nicely.
But indeed, I want the player to click on an item or hotspot, bring up the INVENTORY GUI (not happening), flash the item on and off a few times (might be happening but as the GUI is not visible I can't confirm this), and switch off the GUI again (again, impossible because it doesn't show up in the first place).

Scummbuddy

are you using braces where appropriate?  we'll need to see your code for the room
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

James Kay

Yeah, the braces seem in place.
I don't have the game here (at work) but I'll post it this weekend. Cheers for the time, guys!

Scorpiorus

btw, what interaction did you use, interact (hotspot/object) or pick up? If it's the last then you need to enable the PickUp cursor mode as well.

as about the interact interaction :) it usually looks like:

// room script file

function hotspot...() {
 // script for hotspot...: Interact hotspot

Display("hotspot interaction is being run!");
GUIOn(1);
 
}

function object...() {
 // script for object...: Interact object

GUIOn(1);
 
}

Also try placing a display message (like I did for the hotspot) then you should see that message during the interaction. If you don't, it means the interaction isn't run at all for some reason.

Alynn

Do you have the When interface Disabled set to GUIs turn off?

If'n I am thinking right, the wait command will disable the gui if that option is set the gui will turn off.

Scorpiorus


James Kay

Quote from: Alynn on Fri 12/12/2003 15:05:33
Do you have the When interface Disabled set to GUIs turn off?

If'n I am thinking right, the wait command will disable the gui if that option is set the gui will turn off.

Eureka! That did the trick. Thanks!!!!!

BUT...now I have to find a way to switch off the GUI(0) icon bar during blocked events. Please tell me there is a simple trick for that!

Alynn

Wellllllll... GUIOff(0).... you probably need to manually do that. and GUIOn(0) to turn them back on.

James Kay

Ahhh....bugger.... so everytime I have a blocked event I need to GUIoff(0); ?
Solved one problem, but created a couple of dozen tiny headaches.

Thanks for all the help. This one I would never have figured out myself!  :-[

Alynn

Well if you dont mind the GUIs just graying out you can always set that option, unless you need that gui to disappear (IE you need to see the whole screen and what not....)

Personally my GUI's just gray out for the most part.

SMF spam blocked by CleanTalk