Support for backslashed spaces in script commands

This commit is contained in:
Ryan Shepherd 2018-10-01 14:21:48 -04:00
parent e7295bb18f
commit 7a31c1fc55
2 changed files with 12 additions and 5 deletions

View File

@ -131,7 +131,6 @@ sub RunScriptLine {
# Copy to refer to # Copy to refer to
my $oline = $line; my $oline = $line;
# Remove comments
$line=~s/#.+$//; # Remove comments $line=~s/#.+$//; # Remove comments
$line=~s/^\s+//; # Remove leading whitespace $line=~s/^\s+//; # Remove leading whitespace
$line=~s/\s+$//; # Remove trailing whitespace $line=~s/\s+$//; # Remove trailing whitespace
@ -141,7 +140,14 @@ sub RunScriptLine {
return 0; return 0;
} }
my($cmd, @opts)=split(/\s+/, $line); my @opts;
{
my $sline = $line;
$sline=~s/\\ /\x01/g;
(@opts)=split(/\s+/, $sline);
map { s/\x01/ /g } (@opts);
}
my $cmd = shift(@opts);
LogData(DEBUG, "$file:$linenum $cmd(" . join(',',@opts) . ")"); LogData(DEBUG, "$file:$linenum $cmd(" . join(',',@opts) . ")");
if(exists $script_commands{$cmd}) { if(exists $script_commands{$cmd}) {
$script_commands{$cmd}{'sub'}->(@opts); $script_commands{$cmd}{'sub'}->(@opts);

View File

@ -9,7 +9,8 @@ __init__:
Show aka3 spritesheet.png 200 0 3 max_loops=10 Show aka3 spritesheet.png 200 0 3 max_loops=10
AddSayer h "Hermione" aka01.png 200 200 200 255 AddSayer h "Hermione" aka01.png 200 200 200 255
AddSayer h2 "Topless_Hermione" aka05.png 255 0 0 255 AddSayer h2 "Topless\ Hermione" aka05.png 255 0 0 255
AddSayer h3 "Stripping\ Hermione" spritesheet.png 255 0 0 255
Jump donothing Jump donothing
@ -18,8 +19,8 @@ donothing:
LoopCount=LoopCount+1 LoopCount=LoopCount+1
h "Loop number [LoopCount]" h "Loop number [LoopCount]"
TestVar=lc("Foo").uc(lc("Foo")) TestVar=lc("Foo").uc(lc("Foo"))
h "TestVar [TestVar]" h2 "TestVar [TestVar]"
TestVar = uc("[TestVar]") TestVar = uc("[TestVar]")
h "TestVar2 [TestVar]" h3 "TestVar2 [TestVar]"
ExitGame ExitGame
Jump donothing Jump donothing