Aller au contenu

Photo

[Script Help] ShowPopup


  • Veuillez vous connecter pour répondre
32 réponses à ce sujet

#1
NewYears1978

NewYears1978
  • Members
  • 894 messages
I was trying ot make a Popup appear when clicking on an item (that has story elements in it or whatnot)..

I found on the wiki ShoePopup :http://social.bioware.com/wiki/datoolset/index.php/ShowPopup

void ShowPopup(

int nMessageStrRef,
int nPopupType,
object oOwner = OBJECT_INVALID,
int bShowInputField = FALSE,
int nDefaultInputStrRef = 0
);


The problem I am having is that I do not know C++ or any scripting language so sometimes I am confused by the use of these.

Any help in understanding how to read the above and know what values to put would be apprecated.  Sometimes I can figure them out.

I get really confused when they have an equals sign with a value...not sure what that means.  Such as

"object oOwner = OBJECT_INVALID"

I know this is asking me for the owner of the popup, but not sure what value I put here...  do I just put "OBJECT_SELF" or should I be putting like   "oJoeblow = OBJECT_INVALID" 

Learning slowly...I really need to learn C++ I think..which I would love to do..hard when you work 2 jobs, and have 3 kids =)

#2
weriKK

weriKK
  • Members
  • 106 messages
This really means that the ShowPopup() function can have a maximum of 5 parameters, from which the last three are optional. These optional parameters( oOwner, bShowInputField and nDefaultInputStrRef) have default values ( OBJECT_SELF, FALSE and 0 respectively).



If you skip these parameters while using this function, they will be automatically equal to their default values:




ShowPopup( nMessageStrRef, nPopupType); is a perfectly valid way to call this function.

Inn this case, oOwner will be equal to OBJECT_INVALID, bShowInputField will be FALSE and nDefaultInputStrRef will be zero.

Modifié par weriKK, 21 novembre 2009 - 09:58 .


#3
NewYears1978

NewYears1978
  • Members
  • 894 messages
Ahh..that explains a little ..I was always confused there.



I also think that means this command may not be for what I am trying to do...figuring out how to do that is another thing altogether. I was wanting sorta like a codex entry type thing...not necessarily having to be an added item in the codex..but more something that pops up whenever you click this item..



Looking in the 2da files and such but havn't found what might do this yet (being stupid doesn't help)

#4
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Most of the function topics in the wiki are still very raw. It isn't clear at all to me reading this topic what the purpose of giving the popup an owner would do, but apparantly specifying no owner is acceptable since that's the default value. I'd use OBJECT_INVALID there although it interests me enough so I would try putting some valid object there just to see what happens. The rest of the parameters seem very clear to me is the oOwner one the only one that was confusing you?

From your description it sounds like this is exactly what you want.

Modifié par Axe_Murderer, 21 novembre 2009 - 10:12 .


#5
weriKK

weriKK
  • Members
  • 106 messages
The owner is needed so later on, when you handle the popup window event you can see who caused it to appear.

It is always needed, most probably if the value is set to OBJECT_INVALID when the function is checking the parameters, it will set it to the main controlled creature automatically. This way you can omit an extra parameter and save time in case the owner is the currently controlled creature which it is most of the time I'd believe.

Modifié par weriKK, 21 novembre 2009 - 10:20 .


#6
NewYears1978

NewYears1978
  • Members
  • 894 messages
Well, everything confuses me when looking at the examples because I don't know what it all means yet...

void ShowPopup(
int nMessageStrRef,
int nPopupType,
object oOwner = OBJECT_INVALID,
int bShowInputField = FALSE,
int nDefaultInputStrRef = 0
);


For instance it says "object oOwner = OBJECT_INVALID"  

I know this means that I am to define the object Owner but what I don't know is then why it has the = OBJECT_INVALID and what that even means..

Then on like, int bShowInputField, I can conclude that this is an int value, that it's asking if it should show an input field then  = FALSE...what I don't know is what I actually input here, do I just put "TRUE" or "FALSE" ??


Then on top of all that I don't know what

int nMessageStrRef,
int nPopupType,

is asking.  I know the first is a int reference to the message string..but I dont know if I put my actual message there?  Or is it asking me to reference my message I have somewhere else..

Then on the second...I know it's asking me for the popuptype..but I dont know what values go here..what are the popup types..where do I even find them?  I looked in the popup.xls file and there's not much in there at all..

#7
NewYears1978

NewYears1978
  • Members
  • 894 messages
You two guys are so smart..I wish I knew more about this stuff...at least I am trying to learn. I almost have my little test mod complete.

#8
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Ah that makes sense. I can think of situations where you would want to pop up a message and just have the user dismiss it and therefore not need to know about any owner. In fact, it sounds like that's what NewYears is going for to me.


#9
NewYears1978

NewYears1978
  • Members
  • 894 messages
Yep, that is what Im going for...still trying to figure out how though... =)

Based off what she said I have left those certain values default, now using only:

ShowPopup( nMessageStrRef, nPopupType);

Problem..I don't know what these are.  Not sure what popuptype is as stated earlier..and the nMessageStrRef not sure if I can literally type my message here? Or have to call it from somewhere else..I've tried some things but always get errors which means I'm doing it wrong :)

Modifié par NewYears1978, 21 novembre 2009 - 10:50 .


#10
NewYears1978

NewYears1978
  • Members
  • 894 messages
The only way I could get the script to compile was using this:



ShowPopup( 1, 1);



But..all this was, was an empty box that had a yes or no option.. =)

#11
eiham

eiham
  • Members
  • 38 messages
nMessageStrRef is a string from the talk table (see; String Editor)

nPopupType: if I had to guess it's one of the following constants - UI_MESSAGE_TYPE_PORTRAIT, UI_MESSAGE_TYPE_PORTRAIT_FOLLOWER, UI_MESSAGE_TYPE_SPECIAL

#12
eiham

eiham
  • Members
  • 38 messages
Or wait, maybe not. just try 0 for the PopupType and see what happens :)

#13
NewYears1978

NewYears1978
  • Members
  • 894 messages
String Tables..that's something I knew nothing about..which would explain why I was confused..so that's something to look into...or learn...if I can find it.

#14
Phaenan

Phaenan
  • Members
  • 315 messages
And here I was so sure there would be now way of invoking that dog name popup. Thanks a bunch for bringing this ShowPopup() to my attention, I'm not sure yet if I'll manage to get some user typed input, but I'll certainly try ! I really could use that in my stuff.  B)


ShowPopup( nMessageStrRef, nPopupType);

Let's see. On the top of my head :
nMessageStrRef : a Strref. See below.
nPopupType : an ID number from the ID column in the popups 2DA


and the nMessageStrRef not sure if I can literally type my message here?

That's a string reference, basically an integer identifiant linked to a talktable entry.
You should check on the Wiki page AND04 wrote, it will give you pointers. :o

Modifié par Phaenan, 21 novembre 2009 - 11:11 .


#15
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
You can't put a literal string there no. You have to create a string in the tlk table. When you do that, and be aware there are apparantly some bugs with that process, you'll get a strref ID number for the text you enter. That's what you use in the function call. The popup type selects what style of popup box you want. There are several styles available. Popups.2da lists them. The ID number from popups.2da corresponding to the style you want goes in there. So your function call will look something like:

ShowPopup( 18307465, 3 );

with different numbers of course.


#16
NewYears1978

NewYears1978
  • Members
  • 894 messages
I figured this out before reading this..now just have to get it working..in the process I lost m custom morphed head...



I had madea custom morphed head..worked in my game..but it just vanished now for some reason...do you have to do something special to use custom morphs? It was listed in the games resources til I exported again then suddenly it was gone....Ugh..

#17
Phaenan

Phaenan
  • Members
  • 315 messages
It actually worked. :D

So while I have the source under my eyes, here goes.
 Hopes this helps !




First, the toolset strings editor can be used to create the required strref. That where you'll get a strref for the string you created :
- http://img504.images...tringeditor.png
You may have to export the talktable :
- http://img695.images...ringeditor2.png

Now, you have to invoke the popup from somewhere in your code. For instance, in mine :
        Phae_print("Invoking popup");
        ShowPopup(1239822518, 2, Phae_forge_getAnvil(), TRUE);
Breakdown of those parameters :
- The 1239822518 is the strref from the string editor, shown on the previous screencaps
- The Phae_forge_getAnvil() is just a function I use to retrieve one placeable object neaby. This object will receive the "popup used" event. This type 2 popup is the dog naming popup.
- The last TRUE parameter allows the user to enter text. Which is better for this type of popup.


Once that you have you popup invoking code, you need to go into the script handling your object events if you want to retrieve the player response to your popup. In my case it was a placeable. That script is the one set in the object inspector when editing the object.
An example of such a script :
void main() {
    event eCurrent = GetCurrentEvent();
    int iEventType = GetEventType(eCurrent);


    switch(iEventType) {
        /* irrelevant events removed for lisibility sake */
        
        // Sent when the player answer to a name giving popup
        case EVENT_TYPE_POPUP_RESULT: {
            Phae_forge_saveConsoleName(GetEventString(eCurrent, 0));
            break;
        }


        default: {
            // Fall through to rules_core
            HandleEvent(eCurrent, RESOURCE_SCRIPT_PLACEABLE_CORE);

            break;
        }
    }
}

The important part is here :
        case EVENT_TYPE_POPUP_RESULT: {

            Phae_forge_saveConsoleName(GetEventString(eCurrent, 0));

            break;

        }
The function GetEventString(eCurrent, 0) returns the text typed by the player into the popup window. You can retrieve to do whatever you want.
With other type of popups, for instance the type 1 (one question mark, two yes/no button) you can retrieve the pressed button with : GetEventInteger(GetCurrentEvent(), 1)

And that's it. :blush:

Modifié par Phaenan, 22 novembre 2009 - 12:47 .


#18
NewYears1978

NewYears1978
  • Members
  • 894 messages
I put my code in there "ShowPopup( 1894414771, 3 );" The popup comes up but it's still blank..my stringtable looks like this:



Posted Image



Am I setting one of the values wrong?

#19
NewYears1978

NewYears1978
  • Members
  • 894 messages
Ah...I was exporting string table not talk table...not sure whats the difference?

And this worked =)  Thank you everyone..now if I can figure out my morph problem.

Modifié par NewYears1978, 22 novembre 2009 - 12:15 .


#20
Phaenan

Phaenan
  • Members
  • 315 messages
Not sure, actually. Didn't dabble with that either, yet. :o

#21
NewYears1978

NewYears1978
  • Members
  • 894 messages
This worked fine but the box is rather small..and there is no scrollbar when you have more than fits in the box (although you can still scroll)

I was hoping for more of a menu type (codex entry) type thing..but I havn'tfound a way to do this..

#22
Phaenan

Phaenan
  • Members
  • 315 messages
You mean, found a way to add a codex entry ?

It's rather simple, you just have to create a plot resource and set its type to "Codex". You create a main flag within that plot and place the text you want under journal, include the plt_yourplotres in a script and set the flag in order to add the codex entry to the player's codex :

WR_SetPlotFlag(PLT_YOURPLOTRES, YOURFLAGNAME, TRUE);

#23
NewYears1978

NewYears1978
  • Members
  • 894 messages
Hrm..seeind as how I made my first plot/flag last night and it worked..this shouldn't be any harder..



Actually I think the way I did it worked fairly well..I was going to write backstory and some more stuff for my little NPC but I suck at writing..and plus my mod is a test mod more thana story etc..so I don't really need a full codex entry...so I am going to leave it how I have it.



BUT now that I know what you've said.>I have that for future referene, thanks again :)

#24
NewYears1978

NewYears1978
  • Members
  • 894 messages
Hey I tried this and it didn't seem to work.

my plots name is "JLP_CONVCMP_HOARDER" and I made the flag called "JLP_JOURNAL_HOARDER" then I put

WR_SetPlotFlag(jlp_convcmp_hoarder, jlp_journal_hoarder, TRUE);

The only thing I didn't get was you said set the plot to "Codex" which I don't see any entry in plot setup for codex?

Modifié par NewYears1978, 23 novembre 2009 - 03:14 .


#25
Phaenan

Phaenan
  • Members
  • 315 messages
Took me some time to figure it out as well 'cause I didn't always had my object inspector in sight back then. Basically you'll find the "plot type" (or something similar) in the object inspector when your plot resource is selected in the palette.

Modifié par Phaenan, 23 novembre 2009 - 03:26 .