Skip to content

Add script element to unit template for Storing and Recalling location #34

@Chris15294

Description

@Chris15294

Can you update the unit template to also include the following after the above line

"LuaScript": "LAST_STORED_LOCATION = ""\r\n\r\nfunction onSave()\r\n local data_to_save = {\r\n\t\tlastStoredLocation = LAST_STORED_LOCATION,\r\n }\r\n return saved_data\r\nend\r\n\r\nfunction onLoad(saved_data)\r\n\tLAST_STORED_LOCATION=""\r\n\tLOCKED = false\r\n \r\n if saved_data ~= "" and not bRefresh then\r\n\t\tLAST_STORED_LOCATION = loaded_data.lastStoredLocation\r\n\tend\r\n createMenus()\r\nend\r\n\r\n---------------------------------------------------------------------\r\n-- FNAME: createMenus\r\n-- DESC: Create menu for object\r\n---------------------------------------------------------------------\r\nfunction createMenus()\r\n\tself.clearContextMenu()\r\n\tself.addContextMenuItem("Store Location", storeLocation, false)\r\n\tself.addContextMenuItem("Recall Location", recallLocation, false)\r\nend\r\n\r\nfunction storeLocation()\r\n\tLAST_STORED_LOCATION = { position = self.getPosition(), rotation = self.getRotation()}\r\nend\r\n\r\nfunction recallLocation()\r\n\tif LAST_STORED_LOCATION == nil \r\n\t\tthen return \r\n\tend\r\n\tself.setPosition(LAST_STORED_LOCATION.position)\r\n\tself.setRotation(LAST_STORED_LOCATION.rotation)\r\nend",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions