Browse Source

Add setPathable() function

Adding function who changing item attribute (ThingAttrNotPathable).
Allows to walk on not pathable items (ThingAttrNotPathable -> true) like parcels, fire fields etc. and vice versa.
Modifying item attribute without editing items sources files. Temporary action for the duration of the client session.

Usage:
print(g_things.getThingType(3504):isNotPathable()) -> true

g_things.getThingType(3504):setPathable(true)

print(g_things.getThingType(3504):isNotPathable()) -> false

Helpful for highter levels players to ignoring "avoiding" fire/energy/poison fields etc. when using map click.
EgzoT 3 years ago
parent
commit
c51df93e3e
No account linked to committer's email address
2 changed files with 2 additions and 0 deletions
  1. 1
    0
      src/client/luafunctions.cpp
  2. 1
    0
      src/client/thingtype.h

+ 1
- 0
src/client/luafunctions.cpp View File

@@ -526,6 +526,7 @@ void Client::registerLuaFunctions()
526 526
     g_lua.bindClassMemberFunction<ThingType>("isNotMoveable", &ThingType::isNotMoveable);
527 527
     g_lua.bindClassMemberFunction<ThingType>("blockProjectile", &ThingType::blockProjectile);
528 528
     g_lua.bindClassMemberFunction<ThingType>("isNotPathable", &ThingType::isNotPathable);
529
+    g_lua.bindClassMemberFunction<ThingType>("setPathable", &ThingType::setPathable);
529 530
     g_lua.bindClassMemberFunction<ThingType>("isPickupable", &ThingType::isPickupable);
530 531
     g_lua.bindClassMemberFunction<ThingType>("isHangable", &ThingType::isHangable);
531 532
     g_lua.bindClassMemberFunction<ThingType>("isHookSouth", &ThingType::isHookSouth);

+ 1
- 0
src/client/thingtype.h View File

@@ -178,6 +178,7 @@ public:
178 178
     bool isNotMoveable() { return m_attribs.has(ThingAttrNotMoveable); }
179 179
     bool blockProjectile() { return m_attribs.has(ThingAttrBlockProjectile); }
180 180
     bool isNotPathable() { return m_attribs.has(ThingAttrNotPathable); }
181
+	void setPathable(bool var) { var == true ? m_attribs.remove(ThingAttrNotPathable) : m_attribs.set(ThingAttrNotPathable, true); }
181 182
     bool isPickupable() { return m_attribs.has(ThingAttrPickupable); }
182 183
     bool isHangable() { return m_attribs.has(ThingAttrHangable); }
183 184
     bool isHookSouth() { return m_attribs.has(ThingAttrHookSouth); }

Loading…
Cancel
Save