#How the item binds to the lua script?

1 messages · Page 1 of 1 (latest)

pine gorge
#

I am reading source code of a custom game. When player double click the item, it will increase the player exp. But I can't see how it binds to the lua scripts that actully add the exp. Is there something that it can dynamicly bind?

This content is in npc_items_custom.txt. it is a comsumable item, like cheese in dota2

wintry ocean
#

doesn't look like this is the item that adds exp

pine gorge
void sun
#

This item doesn't do anything at all from its datadriven definition. They probably are listening to "buy item" event and are doing something in lua on it

#

But if they are then this is a terrible way to do it

pine gorge
#

How to listen to "buy item" event? Is there any doc?

#

ListenToGameEvent?

void sun
#

dota_item_purchased is the event name: https://moddota.com/api/#!/events/dota_item_purchased

You use ListenToGameEvent to listen to events.

Here is an example usage (not the same event but the idea is the same):
https://github.com/EarthSalamander42/dota_imba/blob/b9ab7f040020fb5020820275cc36b3095b8771de/game/scripts/vscripts/components/frantic/events.lua

Events guide that I wrote, it is for Typescript but the same concept works fine for lua:
https://moddota.com/scripting/Typescript/typescript-events/

pine gorge
#

I have read the doc. it is useful . The reason I think that the author write the pattern of code is that he doesn't want the hacker to see the code in the lua file. He just uses listen to the event in server, and then write the server code to handle the logic. At last, encrypt the logic with GetDedicatedServerKey. Using this pattern, the client can not see the item handler anymore?

void sun
#

Oh we're still talking about that game with the encryption. Sorry, can't help you.

unreal brook
#

@pine gorge are people that worried about code stealing? I was under the impression that after darklord passed away, that kind of behavior died down. Bad actors on the chinese scene?

compact knot
#

Maybe it's about MouseCallback event on panorama? double click with lmb to launch custom event the server already listens to