Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - RickJ

#1281
Quote
Even so, on a Box-by-Box basis, surely you'll know what font you used, and could work out the necessary difference and use that plus a fixed amount for the margins instead?
Since this is a script module meant for general consumption I have no way of knowing what font someone may use in the future.  I agree that the margins could probably be easily fudged.

Quote
I got the idea, but it looks like you're altering the size of WinBluListBox, while checking against gListbox.RowCount - and I
Thanks you found a bug for me.   WinBluListBox is a pointer variable and should be used in all instances.   I hadn't caught it before because gListBox is the actual control pointer and it value gets copied to the WinBluListBox variable.  Script above has been corrected.  Thanks.

#1282
Quote
WinBluListbox.Height = (WinBluListbox.ItemCount * 5);
Only if the font used happened to be 5 pixels tall, and then you still haven't accounted for the top and bottom margins.   Currently there is not way to fetch the the font from the listbox so there isn't a way to know how many pixels to use for the multiplier.  A 5 poixel increment was chosen to decrease the number of iterations it takes to set the height and because 5 pixels is not very perceptable to the eye with regard to the height of a listbox. 

Quote
(Or gListbox.ItemCount, which you used. Although surely that'd be an infinite loop?)
Hardly inifinte.  The loop increases the listbox height until all of the elements in the list are in view.  There is subsequent error checking, not shown,  that limits the max size so that it fit's in the viewport.
#1283
There are a number of listbox suggestions on the tracker so here are a couple more.

  • Background Color - Currently the listbox has a transparent background, would it be possible to add the ability to specify the background color?   The transparent background makes it very difficult to do "drop down lists" and other sorts of dynamically sized lists.

  • Resizing - Currently it's possible to get the number of items in the list  and how many items are displayed.  To resize the list to display N items then you must calculate how many pixels are required.   A function to resize the list height so that a specified number of items are displayed would be really handy, if easy and practical to implement.   If not, the calculatoion  is do able in script, just not very pretty.

    [edit]
    re: Resizing - Well I guess it's not that ugly but still it's not as simple as a one liner though ...
    Code: ags
    
    int height=0;
    WinBluListbox.Height = 0;
    while (WinBluListbox.ItemCount>gListbox.RowCount) {
          height = height+5;
          WinBluListbox.Height = height;
    }
    

    [/edit]

    As always thanks for the listen. ;)
    RickJ


#1284
I would like the module, I am working on, to do some cleanup when the game exits.   The obvious solution is to make a MyModule.QuitGame() that does whatever I want and then calls QuitGame().  That's OK but it leaves open the possibility that a future user of the module may not realize that this is required and just use the built-in function instead, causing the module to potentially misoperate.   

I checked the on_event() documentation and there is not a eEventQuitGame event listed there.  I was wondering if there is perhaps another clever way of doing this from inside a module?   
#1285
CallRoomScript() is your friend.  :D  Check it out in the manual, it's pretty self-explanatory.

Code: ags

CallRoomScript (int value)

Calls the on_call function in the current room script. This is useful for things like the text parser, where you want to check for general game sentences, and then ask the current room if the sentence was relevant to it.
The on_call function will be called in the current room script, with its value parameter having the value you pass here. This allows it to distinguish between different tasks, and saves you having to use a GlobalInt to tell it what to do.

If the current room has no on_call function, nothing will happen. No error will occur.

You write the on_call function into the room script ("Edit script" button on Room Settings pane), similar to the way you do dialog_request in the global script: 

function on_call (int value) {
  if (value == 1) {
    // Check text input
    if (Parser.Said("get apple"))
      Display("No, leave the tree alone.");
  }
}

#1286
Are you using the latest AGS beta?   Are you using the new method of setting the text?   

// The new way
Label.Text = ".......";

or

// The old way
SetLabelText("....");
#1287
Generally speaking null is not necessarily guaranteed to be equal to 0 for all situations for all time.  If it were, there  wouldn't need to be a keyword for it. 

#1288
Quote
... It is generally assumed that manga's "western" appearance is a form of self-loathing and western love.
I'm not at all qualified to comment on art or manga  history but I think "Self-loathing" is a bit of a leap.  It's not unusual for people to find traits they don't have,  or that are uncommon in their culture, attractive.   Use a British accent in a US pub and you'll be a chick magnet.   Use a British accent in a Lonon pub and you won't be noticed.    :=
#1289
Whew, I feel way better now.  ;)  Thanks ...
#1290
How do I make a String parameter optional as shown below?   

// Module Script
struct WinBlu  {
   // Some stuff
   // :

   import static String   Data(String Name, String Value=null);

   // Some more stuff
   // :
};

When I set it equal to null or to ""  I get the error below.  If I set it to zero
the compiler is happy but I don't think that is right either.   

Error (line xxx): Parameter default value must be literal

I assume I am missing something really obvious here;  it makes me feel so damm noobish.    := 
#1291
It's not in that section of the maual either  :'(
#1292
I would use it to size a data structure corresponding to a gui(s) and its controls.    It's easy enough to work without just thought it was worth a mention as a matter of review.   

Oh, and btw, should "bool"  be mentioned in the Scriopt keyword section of the manual?
#1293
Thanks Steve, I hadn't thought of that.   Although it won't help my current situation, I'll have to remember this technique for future reference.

For the GUI/module I'm currently working on I have generic click handler functions (i.e. one for buttons, one for listbox, etc) that recieve the clicks and then call a module function to process them.   The module function maps the click to an event which is returned and used to call a single event handler function similar to interface_click().   I was thinking to encapsulate the generic click handler's in the module (i.e. one for buttons, one for listbox, etc),  and then call a single event function in the global or room script that could be customized by module users.   

In the example below WinBlu.Click() maps the control's click to a previously programatically defined event which is returned.  WinBlu_Event is the event handler that gets customized to do  whatever the user wants.

// Event Handler
function WinBlu_Event(int event) {
   if (event==THIS) {
   }
   else if (event==THAT) {
   }
   else {
      Display("Error");
   }
}

// Generic button click handler
function WinBlu_ButtonClick(GUIControl *control, MouseButton button) {
   WinBlu_Event(WinBlu.Click(control, button));
}

There is one generic click handler for each type of control that can generate clicks or events.   I thought it would make it easier to use the module if these were included in the module instead of requing that they be pasted into the global script.   Using a character that way you suggest would work just fine but I don't think it would makes things any clearer or easer to understand. 

In case anyone wonders what I am doing, I am attempting to create a dynamically configured GUI system for module testing.  The idea is to throw down a few lines of code to easily create a module testbed. 
=====

Anyway Steve's "cDummy" technique gave me an idea.   What if "on_event()" could be triggered from a script command something like this "TriggerEvent(int data);".  You could catch it with on_event() something like this: 

on_event(event, data) {
   if (event==eEventScriptTriggered) {
   }
}

Would anyone else find this useful?  Of course having some kind of "virtual" module functions would also be sweet.   I've already made too many suggestions in recent days so I'll let some else  make it so ...  ::)


Code: ags
 
if (RickJ > AGS_MAX_SUGGESTION_QUOTA) {
   ShutUp(RickJ);
}
else {
   PostSuggestion("SUGGESTION:.....");
}
#1294
We have one for the max number of GUIS so perhaps one for the max number of controls per gui would also be useful? 
#1295
I guess what I want to do would be something like having a virtual method defined in the module that could be redefined in the global script.    I don't think virtual methods are supported but is there another way of calling a function in the global script from a module?  Perhaps trigger an event or something?   

#1296
Quote from: Radiant on Mon 13/03/2006 21:54:34
What I do is cut/paste to MS Word, then do any fancy replacing (with wildcards if need be) then cut/paste back :)
*** RickJ reads this, chokes on coca-cola,  and spites coke bubbles all over monitor and keyboard  :=

Aw man don't tell people to use a word processor to edit code,  No, No please don't do it!   :'(

Seriously though, it would be much better to use a plain text editor or a program editor to do this.   I would never trust word to not insert funny, invisible characters. 

I use the SciTE editor which is essentially the same editor CJ uses (or at least used to use) for the default script editor.    It can be opened externally as Radiant does with MS word but can also be used as the alternative AGS Script editor.   It has a small footprint (about 700k) so it loads fast.   

You can get it here: http://www.scintilla.org/SciTE.html

The other one I can recommend is metapad.  It is esentially a notepad replacement as it's name suggests.  It handles transparently handles unix and dos line termination and also can convert between them.  It's simpler and smaller than SciTE.  I use this one to edit plain text documents.   

You can get it here: http://www.liquidninja.com/metapad/

There many free choices out there so if these onse don;t suit your fancy just look around.   
#1297
I don't think it's currently possible to go directly to a specific line number in the Script Editor.   If not then it would it be possible to add such function, accessable from menu and/or keyboard short-cut, that would provide for this?  Thanks.

#1298
You can get it from here.
#1299
These are fairly obvious suggestions but in case you haven't thought of it you could try to:

  • Delete the save game files from the compiled directory, especially *.999
  • Make sure you do a  SetRestartPoint () before you do a RestartGame ()

    Note to CJ:  These two functions should probably reference each other in the manual. 
#1300
You can also use DemoQuest as a resource for your project as well.   You may want to look at the documentation and templates as well.  YOu can find everything here:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23083.0
SMF spam blocked by CleanTalk