FRUA & DUNGEON CRAFT Community Forums

Dungeon Craft => Dungeon Craft - Troubleshooting => Topic started by: marainein on March 11, 2017, 04:21:27 AM

Title: GPDL scripting questions
Post by: marainein 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?
Title: Re: GPDL scripting questions
Post by: manikus 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.
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens 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'.
Title: Re: GPDL scripting questions
Post by: Mechanaut 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?
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens 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?
Title: Re: GPDL scripting questions
Post by: Mechanaut on March 12, 2017, 01:57:14 PM
https://en.wikipedia.org/wiki/QuakeC
Title: Re: GPDL scripting questions
Post by: marainein 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
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens 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?
Title: Re: GPDL scripting questions
Post by: marainein 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 (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.
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens 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.

Title: Re: GPDL scripting questions
Post by: manikus 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.
Title: Re: GPDL scripting questions
Post by: marainein on March 31, 2017, 03:08:08 PM
Thanks. http://manikus.reonis.com/Help/GPDLCharacterVariables.html (http://manikus.reonis.com/Help/GPDLCharacterVariables.html) also  contains references to floats.
Title: Re: GPDL scripting questions
Post by: manikus 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
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens 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.
Title: Re: GPDL scripting questions
Post by: marainein 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.
Title: Re: GPDL scripting questions
Post by: marainein on April 02, 2017, 02:58:41 PM
Another thing - $GET_LEVEL_STATS_ASL() exists in the documentation http://www.dianneandpaul.net/UAF/Help/GPDL%24GET_LEVEL_STATS.html (http://www.dianneandpaul.net/UAF/Help/GPDL%24GET_LEVEL_STATS.html) but not in the actual scripting engine. How do you get level ASL's?
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens on April 02, 2017, 06:42:36 PM
It appears that we:

1) Replaced $SET_LEVEL_STATS_ASL with $SET_LEVEL_ASL

2) Never bothered to implement any of the LEVEL_ASL functions.

So.....It will have to be a feature request.  You can ask Manikus to
put it somewhere in his queue.

(You might be able to reference these using Logic Block event.) ???
Title: Re: GPDL scripting questions
Post by: marainein on April 03, 2017, 02:58:29 AM
$SET_LEVEL_STATS_ASL() is in there, but without a corresponding get function I don't know if it works. I noticed the problem a month ago when I started writing this, and just used the global ASL instead, figuring 'there must be a function to get level ASL's - I'll figure it out later'
Title: Re: GPDL scripting questions
Post by: manikus on April 03, 2017, 02:23:31 PM
Paul's documentation says there is a function "$IF_LEVEL_STATS_ASL", but if "$SET_LEVEL_STATS_ASL" has been changed to "$SET_STATS_ASL", so maybe Paul changed this one too?
You can try "$IF_LEVEL_STATS"...

This same documentation says that this, "$String $GET_LEVEL_STATS_ASL(String, String)" is a thing...

http://www.dianneandpaul.net/UAF/Help/GPDLListOfFunctions.html

I also don't see the CHAR_ASL functions listed...
I have in my help docs (which always defer to Paul's by the way) have the following ASL related functions:

$GET_CHAR_ASL( String, String )
$SET_CHAR_ASL( String, String, String )
$IF_CHAR_ASL( String, String )

$GET_PARTY_ASL( String )
$SET_PARTY_ASL( String, String )
$IF_PARTY_ASL( String )
$DELETE_PARTY_ASL( String )

$GET_GLOBAL_ASL( String )
$SET_GLOBAL_ASL( String, String )

$GET_LEVEL_STATS_ASL( String, String )
$SET_LEVEL_STATS_ASL( String, String )
$DELETE_LEVEL_STATS_ASL( String, String )
$IF_LEVEL_STATS_ASL( String, String )

I know at least one of these is wrong. Can you tell me which of the rest work?
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens on April 03, 2017, 04:43:38 PM
'Y' means that the function is supposed to work.
'N' means no code exists to implement the function.

Y--$GET_CHAR_ASL( String, String )
Y--$SET_CHAR_ASL( String, String, String )
Y--$IF_CHAR_ASL( String, String )

Y--$GET_PARTY_ASL( String )
Y--$SET_PARTY_ASL( String, String )
Y--$IF_PARTY_ASL( String )
Y--$DELETE_PARTY_ASL( String )

Y--$GET_GLOBAL_ASL( String )
Y--$SET_GLOBAL_ASL( String, String )

N--$GET_LEVEL_STATS_ASL( String, String )
Y--$SET_LEVEL_STATS_ASL( String, String )
Y--$DELETE_LEVEL_STATS_ASL( String, String )
N--$IF_LEVEL_STATS_ASL( String, String )
Title: Re: GPDL scripting questions
Post by: manikus on April 04, 2017, 01:24:37 PM
Thank you, Paul.

You said above that $SET_LEVEL_STATS_ASL() is now $SET_LEVEL_ASL(). Does that mean that $DELETE_LEVEL_STATS_ASL() is now $DELETE_LEVEL_ASL()?
Title: Re: GPDL scripting questions
Post by: Paul R. Stevens on April 04, 2017, 01:38:08 PM
Quote
You said above

I should not have said it, above or below.  I was mislead by some
unused definitions in the code.
Title: Re: GPDL scripting questions
Post by: manikus on April 04, 2017, 05:47:57 PM
Quote
You said above

I should not have said it, above or below.  I was mislead by some
unused definitions in the code.

Fair enough. :)