Advertisement
martysama0134

WorldEditorRemix.py

Aug 31st, 2021
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.05 KB | None | 0 0
  1. # from __future__ import print_function #it must be the first line
  2. import sys
  3. import os
  4. import WorldEditor as we
  5. import dbg
  6.  
  7. ### defined methods
  8. MAPBASE = 25600
  9. SCENE_NAMES = ("Map", "Object", "Effect", "Fly", "Max")
  10. PROPERTY_NAMES = ("None", "Tree", "Building", "Effect", "Ambience", "DungeonBlock")
  11. PREFIX_ENV = "d:/ymir work/environment/"
  12.  
  13. def SceneName(v):
  14.     return SCENE_NAMES[v]
  15.  
  16. def PropertyName(v):
  17.     return PROPERTY_NAMES[v]
  18.  
  19. def RecalculateHeightPixel(x, y):
  20.     h=we.GetHeightPixel(x, y)
  21.     print("x {} y {} height {}".format(x, y, h))
  22.     we.DrawHeightPixel(x, y, h)
  23.  
  24. def AdvanceHeightPixel(x, y, advance):
  25.     h=we.GetHeightPixel(x, y)
  26.     print("x {} y {} height {}".format(x, y, h))
  27.     we.DrawHeightPixel(x, y, h+advance)
  28.  
  29. def AdjustBaseCoordinates(x, y):
  30.     # y+=2 # trigger adjust
  31.     isWrong = (x % MAPBASE) or (y % MAPBASE)
  32.     if isWrong:
  33.         x2 = x - (x % MAPBASE)
  34.         y2 = y - (y % MAPBASE)
  35.         dbg.LogBox("The Base coordinates are WRONG:\\nCHANGE X {} Y {}\\n          TO X {} Y {}".format(x, y, x2, y2))
  36.         return x2, y2
  37.     return x, y
  38.  
  39. def GetRealTargetPosition():
  40.     x,y = we.GetTargetPosition()
  41.     x = int(x / 100)
  42.     y = -int(y / 100)
  43.     return x,y
  44.  
  45. def MoveToRealTargetPosition(x, y):
  46.     x = x*100.0
  47.     y = -(y*100.0)
  48.     x0,y0 = we.GetTargetPosition()
  49.     we.UpdateTargetPosition(-x0, -y0)
  50.     we.UpdateTargetPosition(x, y)
  51.  
  52. ### TEST GENERAL
  53. if False:
  54.     pass
  55.     print("IsMapReady", we.IsMapReady())
  56.     print("Env: "+PREFIX_ENV+"{}".format(we.GetEnvironmentDataName()))
  57.     print("Map Size {}x{}".format(*we.GetTerrainCount()))
  58.     print("Base x {} y {}".format(*we.GetBaseXY()))
  59.     # print("Adjusted Base x {} y {}".format(*AdjustBaseCoordinates(*we.GetBaseXY())))
  60.     # we.UpdateTargetPosition(100, 100)
  61.     print("Camera x {} y {}".format(*we.GetTargetPosition()))
  62.     print("Real Camera x {} y {}".format(*GetRealTargetPosition()))
  63.     MoveToRealTargetPosition(112, 112)
  64.  
  65. ### TEST PROPERTY
  66. if True:
  67.     pass
  68.     # print(we.GetObjectList(0, 0))
  69.     # print(we.GetPropertyType(we.PROPERTY_TYPE_EFFECT))
  70.     # print(we.GetPropertyExtension("Effect"))
  71.     # print(we.GetPropertyExtension(PropertyName(we.PROPERTY_TYPE_EFFECT)))
  72.  
  73. ### TEST DRAW HEIGHT
  74. if False:
  75.     pass
  76.     RecalculateHeightPixel(1, 1)
  77.     RecalculateHeightPixel(113, 113)
  78.     AdvanceHeightPixel(113, 113, 500) #226,226
  79.     AdvanceHeightPixel(130, 130, -2500) #230,230
  80.     AdvanceHeightPixel(130, 130, 2500) #230,230
  81.     we.DrawHeightPixel(113, 113, 500)
  82.  
  83.     we.DrawHeightPixel(1, 1, 500)
  84.     we.DrawHeightPixel(1, 2, 500)
  85.     we.DrawHeightPixel(1, 3, 500)
  86.     we.DrawHeightPixel(1, 4, 500)
  87.  
  88. ### TEST GET SCENE
  89. if False:
  90.     pass
  91.     dbg.LogBox("Current scene: [{}] {}".format(we.GetSceneType(), SceneName(we.GetSceneType())))
  92.     print(we.SCENE_MAP)
  93.     print(we.SCENE_OBJECT)
  94.     print(we.SCENE_EFFECT)
  95.     print(we.SCENE_FLY)
  96.  
  97. ### TEST BUILTIN
  98. if False:
  99.     pass
  100.     dbg.LogBox(repr(sys.version_info))
  101.  
  102.     with open("kek", "wb"):
  103.         pass
  104.  
  105.     print("kek2")
  106.  
  107.     print(sys.path)
  108.  
  109.     import dbg
  110.     dbg.LogBox("kek")
  111.     dbg.Trace("oooo1\\n")
  112.     dbg.Tracen("oooo2")
  113.     print("kek3")
  114.  
  115.     for i in (1,2,3,4):
  116.         if i==1:
  117.             print("kek4")
  118.  
  119.     if os.path.exists("kek"):
  120.         print("kek5")
  121.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement