Jump to content
Lethal Raptor Games

GetKeyValue() & SetKeyValue() in lua

Recommended Posts

local value = entity:GetKeyValue("key")

 

entity:SetKeyValue("key", "value")

 

Is that all you mean?

Share this post


Link to post

I want to handle the event like in LE2;

 

function object:SetKey(key,value)
if key=="key1" then
self.key1=tonumber(value)
else
return self.super:SetKey(key,value)
end
return 1

end

 

...or does LE3 handle it in a different way?

Share this post


Link to post

No, you can set anything you want (has to be text I think though).

 

entity:SetKeyValue("age", "10")

 

entity:SetKeyValue("eye.color", "blue")

 

etc

Share this post


Link to post

Probably best to use Entity::SetString and GetString(). This will attach values to the Lua script object, if a script is present. They GetKey/SetKey functionality was just left in for backwards compatibility.

Share this post


Link to post

Can SetString() be handled in the script so when a value changes I can execute some code? ...rather than checking for the changed value in UpdateWorld() - like LE2 handled SetKey()...

Share this post


Link to post

No, but you could just call Entity::CallFunction(functionname)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...