asamy/forgottenmapeditor

Thing related functions

Closed this issue · 5 comments

Hello,
I've found that there are 4 missing functions that should be added:

  • g_things.getThingNameById(id)
  • g_things.getThingIdByName(name)
  • g_map.colorThing(thing, {r, g, b, a})
  • g_map.removeThingColor(thing)

Last 2 functions will be useful for "selection tool" that I'm planning to work on.

  • g_things.getThingNameById(id)
  • g_things.getThingIdByName(name)

Should these return an ItemType (OTB Type) or ThingType (DAT Type)?

  • g_map.colorThing(thing, { r, g, b, a})
  • g_map.removeThingColor(thing)

These functions sound expensive, i'll try to find another approach.

ItemType, they'll be used in search module :-)

The first one "getThingNameById" is already there:

local itemType = g_things.findItemTypeByClientId(id);
local itemName = itemType:getName()

The second one isn't, so i'm going to make it like so:

local itemType = g_things.findItemTypeByName(name);
local clientId = itemType:getClientId()
local serverId = itemType:getServerId()

(Being generic is better, because if I were not to make it generic, it would still use the same loop and everything)

OTClient's upstream commit edubart/otclient@5849136 implements g_things.findItemTypeByName

OTClient's upstream commit edubart/otclient@32647f1 implements:

  • g_map.colorizeThing(thing, color)
  • g_map.removeThingColor(thing)

Color can be in RGBA (a table) or a string (#ffffffff for example or just color name). Closing this now, open new issue if any bug.