Author Topic: GPDL scripting questions  (Read 414 times)

Offline marainein

  • Sr. Member
  • ****
  • Posts: 372
GPDL scripting questions
« on: March 11, 2017, 04:21:27 AM »
So I'm gradually learning GPDL. Mainly through the GPDL function option on logic block events. Most of the talk on the forums is about scripts called by hooks - I don't know if there are any important differences.

Some queries:
 - Is there a function to return the index of the first matching element in a delimited string? (yes, I know I can write one)
- I've accumulated a number of utility functions - can I make these globally accessible from other logic blocks?
- Sometimes when I have a script that does something to every square in the level, I get warnings about it taking too long to run. Is there a way to turn this off or adjust it?
- Are the scripts attached to events stored in any files in text format?
- What tools can we use for debugging scripts? So far I've only got $DEBUG()
- Anything else I obviously need to know?

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9762
Re: GPDL scripting questions
« Reply #1 on: March 11, 2017, 02:59:21 PM »
So I'm gradually learning GPDL. Mainly through the GPDL function option on logic block events. Most of the talk on the forums is about scripts called by hooks - I don't know if there are any important differences.
Hooks get used with SAs and determine when the script is called, not unlike using a script with a Logic black event.

Some queries:
 - Is there a function to return the index of the first matching element in a delimited string? (yes, I know I can write one)
 
No. The premade functions are generally not this complex. You would use a script (or write a fanction) that would use several of the premade functions to achieve this.
 
 
- I've accumulated a number of utility functions - can I make these globally accessible from other logic blocks?
- Sometimes when I have a script that does something to every square in the level, I get warnings about it taking too long to run. Is there a way to turn this off or adjust it?
Oh, Paul... ;)

- Are the scripts attached to events stored in any files in text format?
If you export the global data and the level data, scripts will be in text format.

- What tools can we use for debugging scripts? So far I've only got $DEBUG()
- Anything else I obviously need to know?
Have you used the debugging feature in the script editor? It is veru gppd fpr sumtax and supported contexts.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: GPDL scripting questions
« Reply #2 on: March 11, 2017, 03:08:23 PM »
Quote
Is there a function to return the index of the first matching element in a delimited string?

But it might be a good idea to make one.  It would be
so very much more efficient than one you could write
using the scripting language.  On the other hand, it
may be that you are using the wrong tool for the job.
There are other methods of searching for string matches
that are very efficient and more scalable.  In particular,
you have access to content-addressable structures such
as ASL's.

Perhaps if you told us what you are trying to accomplish.

Quote
utility functions - can I make these globally accessible from other logic blocks
Sorry.  If they are universally useful, perhaps they could be
'built-in'.

Offline Mechanaut

  • Full Member
  • ***
  • Posts: 124
Re: GPDL scripting questions
« Reply #3 on: March 11, 2017, 08:37:19 PM »
I was going to ask what GDPL is, but after some searching, I did find it... but for those that don't know (like I didn't), it's this (I think) : http://www.dianneandpaul.net/UAF/Help/GPDL.html
(Paul being Paul I assume.)

This looks neat... Is this ~kinda like Quake C?
« Last Edit: March 11, 2017, 08:39:09 PM by Mechanaut »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: GPDL scripting questions
« Reply #4 on: March 12, 2017, 12:25:34 AM »
Quote
Is this ~kinda like Quake C

If it is, it is a complete coincidence.  (I never heard of Quake C.)

What do they call that?  Convergent evolution?

Offline Mechanaut

  • Full Member
  • ***
  • Posts: 124
Re: GPDL scripting questions
« Reply #5 on: March 12, 2017, 01:57:14 PM »

Offline marainein

  • Sr. Member
  • ****
  • Posts: 372
Re: GPDL scripting questions
« Reply #6 on: March 30, 2017, 02:52:01 PM »
Do floating point numbers in GPDL still work? I ask because $DEBUG($DIV("1", "6")); just gave me a 0

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: GPDL scripting questions
« Reply #7 on: March 30, 2017, 02:59:05 PM »
Quote
Do floating point numbers in GPDL still work?

Did floating point numbers in GPDL ever work?

Offline marainein

  • Sr. Member
  • ****
  • Posts: 372
Re: GPDL scripting questions
« Reply #8 on: March 31, 2017, 01:57:45 AM »
Quote
Do floating point numbers in GPDL still work?

Did floating point numbers in GPDL ever work?
The documentation at http://manikus.reonis.com/Help/GPDLListOfFunctions.html talks about 'Infinite precision - performs division on the two strings, with the first number being divided by the second' - I may have misunderstood that to mean it supported floating point.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: GPDL scripting questions
« Reply #9 on: March 31, 2017, 08:54:26 AM »
Quote
I may have misunderstood

I believe you did.  I certainly do not remember
any floating point capability.  Integers suffice for
almost anything you can want to do.  If, for example,
you want fractions of a meter, convert your units to
millimeters.  Or angstroms.


Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9762
Re: GPDL scripting questions
« Reply #10 on: March 31, 2017, 01:42:27 PM »
You are both right - integers only, but my help does imply floating point. I will change my help.

Here is the line that I used when writing my help all of those years ago.
Quote from: Old GPDL Help Document
Fifth, there are functions to operate on strings as decimal digits with infinite precision.  They are not fast.  But you can easily compute 1000-digit numbers if you so please.
This is followed by the list of functions which includes $DIV.

Offline marainein

  • Sr. Member
  • ****
  • Posts: 372
Re: GPDL scripting questions
« Reply #11 on: March 31, 2017, 03:08:08 PM »
Thanks. http://manikus.reonis.com/Help/GPDLCharacterVariables.html also  contains references to floats.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9762
Re: GPDL scripting questions
« Reply #12 on: March 31, 2017, 03:21:49 PM »
I think that Paul might have only been refering to the mathematical functions. Or he forgot.
If you look in the text version of the items database, the default number of attacks for an item is 0.000000 (as is hit dice in the monster database

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: GPDL scripting questions
« Reply #13 on: April 01, 2017, 01:57:28 PM »
Quote from: Paul R. Stevens
I certainly do not remember
any floating point capability

Quote
I think that Paul might have only been refering to the mathematical functions. Or he forgot.

I was referring to GPDL programs.

There are several floating point variables in the engine.
They are generally interpreted as integers.  Richard must have
had something in mind when he assigned these as type floating
but I don't think it ever became useful. 

I found one place where Rate of Fire is multiplied by damage.
Code: [Select]
            // check for fighter multiple attacks (swords/daggers only?)
 
            if (data->ROF_Per_Round > 0)
              dmgSum *= data->ROF_Per_Round;
     

So a non-interger value could be useful.
« Last Edit: April 01, 2017, 02:02:35 PM by Paul R. Stevens »

Offline marainein

  • Sr. Member
  • ****
  • Posts: 372
Re: GPDL scripting questions
« Reply #14 on: April 01, 2017, 09:05:30 PM »
I think the AD&D rules overwhelmingly use integers anyway. Attacks per round are one of the few exceptions - some characters could make an extra attack every other combat round, effectively giving them 1.5 attacks per round.

 

anything