extension_info = { "title": "Extension stuff", "description": "g_python test", "version": "1.0", "author": "sirjonasxx" } extension_settings = { "use_click_trigger": True, "can_leave": True, "can_delete": True } ext = Extension(extension_info, sys.argv, extension_settings) def on_connection_start(): print('Connected with: {}:{}'.format(ext.connection_info['host'], ext.connection_info['port'])) print(ext.packet_infos) ext.on_event('double_click', lambda: print('Extension has been clicked')) ext.on_event('init', lambda: print('Initialized with g-earth')) ext.on_event('connection_start', on_connection_start) ext.on_event('connection_end', lambda: print('Connection ended')) ext.start() print(ext.request_flags())
from g_python.gextension import Extension from g_python.htools import Inventory extension_info = { "title": "Inventory items", "description": "g_python test", "version": "1.0", "author": "sirjonasxx" } ext = Extension(extension_info, sys.argv, {"use_click_trigger": True}) ext.start() inv = Inventory(ext) # inventory items will be available under: # inv.inventory_items (list of HInventoryItem) def request_inventory(): print("Requesting inventory") inv.request() def on_inventory_load(items): print("Found {} items!".format(len(items))) ext.on_event('double_click', request_inventory) inv.on_inventory_load(on_inventory_load)
"title": "Snake", "description": "Play snake", "version": "2.0", "author": "Lande" } extension_settings = { "use_click_trigger": True, "can_leave": True, "can_delete": True } ext = Extension(extension_info, sys.argv, extension_settings) ext.start() ext.on_event('double_click', lambda: main()) class Snake: def __init__(self): self.length = 1 self.positions = [((screen_width / 2), (screen_height / 2))] self.direction = right self.color = (50, 255, 50) self.score = 0 def get_head_position(self): return self.positions[0] def turn(self, point): if self.length > 1 and (point[0] * -1,