Skip to content

Commit

Permalink
final fixes for 0.5
Browse files Browse the repository at this point in the history
givePokemon, use item constants
fix crashes/errors in hover-tip logic for trainerbattle commands
* tested that macros and array args still work right
  • Loading branch information
haven1433 committed Dec 4, 2022
1 parent 4a32ab7 commit 4a5f351
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/HexManiac.Core/Models/Code/ScriptParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,11 @@ public byte[] Compile(ModelDelta token, IDataModel model, int start, ref string
var streamStart = i + 1;
var indentCount = 1;
i += 1;
while (indentCount > 0) {
while (indentCount > 0 && lines.Length > i) {
line = lines[i].Trim();
if (line == "{") indentCount += 1;
if (line == "}") indentCount -= 1;
i += 1;
if (i == lines.Length) break;
}
i -= 1;
var streamEnd = i;
Expand Down Expand Up @@ -413,13 +412,16 @@ public string GetHelp(IDataModel model, HelpContext context) {
var checkToken = 1;
while (candidates.Count > 1 && checkToken < tokens.Length) {
if (!tokens[checkToken].TryParseHex(out var codeValue)) break;
candidates = candidates.Where(line => line.LineCode[checkToken] == codeValue).ToList();
candidates = candidates.Where(line => line.LineCode.Count <= checkToken || line.LineCode[checkToken] == codeValue).ToList();
checkToken++;
}
var syntax = candidates.FirstOrDefault();
if (syntax != null) {
var args = syntax.Args.Where(arg => arg is ScriptArg).ToList();
if (args.Count + 1 > tokens.Length) {
var arg = args[tokens.Length - 2];
var skipCount = syntax.LineCode.Count;
if (skipCount == 0) skipCount = 1; // macros
if (args.Count + skipCount > tokens.Length && tokens.Length >= skipCount + 1) {
var arg = args[tokens.Length - 1 - skipCount];
if (!string.IsNullOrEmpty(arg.EnumTableName)) {
var options = model.GetOptions(arg.EnumTableName).Where(option => option.MatchesPartial(tokens[tokens.Length - 1])).ToList();
if (options.Count > 10) {
Expand Down
2 changes: 1 addition & 1 deletion src/HexManiac.Core/Models/Code/scriptReference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ msgbox.item 0F 00 msg<""> 1A 00 80 item:data.items.stats 1A 01 80 count: 1A
76 hidepokepic # hides all shown pokepics
77 showcontestwinner contest. # nop in FireRed. Shows the painting of a wenner of the given contest.
78 braille text<> # displays a message in braille. The text must be formatted to use braille.
79 givePokemon species:data.pokemon.names level. item: filler. filler:: filler::
79 givePokemon species:data.pokemon.names level. item:data.items.stats filler. filler:: filler::
# gives the player one of that pokemon. the last 9 bytes are all 00.
# 800D=0 if it was added to the party
# 800D=1 if it was put in the PC
Expand Down

0 comments on commit 4a5f351

Please # to comment.