New portals.txt format
Posted: 26 Feb 2014, 21:15
EDIT: Changed to a cleaner and shorter code, also keeping compatibility with automatic portals recording:
Link: http://hastebin.com/rurewowuce.hs
I was able to implement 100% airship routing.
Sample:
Airship sample:
==== OLD POST ====
Example (converted from bRO): http://pastebin.com/6QJ36TyL
It's totally expandable, you can add there as many properties as you want. Identation is optional. Also you can add there properties to be used by plugins.
Currently, i'm planning to use it to add support to airplane and moskovia troubled route.
We could add a header to portals.txt to decide whether it's this new format or not, keeping compatibility with older tables.
It could be more compact though. Maybe this:
(And would be easier to search).
FileParsers code:
Another uses:
Equip #itemID before talking to the NPC, re-equip previous item then. Useful for moskovia, biolabs...
Would start deactivated when entering source map, and will only be available once the text is detected.
Link: http://hastebin.com/rurewowuce.hs
I was able to implement 100% airship routing.
Sample:
Code: Select all
prt_maze01 74 12 prt_maze01 139 45
prt_maze01 85 174 prt_maze01 74 12
prt_maze01 85 56 prt_maze01 23 125
prt_maze01 85 97 prt_maze01 137 125
prt_maze01 96 45 prt_maze01 55 45
prt_maze01 99 34 prt_maze01 139 45
# splendide
moc_para01 44 19 moc_fild20 342 198 {
steps: c r0 c
}
moc_fild20 368 197 moc_fild22b 175 159 {
steps: c r1 c
}
moc_fild22b 182 179 mid_camp 210 291 {
steps: c c c c r0 c
}
Code: Select all
airplane 243 73 lighthalzen 302 75 {
activation_text: Lighthalzen
}
airplane 243 73 einbroch 92 278 {
activation_text: Einbroch
}
airplane 243 73 yuno 92 260 {
activation_text: [J|Y]uno
}
airplane_01 243 73 yuno 12 261 {
activation_text: [J|Y]uno
}
airplane_01 243 73 ra_fild12 292 204 {
activation_text: Rachel
}
airplane_01 243 73 izlude 200 56 {
activation_text: Izlude
}
Example (converted from bRO): http://pastebin.com/6QJ36TyL
Code: Select all
{ # yuno 152 187 -> aldebaran 168 112
source: (
map: yuno
x: 152
y: 187
)
dest: (
map: aldebaran
x: 168
y: 112
)
cost: 1200
ticket: 1
steps: c r2 c r0
},
Currently, i'm planning to use it to add support to airplane and moskovia troubled route.
We could add a header to portals.txt to decide whether it's this new format or not, keeping compatibility with older tables.
It could be more compact though. Maybe this:
Code: Select all
dest: (map: aldebaran, x: 168, y: 112)
FileParsers code:
Code: Select all
sub parsePortals {
my ($file, $r_hash) = @_;
undef %{$r_hash};
my $reader = Utils::TextReader->new($file);
my %portal;
my $sub_struct;
until ($reader->eof) {
$_ = $reader->readLine;
s/\r//g;
s/(.*)[\s\t]+#.*$/$1/;
s/^\s+|\s+$//g;
if (/^\}\,/) { # reached end of definition, save
my $portal = sprintf("%s %s %s", $portal{'source'}{'map'}, $portal{'source'}{'x'}, $portal{'source'}{'y'});
my $dest = sprintf("%s %s %s", $portal{'dest'}{'map'}, $portal{'dest'}{'x'}, $portal{'dest'}{'y'});
$$r_hash{$portal}{'source'}{'map'} = $portal{'source'}{'map'};
$$r_hash{$portal}{'source'}{'x'} = $portal{'source'}{'x'};
$$r_hash{$portal}{'source'}{'y'} = $portal{'source'}{'y'};
$$r_hash{$portal}{'dest'}{$dest} = $portal{'dest'};
#$$r_hash{$portal}{'dest'}{$dest} = $portal{'misc'};
map { $$r_hash{$portal}{'dest'}{$dest}{$_} = $portal{'misc'}{$_} } keys %{$portal{'misc'}};
$$r_hash{$portal}{dest}{$dest}{enabled} = 1; # is available permanently (can be used when calculating a route)
undef %portal;
undef $sub_struct;
} elsif (/^(\w+):\s+\(/) { # begin complex struct
$sub_struct = $1; # set our complex struct name, like source or destination
} elsif (/^\)$/) { # end complex struct
undef $sub_struct;
} elsif (/^(\w+):\s+(.+)/) {
if ($sub_struct) {
$portal{$sub_struct}{$1} = $2;
} else {
$portal{'misc'}{$1} = $2;
}
} elsif (!/^\{$/) {
error ("Error in parsePortals2 $_\n");
return 0;
}
}
return 1;
}
Code: Select all
equip: #itemID
Code: Select all
activation_text: /airplane broadcast regex/