how to use "run dialoge" as a condition?

Started by dikla, Wed 30/06/2004 20:43:12

Previous topic - Next topic

dikla

just like the topic. i want somthing to happen if run dialog is activate (if the diaglog was indeed happened and finished)
but i dont know how to make "run dialog" as a condition.
tx dikla

Skio

You can define a global variable and set it to 1 from within the dialoge ->

set-globalint 12 1   (check the HELP)

Then, in the coditional, all you have to do is to check the variable.
Î'νδρων Επιφανων Πασα Î"η ΤαφοÏ,

dikla

sorry, i just have problem with the global int. i cannot understand it from the turtorial nor the scripting nor the getglobalint. i know that int is a number and string is words but pls show me step by step how do i so this if you dont mind. i'm sure it would help a lot that have problem with it.
txk dikla

Hollister Man

I think the Global Ints list is technically an array with functions to change the contents of the array.

Basically, A global int is a 'container' with an 'address' that can be accessed by using the function GetGlobalInt(X) where x=the container's address, so to speak.Ã,  Ã, Using SetGlobalInt(X, Y), where X is the said 'address' and Y is the number you want GlobalInt(X) to contain.Ã, 

If you want to store the number 40 in the global int number 6, you do this

SetGlobalInt(6, 40);

And now if you want to retrieve it, GetGlobalInt(6) works like a "read only" variable.Ã,  You can type X=GetGlobalInt(6) and then X will contain the number 40.Ã,  But you CAN NOT type GetGlobalInt(6)=4.

In a dialog, it works differently, though, follow the previous instruction.
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

dikla

WHAT IS number 40 and what is number 6? where you get this numbers?
step by step i mean like dectating me what to write and where. if you do this for me, i will understand it. in my case i have a hotspot which any click on it will give the player oranges. but only if he had dialog number 2. how do i write the condiction of the dialog?
if (what?....) { //and tell me what it means
here i know what to do
}
else {
here i know what to do.
}
thats all i need. if you can help me i will be thankful.
dikla

Wolfgang Abenteuer

Okay, I'm not 100% sure what you are trying to do here.Ã,  You say you want to click on a hotspot and have it give the player an item (oranges)?Ã,  But only if the dialogue is active?Ã,  Why would you need a dialogue for that?

As for the SetGlobalInt(6,40) line, the numbers he got off the top of his head, really.Ã,  That command would set the value of GlobalInt #6 to 40.Ã,  There are GlobalInts from 0-499 available, and as far as I know they can be set as high as you want.Ã,  For a simple "switch" to determine if the player should get one thing or should not, you really only need a value of 0 or 1.

So, for example, if you had a dialogue script that said this (and I'm just making this up right now because I'm not sure what it is you're trying to do):

Code: ags
@S
return
@1 //Make oranges available
narrator: You can get oranges now.
set-globalint 0 1
return
@2 //Don't make oranges available yet
narrator: You can't get the oranges yet.
return


Then once the hotspot is clicked on, do this:

Code: ags
if (GetGlobalInt(0) == 1) {
Ã,  //add your inventory code for oranges and whatever else you want to do here
}
else {
Ã,  //you know the rest here already
}


Notice that in the dialogue script, I used set-globalint 0 1, which set GlobalInt #0 to a value of 1.Ã,  Then in the other script, I checked to see if the value of GlobalInt #0 was set to one and run the inventory code for the oranges if it is, or do nothing if it's not.

Is that kind of what you had in mind?

~Wolfgang

Kinoko

Okay, I'm just going to add my personal take on GlobalInts here, in case it helps.

A GlobalInt is what you use when, say, you want a different response for the same action after something has happened.

For example, if you look at a house, the character might say, "What a pretty house". If you break a window, and THEN look at the house, the character might say something different like, "There's a broken window".

In this example, you would use GlobalInts to tell the game what action would make the response change - in this case, the window breaking. You pick a number (any number) for the global int... this is just like a title to tell you which GlobalInt you're using for what. In this case, we'll say the number 1. Then you would make the second number (the number the global int "contains" 0 before the window is broken, and 1 if the window is broken.

So, Global Int number 1 will equal 0 before the broken window, and it will equal 1 when the window is broken.

To use this, you would tell the game when you look at the house, that if Global Int number 1 equals 0, to have the character say, "What a pretty house". If it equals 2, have the character say, "There's a broken window". Wherever in the game script you have the window break, you would include somewhere in that script a line telling the game to change Global Int number 1 to equal 1 (by default, it will be 0).

So, in the script [in the room editor => hotspot (house) interaction => Look At...] for the hotspot, you would put something like:

Code: ags

if (GetGlobalInt(1)==0) {
DisplaySpeech (EGO, "What a pretty house");
}

else if (GetGlobalInt(1)==1) {
DisplaySpeech (EGO, "There's a broken window");
}


In the script where the window gets broken, you would put:

Code: ags

SetGlobalInt(1,1);


...which would change the value of the Global Int #1 from 0 to 1.

This was as simply as I could put it, sorry if it's overboard, or if it doesn't answer your question.

///////////////////

A quick way to try this out yourself would be to open up a room, make a new hotspot, and then in the Interaction Editor for that hotspot, click on "Look At Hotspot", choose "Run script" and in that script put this:

Code: ags

if (GetGlobalInt(1)==0) {
DisplaySpeech (EGO, "Global Int number 1 equals 0");
SetGlobalInt (1,1);
}

else if (GetGlobalInt(1)==1) {
DisplaySpeech (EGO, "Global Int number 1 now equals 1");
}


Test your game in this room and try looking at the hotspot twice. This will change the value of the Global Int as soon as you've looked at the hotspot once. If you look at it a second time, the new interaction will be run. I'm assuming your main character is "EGO" (change it, if it isn't) and that you haven't used a GlobalInt anywhere else.

TerranRich

#7
Isn't the BFAQ's answer enough of an explanation? It's REALLY not that hard. :P

http://www.rain-day.com/harbinger/faq/#coding09
Status: Trying to come up with some ideas...

dikla

hi guys!

thank you all for the explanation. i understand it, and what it does and indeed i succedded to do what i want, but i still have questions (hope you will not be angry and just short answer):
1. where do i put the 2 values of the global int?
2. is it good only when you need speech or rundialoge? or you can use it in any action?
3. related to 1st question: do you put it (the values) in specific hotspot or object or dialog? or in hotspot, obect or dialoge interatcion you put the "if" or whatever you want to do with the variable. i mean do you have special place to declare on the globalints? i did not see it in your examples. (in my dialgoe i wrote set-globalint 100,4, - and the concition i put in the hotspot.
in the case of the broken window, where do i put the "Set Global Int 5, 100"?
i hope my question is understood.
dikla

Kinoko

In regards to the first question...

You can put SetGlobalInt -anywhere- as long as it's going where you want it. To clarify... you put it where the event that changes the orignal action should be. In the case of the broken window, you put it -whereever- the script that dictates where the window gets broken is.]

For example, if the window gets broken by the player USING a rock on the window, you'd be putting the SetglobalInt line somewhere in the WINDOW's interaction editor, under "Use inventory item on". In that script would be where you place the code for the player using the rock on the window, and so in THAT script would be where the SetGlobalInt line would go.

That's just an example. You put it wherever the -change- is. The catylist. I don't know how I can explain it any better ^_^;;; Anyone else... ?

As for Question #2, it's good for anything. Anything you want to change depending on something else, or anything you want to restrict happening until something else has happened.

dikla

Thank you very much. NOW i understand and I think it's realy a powerful tool.
dikla

SMF spam blocked by CleanTalk