Scripts / [SOLVED] A change of variables from the bots/other objects

Author
Message
DenZelik
5
Years of Service
User Offline
Joined: 4th Sep 2018
Location: Novoaltaisk
Posted: 16th Apr 2019 17:06
Hello dears! I have a question:

Let's say I have a bot, in the script of which there is a variable var, which does something and it is of type local, i.e. each bot has a separate instance of this variable. So, how can I access this variable through the player? For example, if I hit a bot with a weapon, then you need to change the value of this variable only for this bot. I need it to implement the imposition of negative effects on enemies.

Thank you in advance

The author of this post has marked a post as an answer.

Go to answer
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Apr 2019 18:07
This post has been marked by the post author as the answer.
you can't if it is local, local means accessed only by that script.
why can't you just change it in the script anyway?
i.e. if g_PlayerGunFired > 0 and g_Entity[e]['health'] < health[e] then
var[e] = 1 --whatever you need to change it to here
health[e] = g_Entity[e]['health']
end

just remember to also set up the health = {} and store the health[e] = g_Entity[e]['health'] in the init(e) function too
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Apr 2019 02:08
Local doesn't just mean that the scope of the variable is limited to a script, it means that it is limited to the local environment, for example a variable declare as local within a for loop is not visible outside the for loop!

A single 'script' can contains many environments within which can be many local variables.

Anyhow, if you want to effect an entities health you need to do it using the SetEntityHealth function.
Been there, done that, got all the T-Shirts!
PM
DenZelik
5
Years of Service
User Offline
Joined: 4th Sep 2018
Location: Novoaltaisk
Posted: 17th Apr 2019 18:11
Thank you very much

Login to post a reply

Server time is: 2024-04-23 14:04:17
Your offset time is: 2024-04-23 14:04:17