arguments for commands
Moderators: marionline, SDHawk
- SwordPlay
- Chemical Slime
- Posts: 966
- Joined: Sun Jan 22, 2017 9:32 am
- Location: London, England
- Contact:
arguments for commands
I want to use this command:
- slice at pixel (parent, x, y, number, check descendants, visible only)
but I don't want to use the arguments "number" or "check descendants"
How should this be formatted?
- slice at pixel (parent, x, y, number, check descendants, visible only)
but I don't want to use the arguments "number" or "check descendants"
How should this be formatted?
- Newbie Newtype
- Reigning Smash Champion
- Posts: 1873
- Joined: Mon Oct 15, 2007 9:44 pm
You can't skip an argument by putting leaving it out (although that's something I want to implement). HSpeak will interpret two commas next to each other as a single comma! I've just patched HSpeak to disallow it.
So you have to give the default values to skip an argument. The plotdict should tell you what the defaults are, but you can also look in plotscr.hsd.
So you have to give the default values to skip an argument. The plotdict should tell you what the defaults are, but you can also look in plotscr.hsd.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
I'm sure I've seen it, along with abuses of most of the other things HSpeak allows but shouldn't!I wonder if any existing scripts at all actually use ,, anywhere? I am guessing probably not
I sure is nice that we don't have to maintain strict source-level compatibility.
(I still haven't given up on the idea of adding - for subtract, somehow!)
Last edited by TMC on Wed May 17, 2017 5:12 pm, edited 1 time in total.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
What about a per-source-file top-level pragma like:TMC wrote:(I still haven't given up on the idea of adding - for subtract, somehow!)
Code: Select all
allow troublesome dashes
That solution has some downsides, but I'm just thinking out loud here :)
We could even check if the input .hss file has a modification time older than the switch to - as the default subtraction operator, and output an appropriate warning message
I think that we would also want subtracting a negative number to always have a mandatory space between the two - symbols.
... actually, in this scenario, couldn't -- always produce an error/warning when "allow troublesome dashes" is not enabled? I don't feel a need to ever support C++ style decrement operator when we already have a perfectly good n -= 1
Yes, I like the idea of requiring subtract negative to be written with a space between the two -'s, and doing a search-and-replace is easy even in Notepad.
(Also currently we support spaces in the middle of a two-character operator, like + = but I see no good reason for that.)
So switching from -- to - would not really be that big a deal since HSpeak would just tell you to either search-and-replace if it saw a -- ... were it not for a far more serious problem, which is that - is currently allowed in identifiers!
I used rpgbatch to scan zip files for included scripts and extracted them (download here). There were 243 .zips with scripts. I didn't extract anything out of .rpg files, but I'll try that in future; this sample is still only small and published scripts will generally be better written.
I searched for scripts using - in identifiers (regex "^[^\"#]*\([^\"#-] *- *[^-=0-9]\|\w *- *[^-=]\)") and found it's actually pretty common. Even Wandering Hamster does it (Fluffy-Mu)! Out of 243 there were 27 games which did so:
Quite a few of them are from sidescroller 101 games, eg hero-vx.
So either we would need a compiler directive to choose whether - is an operator instead of a valid identifier (which would need to be per-file so that plotscr.hsd can go one way, which would mean not being able to call scripts containing - in the name from a file using - as an operator), or we need to forget the idea.
I also checked how many people use - with a space on either the left or right side, and aside from a bunch of negative numbers written with a space, like - 30, these were the only occurrences:
I searched for scripts containing a space in the middle of an operator ("^[^\"#]*[-+<>.^|&:/] \+[+<>.^|&:/]" and a separate search for "- \+-") and there were none. I'm pleased to delete that block of code!
I checked for scripts containing two commas next to each other and there were only two.
(Also currently we support spaces in the middle of a two-character operator, like + = but I see no good reason for that.)
So switching from -- to - would not really be that big a deal since HSpeak would just tell you to either search-and-replace if it saw a -- ... were it not for a far more serious problem, which is that - is currently allowed in identifiers!
I used rpgbatch to scan zip files for included scripts and extracted them (download here). There were 243 .zips with scripts. I didn't extract anything out of .rpg files, but I'll try that in future; this sample is still only small and published scripts will generally be better written.
I searched for scripts using - in identifiers (regex "^[^\"#]*\([^\"#-] *- *[^-=0-9]\|\w *- *[^-=]\)") and found it's actually pretty common. Even Wandering Hamster does it (Fluffy-Mu)! Out of 243 there were 27 games which did so:
Code: Select all
./cp-20/wander.hss
./cp-213/JUNKBOB.HSS
./cp-295/new-wanderp.hss
./cp-433/steve.txt
./cp-601/chat.hss
./cp-601/test.hss
./cp-601/text.hss
./cp-634/RPG File-DESTINY.HSS
./cp-666/Breath of Fire Script.hss
./cp-757/The Ritual-scripts-ritual.hss
./cp-951/1day irc.hss
./extra-COFFEE1--playtest/COFFEE1.txt
./extra-POWERXE--playtest/POWERXE.txt
./opohr-Metamorphosis/528MORPH.HSS
./ss-3dmaze_187/3dmaze-scriptmockup.txt
./ss-3dmazebase_205/3dmazebase-scriptmockup.txt
./ss-amped_220/Amped.hss
./ss-automagically_bizzaro_carnival_in_salad_kingdom_648/12345automagically.txt
./ss-festivus_192/festivus-scriptmockup.txt
./ss-first_fantasy_161/FF_Scripts.txt
./ss-hero_680/Hero-Hero.HS.txt
./ss-lilith_688/battle.hss
./ss-monstergame_techdemo_116/scripts-8bit.txt
./ss-noes_163/NOES-NOES.txt
./ss-ravu_171/Love.hss
./ss-seasons_demo_188/Seasons_Demo-Seasons_Demo-JaneRed_Script_both.HSS
./ss-star_wohrs_123/Star wOHRs.txt
./ss-testone_174/111.hss
./ss-thesuperamazingblueballgame_821/rewrite.hss
./ss-z_level_960/Scripts-main.hss
So either we would need a compiler directive to choose whether - is an operator instead of a valid identifier (which would need to be per-file so that plotscr.hsd can go one way, which would mean not being able to call scripts containing - in the name from a file using - as an operator), or we need to forget the idea.
I also checked how many people use - with a space on either the left or right side, and aside from a bunch of negative numbers written with a space, like - 30, these were the only occurrences:
Code: Select all
./ss-z_level_960/Scripts-main.hss:plotscript, Map 01 - Middle, begin
./ss-z_level_960/Scripts-main.hss:plotscript, Map 02 - Top, begin
./ss-z_level_960/Scripts-main.hss:plotscript, Map 03 - Bottom, begin
I checked for scripts containing two commas next to each other and there were only two.
Last edited by TMC on Thu May 18, 2017 10:12 am, edited 3 times in total.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
It would be like two different language versions, with HSpeak supporting both.
Since you have to declare a variable or script to use it, and 'subtract' isn't allowed inside variable/globalvariable/an arglist, HSpeak would easily detect when you need to add the directive to your scripts.
Making the directive act only on the current file (well actually, only the part of the file below the directive) makes it easy to mix different language versions in the same game if using scripts from elsewhere. There could be an inverse/undo directive to make it even easier.
So, this all sounds perfect.
-- is annoying, but the other thing that's worse is 'return'. Changing the meaning of return would be confusing. I feel "exit returning" is too long though. "return!" or "return now" or "do return" as an alternative? (Hmm... if we had macros...)
(Taking the same no-surprises approach to 'return' as to '--' would be to remove 'return' except when a directive is used, and otherwise replace it with 'setreturn' and 'doreturn'.)
Since you have to declare a variable or script to use it, and 'subtract' isn't allowed inside variable/globalvariable/an arglist, HSpeak would easily detect when you need to add the directive to your scripts.
Making the directive act only on the current file (well actually, only the part of the file below the directive) makes it easy to mix different language versions in the same game if using scripts from elsewhere. There could be an inverse/undo directive to make it even easier.
So, this all sounds perfect.
-- is annoying, but the other thing that's worse is 'return'. Changing the meaning of return would be confusing. I feel "exit returning" is too long though. "return!" or "return now" or "do return" as an alternative? (Hmm... if we had macros...)
(Taking the same no-surprises approach to 'return' as to '--' would be to remove 'return' except when a directive is used, and otherwise replace it with 'setreturn' and 'doreturn'.)
Last edited by TMC on Thu May 18, 2017 2:32 pm, edited 1 time in total.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
"return now" is only 4 characters shorter than "exit returning". "do return" on the other hand...
! might yet prove to be useful for some other syntactical purpose.
How about "exit". It's short for both "exit script" and "exit returning", and it can be a replacement for both: either give it an argument, or don't, in which case the last "return" is used.
Edit: zero occurrences of "exit" in those 243 games.
! might yet prove to be useful for some other syntactical purpose.
How about "exit". It's short for both "exit script" and "exit returning", and it can be a replacement for both: either give it an argument, or don't, in which case the last "return" is used.
Edit: zero occurrences of "exit" in those 243 games.
Last edited by TMC on Thu May 18, 2017 5:56 pm, edited 1 time in total.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
I agree that 'return' and 'exit returning' aren't very bothersome. At least the difference between them is pretty self-evident, and 'exit returning' being long hasn't ever bothered me. However, 'exit' sounds great. Way cleaner than using those two commands independently.
My pronouns are they/them
Ps. I love my wife
Ps. I love my wife