From 416b6413064524f0c8cc021a1d8049ea2a600c35 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sat, 10 Feb 2024 22:42:50 +0000 Subject: [PATCH] scripts/generate_vsc_snippets: Include custom mod functions as well --- scripts/generate_vsc_snippets.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scripts/generate_vsc_snippets.py b/scripts/generate_vsc_snippets.py index a2da1a235..4919ac206 100644 --- a/scripts/generate_vsc_snippets.py +++ b/scripts/generate_vsc_snippets.py @@ -6,6 +6,11 @@ import json import urllib.request +NATIVE_URLS = { + "https://raw.githubusercontent.com/alloc8or/gta5-nativedb-data/master/natives.json", # Thanks to alloc8or for the natives.json + "https://gopong.dev/chaos/natives.json" +} + out_data = {} def parse_native(native_hash, native_data): @@ -35,18 +40,22 @@ def parse_native(native_hash, native_data): "description": "Returns: " + native_data["return_type"] + native_comment } -# Thanks to alloc8or for the natives.json -try: - result = urllib.request.urlopen("https://raw.githubusercontent.com/alloc8or/gta5-nativedb-data/master/natives.json").read() -except urllib.error.URLError: - print("Error while fetching natives.json, aborting!") - exit() -json_in = json.loads(result) +def parse_natives(url): + try: + result = urllib.request.urlopen(url).read() + except urllib.error.URLError: + print(f"Error while fetching {url}, aborting!") + exit() + + json_in = json.loads(result) + + for _, native_namespace in json_in.items(): + for native_hash, native_data in native_namespace.items(): + parse_native(native_hash, native_data) + +for url in NATIVE_URLS: + parse_natives(url) -for _, native_namespace in json_in.items(): - for native_hash, native_data in native_namespace.items(): - parse_native(native_hash, native_data) - with open("lua.json", "w") as _out: json.dump(out_data, _out)