MODULE/TEMPLATE: Verbcoin v1.1 - 19 April 2011 - Now..some new stuff!

Started by monkey0506, Sun 13/02/2011 02:30:28

Previous topic - Next topic

monkey0506

Hey there. I don't mean to offend (so sorry if this comes across the wrong way Elecktroshokker), but to me the verbcoin template that is distributed with AGS is somewhat of a mess. I can't tell what most of the functions are for without looking at the manual, because the naming convention is rather odd. Also, I seem to recall that none of the functions the template defines return a value, so you can't read anything back once it's been set..which seems rather unfriendly to me (writeonly??).

So I'm not here to bash the great work that Elecktroshokker has done, I'm here to present my take on the verbcoin interface. It has some similarities to the existing template, but not all of the functionality is the same between the two.

I've taken the liberty of making the template in the form of a short game which also serves as the demo for the module.

Part of the goal I had in writing this was also that of making it available as a stand-alone module. The existing template uses a lot of statically scripted, hard-coded items which make it impossible to do this. With this module you can simply import the script into an existing project, which could save a lot of work if you've already begun developing your game.

Anyway, without further ado..links:

Verbcoin template v1.1 (For AGS 3.1.1+) (Includes module v1.1)
Verbcoin module v1.1 (For AGS 3.0+)
Verbcoin demo v1.0a (Includes module v1.0a, but not template) (This is the same as the compiled version of the template v1.0a)

Other versions (for compatibility purposes):

Verbcoin template v1.0c (For AGS 3.0+) (No native coordinates, uses low-res coordinates*) (Includes module v1.0b)
Verbcoin template v1.0a (For AGS 3.1+) (No "normal" dialog scripting, uses run-script*) (Includes module v1.0a)

*This shouldn't make any difference in your own game if using a higher version of AGS, and would then only to the template files themselves.

Older versions:

Verbcoin template v1.0b (For AGS 3.1.1+) (Includes module v1.0a)
Verbcoin module v1.0b (For AGS 3.0+)
Verbcoin template v1.0 (Requires AGS 3.2.1+)
Verbcoin module v1.0 (Requires AGS 3.2+)
Verbcoin demo v1.0 (Includes module v1.0)

I've tried to thoroughly test everything, and the module itself is quite heavily documented, but let me know if you encounter any bugs, or just if you have any questions/comments/etc. I'll try to post mirrors soon.

Here's an excerpt from the documentation to give you an idea of how to implement the module functions in an existing game:

QuoteGetting started with the Verbcoin module:
-----------------------------------------

Getting started with the Verbcoin module is relatively simple. Import the module into your project, and set up your GUI
however you would like. We'll use Button controls to determine where our "verbs" are at, so be sure that you add these
controls where appropriate. Once you've got that taken care of, you'll need to add a few lines to your script to finish
setting up the interface.

Example:

Code: ags
// GlobalScript.asc

function game_start()
{
  Verbcoin.CoinGUI = gVerbcoin; // tell the module which GUI we will be using for our verbcoin
  Verbcoin.XOffset = gVerbcoin.Width / 2; // set the offset for displaying our GUI
  Verbcoin.YOffset = gVerbcoin.Height / 2; // here we'll just centre it
  Verbcoin.AddButton(btnLook, "Look at", eModeLookat); // add our buttons that the verbcoin will use
  Verbcoin.AddButton(btnTalk, "Talk to", eModeTalkto); // we tell the module what text we want associated with the button
  Verbcoin.AddButton(btnUse, "Use", eModeInteract); // as well as what CursorMode we want to associate the button with
}


And that's it! This is a fairly basic setup for a verbcoin interface, with three buttons for Look, Talk, and Use. There
are other settings that you may want to look at such as Verbcoin.DefaultMode or Verbcoin.Delay, but this should be
enough to get you started.

19 April 2011

Based on some of the recent feedback, I've added two new options to make the module more customizable: Verbcoin.MouseButtonToUse and Verbcoin.IgnoreInventoryClicks. In case the names weren't self-explanatory enough, let me elaborate.

MouseButtonToUse allows you to specify a different MouseButton for activating the verbcoin. For example, if you want to use the right mouse button for the verbcoin instead of the left mouse button, you would simply set this to eMouseRight.

IgnoreInventoryClicks lets you specify that the verbcoin should not be used for inventory interactions. By default, the module treats clicks on inventory items the same as a click on a character, object, or hotspot. If you want to handle inventory items differently, this property now lets you do that.

There are also a couple of other minor changes as well, but nothing very significant really.

03 March 2011

Okay, technically I'm not making this edit until the 5th, so sue me. :D I've uploaded the module v1.0b and template v1.0c for compatibility fixes.

The module v1.0b corrects backwards compatibility of the module which was referencing String.IsNullOrEmpty, the only thing preventing full AGS 3.0+ compatibility. Since it's such a simple function I just changed the function calls to check each of the possible conditions directly. The module is now fully 3.0+ compatible.

The template v1.0c, as you may have noticed, has not been set as the primary download link for the template. The reason for this being that most users are probably using at least AGS 3.1.1 or higher if they are using an AGS 3 version, and there have been some significant changes. The template v1.0c is designed with those using AGS 3.0 to 3.0.2 in mind, who are bound to using low-res coordinates. You can import the template into higher versions of AGS and use native coordinates if you wish, but the template itself and included resources use only low-res coordinates.

17 February 2011

I've uploaded versions 1.0a and 1.0b of the template, and version 1.0a of the module and demo. The template v1.0a is designed for AGS 3.1 only (though is compatible with). The template v1.0b is for AGS 3.1.1+. The only difference between the two is whether the example dialog included in the template uses normal scripting commands. For this reason future versions of the template will not be designed around versions of AGS prior to 3.1.1.

The module version 1.0a is a minor bugfix because I was referencing eMouseMiddleInv, which didn't exist until AGS 3.2. The module itself should be compatible with AGS 3.0+, though I might have overlooked something else. I have verified module compatibility as far back as 3.1, which I'm guessing should cover most 3.0+ users anyway, but I will still try and find a copy of AGS 3.0 to verify.

Sslaxx

If I'm missing the obvious I apologise, but what's the minimum version of AGS you need to use this module?
Stuart "Sslaxx" Moore.

monkey0506

Unless I've overlooked something, the module itself should be compatible with 3.0+.

I didn't think about it till just now, but the template was compiled with 3.2.1, so the template requires that version. I'm going to try and compile the template with a lower version as soon as I can get one. I couldn't find a working link for 3.0, but I'm downloading 3.1 right now.

I'll look around more and see if I can't find a mirror for 3.0 to test it out. (If anyone has it, feel free to let me know ;))

Edit: Apparently I forgot that normal scripting wasn't supported within dialog scripts until 3.1.1. Based on the way I scripted some of the dialogs in the template, it wouldn't be impossible, but it would be potentially bothersome to have to convert it over.

Also I looked at the module script in 3.1 and I referenced (exactly once) eMouseMiddleInv which didn't exist until 3.2. That would be very, very easy to fix with a simple bit of preprocessor conditioning.

I'm now downloading 3.1.1 to convert the template.

Oh, and Game.IgnoreUserInputAfterTextTimeoutMs was used in the template, but that can easily be removed.


monkey0506

I actually was able to work around the conditions by porting portions of the dialog script to the global script instead..which I didn't want to do.

So I've now got versions 1.0a and 1.0b of the template for 3.1 and 3.1.1+ respectively. As noted, the module itself should  be 3.0+ compatible (with the fix I implemented into the module 1.0a.).

I'll try and upload them tonight.

Shane 'ProgZmax' Stevens

This is a pretty cool approach to the verbcoin since it allows you to easily supply more button functionality.  I definitely think this version should be included as an ags template.

monkey0506

I'm glad to hear that ProgZ.

I finally got around to uploading the new files, which should allow people to start using it without having to use unreleased/unofficial versions of AGS (meaning 3.2+).

Let me know what you think of the module, and of course if you find any problems! :)

silverwolfpet

Hi!

I downloaded this one: Verbcoin template v1.0a (For AGS 3.1)
I have version 3.1.

I just import the script and, without setting up anything, I try and run the game, just to see if it runs without setting up the GUI and all that stuff. It freezes on the same line, at the same place.

Verbcoin.asc(826): Error (line 826): undefined symbol 'eMouseMiddleInv'

What am I doing wrong?

EDIT: I just deleted the 'eMouseMiddleInv', seems to run fine now...although I did notice a slight lower framerate. Could also be due to the music (3Mb).

Second EDIT:  Okay, got it to work, it's brilliant! One thing though...

I have two characters: Kauff and Gustav. I used to put this at the beginning of the global script:

Code: ags
function game_start() 
{
  if (mouse.Mode == eModeWalkto) {
  Label1.Text = String.Format("Walk to @OVERHOTSPOT@");
}


And later on I added

Code: ags

function on_mouse_click(MouseButton button)
{
if (player == cKauff) {
    if (mouse.Mode == eModeWalkto) {
  Label1.Text = String.Format("Walk to @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeLookat) {
  Label1.Text = String.Format("Analyze @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeInteract) {
  Label1.Text = String.Format("Use @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeTalkto) {
  Label1.Text = String.Format("Answer Question to @OVERHOTSPOT@");
  }}
  else {
      if (mouse.Mode == eModeWalkto) {
  Label1.Text = String.Format("Walk to @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeLookat) {
  Label1.Text = String.Format("Examine @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeInteract) {
  Label1.Text = String.Format("Use @OVERHOTSPOT@");
  }
  else if (mouse.Mode == eModeTalkto) {
  Label1.Text = String.Format("Contradict Kauff with @OVERHOTSPOT@");


Basically, I want each of these two playable characters to have unique actions (even though "Answer Question to" and "Contradict Kauff with" have the same function as "Talk to". It's just unique and I like it)

Now, when the GUI appears, mouseover works fine but it doesn't show the "Analyze", "Use" etc etc strings anymore.

I managed to give each character a unique GUI, with it's own buttons... like so:

Code: ags
function repeatedly_execute() 
{
  if (player == cKauff){
  Verbcoin.CoinGUI = gKauffVerbcoin;
  Verbcoin.XOffset = gKauffVerbcoin.Width / 2;
  Verbcoin.YOffset = gKauffVerbcoin.Height / 2;
  Verbcoin.AddButton(btnKauffLook, "Look at", eModeLookat);
  Verbcoin.AddButton(btnKauffTalk, "Talk to", eModeTalkto);
  Verbcoin.AddButton(btnKauffUse, "Use", eModeInteract);
}
else if (player == cGustav) {
  Verbcoin.CoinGUI = gGustavVerbcoin;
  Verbcoin.XOffset = gGustavVerbcoin.Width / 2;
  Verbcoin.YOffset = gGustavVerbcoin.Height / 2;
  Verbcoin.AddButton(btnGustavLook, "Look at", eModeLookat);
  Verbcoin.AddButton(btnGustavTalk, "Talk to", eModeTalkto);
  Verbcoin.AddButton(btnGustavUse, "Use", eModeInteract);
}}


Where can I add/move the original code for the @overhotspot@ stuff to appear when I mouseover the buttons?

...that sounded like crap, but you get the idea of what I am asking. Thank you!

monkey0506

Dang it..I accidentally packaged the v1.0 module into all of the 1.0a downloads (template, module, and demo).

Apparently only the template v1.0b download has the v1.0a module SCM file in its package. The v1.0a template has the corrected module files updated though, so if you already downloaded the template you could extract the files from there (by creating a new project and then grabbing them).

Apparently I'm bad at this. :=

silverwolfpet

Nah, it's fine, I just deleted that single line...no big deal. Wasn't going to use middle button anyway.

any suggestions on my problem? It's related to the Verbcoin. Do I have to modify your script?

monkey0506

Sorry, you must have edited around the same time I was posting.

@OVERHOTSPOT@ won't work when the GUI is shown, but that's what Verbcoin.LocationName is for.

I'd recommend making some changes. Put the following function somewhere toward the top of your GlobalScript.asc script file:

Code: ags
void SetPlayer(Character *theCharacter)
{
  if (theCharacter == cKauff)
  {
    Verbcoin.CoinGUI = gKauffVerbcoin;
    Verbcoin.XOffset = gKauffVerbcoin.Width / 2;
    Verbcoin.XOffset = gKauffVerbcoin.Height / 2;
    Verbcoin.AddButton(btnKauffLook, "Analyze", eModeLookat);
    Verbcoin.AddButton(btnKauffTalk, "Answer Question to", eModeTalkto);
    Verbcoin.AddButton(btnKauffUse, "Use", eModeInteract);
  }
  else if (theCharacter == cGustav)
  {
    Verbcoin.CoinGUI = gGustavVerbcoin;
    Verbcoin.XOffset = gGustavVerbcoin.Width / 2;
    Verbcoin.YOffset = gGustavVerbcoin.Height / 2;
    Verbcoin.AddButton(btnGustavLook, "Examine", eModeLookat);
    Verbcoin.AddButton(btnGustavTalk, "Contradict Kauff with", eModeTalkto);
    Verbcoin.AddButton(btnGustavUse, "Use", eModeInteract);
  }
  theCharacter.SetAsPlayer();
}


Then instead of using cKauff.SetAsPlayer or cGustav.SetAsPlayer you would use SetPlayer(cKauff). This handles processing the setup of the verbcoins when the player is changed, instead of doing it from repeatedly_execute (which would be queuing a lot of redundant function calls). So, remove the lines you already have there.

Also, you're going to need to rethink where you're updating your label, so go ahead and just get rid of the script you have in on_mouse_click. Now, going back to the repeatedly_execute function:

Code: ags
function repeatedly_execute()
{
  if (Verbcoin.ActionText == null) Label1.Text = String.Format("Walk to %s", Verbcoin.LocationName);
  else Label1.Text = String.Format("%s %s", Verbcoin.ActionText, Verbcoin.LocationName);
}


This will update your label so that if you don't have a verb on the verbcoin selected then it will show the walk-to text, otherwise it will show the appropriate interaction text for the selected button. This will be also take advantage of the module's built-in methods for alternate interaction text (look up the SetActionText functions in the included documentation).

silverwolfpet

Well, I did exactly as you wrote... word for word. Copy paste.
Deleted exactly what you said.

Now it just shows me "Walk to" all the time, hotspots are without any name (so nothing appears, or nothing gets recognized) and the Verbcoin doesn't work anymore. Thoughts?

monkey0506

With that code you would need to call SetPlayer from game_start to initialize the Verbcoin, and then use SetPlayer when you are changing the player (IIRC you're using a button for this, right)?

And why would none of your hotspots have names? If they didn't have names then @OVERHOTSPOT@ wouldn't work either..unless you just mean to say that it's not adding anything for the hotspot names to the label..which actually sounds related to the issue with the verbcoin itself not working, which I believe is related to the above.

Make sure you call the given SetPlayer function from game_start and that should get it working for you.

Edit: On an unrelated note, I finally got ahold of a copy of 3.0, and it seems the only other thing I overlooked was the non-existence of String.IsNullOrEmpty in that version of AGS. I can work around using that function for the sake of furthered backwards compatibility!

silverwolfpet

You're a genius! I made it work! Yes yes yes! Awesome! Everything works swell! :D

Two thumbs waaay way up! Thank you!

monkey0506

Sweet! Good to know you got it working.

I'm currently working on porting the template back to AGS 3.0 which is..a bit more work than I realized (no native coordinates primarily). The module itself is compatible now that I've fixed the references to String.IsNullOrEmpty (along with the other fixes from v1.0a of the module). I'll try and upload corrected archives for the 1.0a downloads as well with the correct module version in them.

monkey0506

Alright, so I've finally sorted out the compatibility issues and there are now versions of both the module and the template available which make this fully 3.0+ compatible. Isn't that nice? :)

The reason there's so many versions of the template if you're wondering is just to take advantage of various features of different versions of AGS within the template files. I do not intend to maintain three versions of the template, so these versions should be considered as "final" compatibility releases. Any newer version(s) of the template will be designed for AGS 3.1.1+ only.

I will though try to maintain backwards compatibility of the module, since the module code isn't dependent on those features like dialog scripting or what coordinate system is used (since it doesn't reference static coordinates, and only uses things like mouse.x and mouse.y). For any future versions, if you want to implement the new module into an older version of the template that I will try to make it so that you can just import the newer module into the template version matching your version of AGS.

TheRoger

Damn...can get it my way...

Is it possible to make that when you press Left mouse button, character would be just walking, no matter how long you'll hold button. And coin would appear when you press Right mouse button, without character walking. It would be nice that coin would only disappear when you use any action or move mouse away.

monkey0506

You really want the verbcoin to deactivate if the user moves the mouse off of it?? That would be horrendously frustrating to me.

It wouldn't be that difficult for me to make the mouse button used to activate the coin something that could be customized.

If I understand you correctly, you want the verbcoin to be turned on by a right-click, and then stay on (without the user holding the mouse button down), right? That's actually pretty different than what this module was designed for. The built-in template by Electroshokker is labeled as a "SCUMM" verbcoin template, but if you actually compare it, this module/template is much closer to the workings of, say, The Curse of Monkey Island. (And just to be sure I wasn't remembering things wrong, I did in fact check while writing this.)

For your purposes, it might actually just be simpler for you to write your own script. Something like:

Code: ags
// top of script

int clicked_x;
int clicked_y;

void PositionAndShowVerbcoin()
{
  gVerbcoin.X = mouse.x - (gVerbcoin.Width / 2); // you can use your own offset here, I'll just show how to center it
  gVerbcoin.Y = mouse.y - (gVerbcoin.Height / 2);
  gVerbcoin.Visible = true;
}

// on_mouse_click
  // ...
  else if (button == eMouseRight) PositionAndShowVerbcoin();

// repeatedly_execute
  if ((gVerbcoin.Visible) && (GUI.GetAtScreenXY(mouse.x, mouse.y) != gVerbcoin)) gVerbcoin.Visible = false;

// on_event
  if (event == eEventGUIMouseDown)
  {
    if (data == gVerbcoin.ID)
    {
      GUIControl *gcat = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
      if (gcat == null) return; // didn't click on a control..
      if (gcat == btnLook) ProcessClick(clicked_x, clicked_y, eModeLookat);
      else if (gcat == btnTalk) ProcessClick(clicked_x, clicked_y, eModeTalkto);
      else if (gcat == btnUse) ProcessClick(clicked_x, clicked_y, eModeInteract);
    }
  }


I'm only suggesting that because from what it sounds like you want an interface pretty different than that of the CMI-style SCUMM verbcoin interface, which is what this module/template implements.

TheRoger

Well, I'll try this, though I'm bad at this kind of scripting.

EDIT:Hmm...Well the main thing what I want is that character wouldn't walk when you press Right button on walkable area.

monkey0506

So don't process a click in eModeWalkto when the user clicks the right mouse button. That's..pretty basic. The click is intercepted by on_mouse_click, and it won't be processed until you call the ProcessClick function.

SMF spam blocked by CleanTalk