MODULE: MultiResponse v1.2

Started by SSH, Mon 21/08/2006 12:34:48

Previous topic - Next topic

SSH

requires AGS 2.71 or above

It's a real pain to script multiple responses to an action, sometimes. You have to go around declaring variables, put in bunches of if statements, etc. Not too much effort for one interaction, but if you're doing it for all of them?

SSH to the rescue with MultiResponse...

add a script action to your "interact with hotspot" for example and say:

Code: ags

Multi.Disp("No, I'm not touching that>No, I'm really not going near it>Look, for the last time, NO!");


And the first click on it will give you "No, I'm not touching that", the 2nd "No, I'm really not going near it" and the 3rd and subsequent clicks "Look, for the last time, NO!"

Great, I hear you say, but there's more!

The function returns which of the responses was given, so you can do something special:

Code: ags

int state=Multi.Say("I don't think I want to take any>I'd rather not>OK, if you insist>I've already got some");
if (state==3) player.AddInventory(iIckyGoo);


Full documentation at http://ssh.me.uk/moddoc/MultiResponse

Download MultiResponse module here

UPDATED FOR v1.1:

Multi.Respond still does what it used to, but Multi.Disp is now preferred (I would have made it Display, but AGS won't allow it :( ) There is now also Multi.Say to use player.Say instead of Display, and Multi.SRespond which returns the string as GarageGothic suggested. Also new Multi.SLoop and Multi.SRandom which return a looping or random string respectively. There is also the current position in Multi.reponse and a "last response" detector in Multi.last.

UPDATED v1.2:

Added some v3.0+ support with extender functions
12

strazer

Nice idea!

How is the response displayed? player.Say speech text? Is there an option to use a simple Display text box?

SSH

Forgot to say. It uses Display at the moment. I'll probably add another function/option for using player.Say at some point...
12

jasonjkay

It sounds great, should speed up some scripting times. I'll add it to my site.
http://www.americangirlscouts.org/agsresources/ - Mods, plugins and templates.

GarageGothic

Wouldn't it make more sense to let the function return the String that is being said, and then store the state in a global int? Then instead of Display, you could do things like:

Code: ags
player.Say(Multi.Respond("No, I'm not touching that>No, I'm really not going near it>Look, for the last time, NO!"));
if (respondstate == 3) player.AddInventory(iIckyGoo);

SSH

That's another possibility. I might make a new version that lets you do it eitehr way..
12

Dave Gilbert

SSH, this is GREAT!  Thanks so much for this.

Candle


Kweepa

Still waiting for Purity of the Surf II

Dave Gilbert

Quick question, SSH.  Will this function support voice speech?

GarageGothic

#10
Without having looked at the current code, it should be quite trivial to allow voice support if the String is passed to Display (current) or Say. In fact the format should be exactly the same as now, so you just add the voice file numbers in the original String:

Multi.Respond("&1 I don't think I want to take any>&2 I'd rather not>&3 OK, if you insist>&4 I've already got some");

Then, if passed to Say rather than Display, the function would end up calling e.g. cBilly.Say("&1 I don't think I want to take any"), which would play the voice file BILL1.OGG and display the text "I don't think I want to take any".

SSH

#11
Haven't tried it, but I think you're right, GG

I've made a v1.1 now, details in first post.

Edit:

I forgot to mention that the 1.1 version should be up to 100 times faster for big games now, as it uses a hash table to store data rather than just a single string
12

Besh

"Spread our codes to the stars,
You can rescue us all"
- Muse

Goldmund

This module is wonderful!
It will allow me to drown players in plethora of zany responses more easily! Also random!
Hooray!

Dave Gilbert

This is proving to be most fun to use!  However, I am noticing it acts a bit funky when it's used in the global script.  If you use more than one in the global script, every "instance" gets increased when you use it.  For example, let's say you have two inventory items, and since their look interactions are stored in the global script you'd have the following:

object 1:
response 1: "It's a magnifying glass"
response 2: "I said it's a magnifying glass"
response 3: "For the third time, it's a magnifying glass"

object 2:
response 1: "It's a toolbox."
response 2: "Nothing has changed since the last time."
response 3: "Actually, this toolbox has a false bottom"

Again, these are both in the global script.  If you look at object one, you'd get "It's a magnifying glass", but then if you look at object 2, you'd get "Nothing has changed since the last time."

This only seems to happen in the global script. 

SSH

#15
Hmmm, did you download this right after I announced v1.1? I did have a buggy version that was a bit like that that I initially uploaded by mistake, but fixed the same day. So, try redownloading first. Also, can you check with 3 different items, not two. There is a cacheing mechanism to make it run faster and it used to check the "status" of the LAST item you looked at instead of the current item.

If that doesn't throw any light, I'll knock up a debug version.

EDIT: I've double-checked this. I've used this module in PMX and lookign at inventory items works fine and doesn't do what you say...
12

Akumayo

Sounds useful.  I myself would have no use for it, but I can relate to having many frivolous variables to keep up with something as trivial as how many times one has glanced at a bookcase.  Good job, as usual, SSH.
"Power is not a means - it is an end."

Dave Gilbert

SSH: I redownloaded and now it seems to be working fine!  Thanks for the info.

riseryn

Hi
I would like too trigger an interaction when last message of a Multi.Sloop has been read.
How is it possible?

SSH

I think you meant to post in the MultiResponse thread, but the answer is:

Code: ags

if (Multi.last) {
  // do stuff
}

12

SMF spam blocked by CleanTalk