• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Scripting on the RME

EdMignari

Veteran OT User
Joined
Jan 8, 2011
Messages
193
Reaction score
347
OT world has a lot of skilled Lua programmers. This will enable them to implement new features like procedural map generation, custom area selection and move, custom item replacement, etc.

Already implemented functions:

Code:
g_gui.newMap()
g_gui.loadMap(path)
g_gui.shouldSaveCurrentMap()
g_gui.saveCurrentMap()
g_gui.canUndo()
g_gui.canRedo()
g_gui.doUndo()
g_gui.doRedo()
g_gui.getEditorAt(index)
g_gui.getCurrentEditor()
g_gui.setCurrentEditor(editor)
g_gui.setCurrentEditor(index)
g_gui.getCurrentFloor()
g_gui.setCurrentFloor(z)
g_gui.getCenterPosition()
g_gui.setCenterPosition(position)
g_gui.setSelectionMode()
g_gui.setDrawingMode()
g_gui.setStatusText(text)
g_gui.showTextBox(title, text)
g_gui.getExecDirectory()
g_gui.getDataDirectory()
g_gui.getLocalDataDirectory()
g_gui.getLocalDirectory()
g_gui.getExtensionsDirectory()

Editor(index)
editor:getMapDescription()
editor:setMapDescription(newDescription)
editor:getMapWidth()
editor:setMapWidth(newWidth)
editor:getMapHeight()
editor:setMapHeight(newHeight)
editor:getTile(x, y, z)
editor:getTile(position)
editor:createSelection(start, end)
editor:selectTiles(tiles)
editor:getSelection()

Tile(x, y, z)
Tile(position)
tile:getPosition()
tile:isHouse()
tile:isHouseExit()
tile:isPvP()
tile:isNoPvP()
tile:isNoLogout()
tile:isPZ()
tile:isBlocking()
tile:isSelected()
tile:isModified()
tile:setPvP(enable)
tile:setNoPvP(enable)
tile:setNoLogout(enable)
tile:setPZ(enable)

Selection(editor, start, end)
selection:getTiles()
selection:getTileCount()
selection:getMinPosition()
selection:getMaxPosition()
selection:move(position)
selection:offset(x[, y = 0[, z = 0]])
selection:borderize()
selection:randomize()
selection:saveAsMinimap(directory, fileName)
selection:destroy()




aba68ee2b28747538e666b2506405bc8.png



8a81772c5f344f0da7b120bd9434785f.png



Examples:


Code:
local startPos = {x = 231, y = 215, z = 7}
local endPos = {x = 252, y = 227, z = 7}

local editor = Editor(0) -- Gets the editor at tab 0.
if editor then
  local selection = editor:createSelection(startPos, endPos) -- Creates a rectangular selection.
  if selection  then
    local tiles = selection:getTiles()
    for _,tile in pairs(tiles) do
      tile:setPZ(false)
    end
  end
end

Code:
local startPos = {x = 231, y = 215, z = 7}
local endPos = {x = 252, y = 227, z = 7}
local destination = {x = 1000, y = 1035, z = 7}

local editor = Editor(0) -- Gets the editor at tab 0.
if editor then
  local selection = editor:createSelection(startPos, endPos) -- Creates a rectangular selection.
  if selection  then
    selection:move(destination)
  end
end

Code:
local startPos = {x = 199, y = 187, z = 7}
local endPos = {x = 278, y = 237, z = 0}
local directory = "C:/Users/Mignari/Documents/output"
local filename = "test"

local editor = Editor(0) -- Gets the editor at tab 0.
if editor then
  local selection = editor:createSelection(startPos, endPos) -- Creates a rectangular selection.
  if selection  then
    selection:saveAsMinimap(directory, filename)
  end
end

Discussion:
https://github.com/hjnilsson/rme/issues/131

Follow the development:
https://github.com/hjnilsson/rme/tree/lua_scripting

Nightly builder (Win):
https://www.dropbox.com/sh/auqhbsiqdk33gm8/AACKIsP_Z5ZeCPdWkh8ougPTa?dl=0

NOTE: this is a development version! Use it only for testing and exploring new features.
 
Last edited:
This looks cool man! Perfect time for me as i'm i'm starting to map hahaha thanks!
 
so it adds itemID's to position with Lua scripts?
 
cool
i'm willing to add a system called route waypoint
i was about to start coding it entirely in C++ but i'd for sure utilize the scripting interface
 
I think scripting on RME is cool but there is other things that bother me more like otbm format. Otbm format is binary and is not merge friend, two mappers can't work together on the same map which is so bad.
 
I think scripting on RME is cool but there is other things that bother me more like otbm format. Otbm format is binary and is not merge friend, two mappers can't work together on the same map which is so bad.

It's really that difficult to find someone who wants to do this. Changing the format without maintaining backward compatibility is a pain for us.
So the otbm format is sufficient for me.
 
It's really that difficult to find someone who wants to do this. Changing the format without maintaining backward compatibility is a pain for us.
So the otbm format is sufficient for me.
What about a small hack in the otbm format? Like lock areas? I lock a certain area, commit it(Ex: git) and the other mapper can't edit that area. Then we need a tool to merge both maps. Even if we change the format, how the merging would happen? I think we would need a tool to merge anyway.
 
Btw, can you add map markers on RME or something similar?
I prefer if map markers look like arrows.
Would be nice if I can add text to map markers too.

I'm currently marking my map like this:
2j3l028.jpg


These flags are removed on server start up.
About these flags, the annoying part is that it replaces some other item, so I have to put them down nearby and kinda spam them to make me understand where is the position I am using in my scripts.
Also to understand what corner is this marker, I sometimes have to draw a corner with flags too.
 
please guys let's not make this topic as feature requests for RME.
 
Btw, can you add map markers on RME or something similar?
I prefer if map markers look like arrows.
Would be nice if I can add text to map markers too.

I'm currently marking my map like this:
2j3l028.jpg


These flags are removed on server start up.
About these flags, the annoying part is that it replaces some other item, so I have to put them down nearby and kinda spam them to make me understand where is the position I am using in my scripts.
Also to understand what corner is this marker, I sometimes have to draw a corner with flags too.
https://github.com/hjnilsson/rme/issues/128
 
This is just awesome. Thank you for this!
 
Btw, can you add map markers on RME or something similar?
I prefer if map markers look like arrows.
Would be nice if I can add text to map markers too.

I'm currently marking my map like this:
2j3l028.jpg


These flags are removed on server start up.
About these flags, the annoying part is that it replaces some other item, so I have to put them down nearby and kinda spam them to make me understand where is the position I am using in my scripts.
Also to understand what corner is this marker, I sometimes have to draw a corner with flags too.

I've already done something like that but I used tile flags (and on server startup I seek for these flags on the tiles)
also I did not placed items but colors like spawn/house/pz
despite of this I'm very interested in improving this to work similar as you intend
 
Bump!


A new useful function was added to the building:
selection:saveAsMinimap(directory, fileName)

Now is possible to export just a piece of the map as minimap(PNG). A code example was added in the topic.

Also:
editor:getMapDescription()
editor:setMapDescription(newDescription)
editor:getMapWidth()
editor:setMapWidth(newWidth)
editor:getMapHeight()
editor:setMapHeight(newHeight)
 
I think scripting on RME is cool but there is other things that bother me more like otbm format. Otbm format is binary and is not merge friend, two mappers can't work together on the same map which is so bad.
OTBM is an object tree structure, I don't see why you wouldn't be able to make your own representation in a text-based format and just convert between the two if you're into that sort of thing.

Personally I'd go for a server-based solution where a centralized party tells each client "draw a tree at 45,56,7" when one of the clients draws a tree there. Seems like it'd be easier to implement. If EdMignari's Lua implementation supports event listeners you could probably get a prototype up and running with the scripting feature this thread is about.
 
Back
Top