mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Refactor luagenerator
- cleaned up the generation - created special class to handle the serialization - improved string escaping: Replace OS Path separator with normal slash and allow the usage of a single quote in unit names by changing the delimiter to double quote instead (1797) - adjusted unit_name generation to prevent scripting errors with unescaped characters
This commit is contained in:
@@ -466,3 +466,11 @@ def interpolate(value1: float, value2: float, factor: float, clamp: bool) -> flo
|
||||
|
||||
def dcs_to_shapely_point(point: Point) -> ShapelyPoint:
|
||||
return ShapelyPoint(point.x, point.y)
|
||||
|
||||
|
||||
def escape_string_for_lua(value: str) -> str:
|
||||
"""Escapes special characters from a string.
|
||||
This prevents scripting errors in lua scripts"""
|
||||
value = value.replace('"', "'") # Replace Double Quote as this is the delimiter
|
||||
value = value.replace(os.sep, "/") # Replace Backslash as path separator
|
||||
return "{0}".format(value)
|
||||
|
||||
Reference in New Issue
Block a user