Jump to content

Unusable Gameobject


bookkc

Recommended Posts

http://www.elunaengine.com/Object/SetFlag.html
index comes from here https://github.com/mangoszero/server/blob/52454825c7e1435ff53f32f9edf9fe7dca10ec08/src/game/Object/UpdateFields.h#L284
and it can vary between patches, so same value might not work on mangos zero and mangos two.
The value you can look from gameobject template documentation: https://www.getmangos.eu/wiki/referenceinfo/dbinfo/mangosdb/mangoszeroworlddb/gameobject_template-r1047/#flags

 

 

Link to comment
Share on other sites

function OnCast(event, player, spell, skipCheck)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local obj = 185169
obj:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end


RegisterPlayerEvent(5, OnCast)

so, i know, i was wrong in code, but why how to make work this code with 185169 object

 

ERROR Eluna: lua_scripts/ce_fix.lua:5: attempt to index local 'obj' (a number value)

 

Link to comment
Share on other sites

Hi, ToShuk Marusenko.

The problem in your code is that obj is nothing but an integer and yet you try to call its 'SetFlag' method.
I'm not familiar with Eluna, but it seems like you can get the spell caster from the spell variable there.

 

For example:

caster = spell:GetCaster();
obj = caster:ToGameObject();

obj:SetFlag(GAMEOBJECT_FLAGSm 20);

 

Link to comment
Share on other sites

function OnChat(event, player, spell, skipCheck)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local worldObject = WorldObject:GetGameObjectsInRange(100, 185169)
worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end


RegisterPlayerEvent(18, OnChat)

 

 

2018-04-25 10:18:59 ERROR Eluna: lua_scripts/obj.lua:4: calling 'GetGameObjectsInRange' on bad self (bad argument : WorldObject expected, got table)

 

 

so, where i get fail ?)) i dont know... its my first step to learn eluna with gameobjects

Link to comment
Share on other sites

On 4/25/2018 at 8:22 AM, bookkc said:

So, where i get fail ?)) i dont know... its my first step to learn eluna with gameobjects

7

All functions with : in the wiki need an object to be called.
They are methods of objects. The WorldObject/Creature/Aura signifies what type the object must be. For example, you cannot call http://www.elunaengine.com/Player/GiveXP.html on a creature.

In your code you are calling WorldObject:GetGameObjectsInRange, but WorldObject is not an object of type WorldObject.
player is a WorldObject though, as you may see at the top of this page: http://www.elunaengine.com/Player/index.html

 

On 4/25/2018 at 8:22 AM, bookkc said:

 

7
Link to comment
Share on other sites

Rochet2, can you help me?? please, give little example of this

 

function OnChat(event, player, spell, skipCheck)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local worldObject = WorldObject:GetGameObjectsInRange(100, 185169)
worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end


RegisterPlayerEvent(18, OnChat)
Link to comment
Share on other sites

function OnChat(event, player, spell, skipCheck)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local worldObject = player:GetGameObjectsInRange(100, 185169)
if worldObject then
worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end
end


RegisterPlayerEvent(18, OnChat)

 

Link to comment
Share on other sites

i try to make this 

 

function OnChat(event, player, SetFlag, GetGameObjectsInRange)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local worldObject = player:GetGameObjectsInRange(100, 185169)
if worldObject then
worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end
end


RegisterPlayerEvent(18, OnChat)

but not happenents

 

and try to make this

 

 

function OnChat(event, SetFlag, GetGameObjectsInRange)
local OBJECT_END = 0x0006
local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
local worldObject = player:GetGameObjectsInRange(100, 185169)
if worldObject then
worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
end
end


RegisterPlayerEvent(18, OnChat)

but now i have error with this line 

local worldObject = player:GetGameObjectsInRange(100, 185169)

Link to comment
Share on other sites

I see.
The problem is that GetGameObjectsInRange is used, which returns a table of gameobjects.
The code however is built as if the return value would be a gameobject in itself.
Should use GetNearestGameObject instead.
 

function OnChat(event, player)
    local OBJECT_END = 0x0006
    local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
    local worldObject = player:GetNearestGameObject(100, 185169)
    if worldObject then
        worldObject:SetFlag(GAMEOBJECT_FLAGS, 4+16)
    end
end

RegisterPlayerEvent(18, OnChat)

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use