id Tech 4 (Doom3/Prey/Q4) > id Tech 4 Engine Coding

Getting var values from GUis?

(1/2) > >>

argoon:
Hello guys i know that i can set a variable value in a GUI from the engine code using for example somegui->SetStateInt("varName"); and it works fine, but i can't seem to do the inverse, get a value from a gui variable to the game code, i tried using the somegui->GetStateInt("varName"); but it returns zero every time, no matter to what value i set the GUI variable.

what i'm trying to do is create a grid based inventory system, and when i click in a "slot" i tell the c++ code what slot i interacted with.

Phrozo:
If you can't get the value how do you know you are actually setting it? Neither get or set state functions will inform you if are trying to read or write to a variable that can't be found or doesn't exist. Are you sure your variable can be found?

bitterman:
AFAIK this works like entity -> somegui -> parm. Then parm is for entity, not for gui itself (not sure about pda gui, perhaps the player is that entity).

argoon:

--- Quote from: Phrozo on September 28, 2017, 11:14:31 PM ---If you can't get the value how do you know you are actually setting it? Neither get or set state functions will inform you if are trying to read or write to a variable that can't be found or doesn't exist. Are you sure your variable can be found?

--- End quote ---

Hello Phrozo thanks for the reply,  I'm really not sure of anything, I'm still learning this stuff, because gui scripting tutorials are so scarse, I'm learning by trial and error, the only thing I'm sure of, is that when inspecting the gui in the visual studio watch window, I see that at lest the variable name I wrote in the gui desktop is there.

In the case of set, at lest for variables using "gui::varname" I know I'm setting the values from the c++ side  because they work, for other vars I never really tried, I've used namedEvents for the most part,  never tried to "get" a variable value back from the gui.

I also see that Id almost never used GetStateInt or others like it, so perhaps I'm just not thinking this in the right way, but for now I can't see how I could make what I'm trying to make without retrieving a var value from the gui.

Tell me, what would you do, if you add a inventory system where you have a grid based look and you assign different items to each slot (this part already works fine),  the "grid" in the c++ side is just a array of structs, with info like, slot ID, what item is in what slot, a icon path, a item counter per slot, etc, ( I use namedEvents and gui::varname,  to assign the right info to the right "slot"  in the gui file), but then you wanted to have the ability to click in a particular slot (onAction) and have that affect the right array index in the c++ side?

I know I can use set "some cmd name", by using the "handle single gui cmds" function from the player.cpp, like id did but for that, I think I need to do different cmd's to every item in the inventory, if they happen to be in different slots, for example, if I wanted to remove a key from slot 1 in the inventory,  I would need to do,  a remove key1 function,  do another function to remove key2 from slot 2, etc, instead of the a single -  set "removeItem"  function and have that remove the right item from the right gui slot and the right array index. Why I think so?  Because afaik there's no way to tell the c++ code in what window a particular onAction was triggered without using variables ?

Again I may be thinking all this wrong (most likely) and there's a simple way to do that I'm just ignorant about.


--- Quote from: bitterman on September 29, 2017, 03:22:09 AM ---AFAIK this works like entity -> somegui -> parm. Then parm is for entity, not for gui itself (not sure about pda gui, perhaps the player is that entity).

--- End quote ---

That is right and for the pda gui the player is indeed the entity, the pda gui is called from the player def file, still don't know how this can help me, do I need to define the var with gui::varname for "get" like I do for set ? Not near my pc so can't test.

bitterman:
Well, we can easy get/set entity's keys.
Is it necessary to store info about ltem location in gui parm?

Navigation

[0] Message Index

[#] Next page

Go to full version