Scripts / multiple script attached to a single entity ?

Author
Message
reyandekcire
8
Years of Service
User Offline
Joined: 18th Feb 2016
Location:
Posted: 5th Jun 2016 15:13
Hi, i'm trying to have 2 scripts attached to a single entity but i'm so bad in lua scripting that my script doesn't work...

here is the script :

function lea_init(e)
Include("conversation_npc_1.lua")
Include("conversation_npc_2.lua")
end

function lea_main(e)

if agendaclue > 0 then
SwitchScript(e,"conversation_npc_1")
end

if agendaclue < 1 then
SwitchScript(e,"conversation_npc_2")

end

end

the problem is that only conversation_npc_2 script activates even if agendaclue is > 0 (i've checked that the value of agendaclue is 1 by spawning an entity when this variable is > 0)

Could any one help ?
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 5th Jun 2016 18:49
Try this, it works for me.



hth

As you can notice, there is a global variable "agendaclue = 0", take care to pass the value, via your script.

What I did:

a-Place 2 barrels plus player market in a blank map.
b-Attached "lea.lua" to one, and I wrote some script than pass "agendaclue = 1", and attached it to the other barrel.

If I go to the firts one, I get the converstion2, and the conversation1, in the other one.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
reyandekcire
8
Years of Service
User Offline
Joined: 18th Feb 2016
Location:
Posted: 8th Jun 2016 22:21
Hi 3Com,

I've tested what you did but I still can't have the same entity switching script according to variable value. Anyway I have bypassed the problem by having 2 similar entities, one with conversation 1 script and the other one with conversation script and using Hide(e) command according to variable value, it works.... Thanks any for your help.
Cheers
PM

Login to post a reply

Server time is: 2024-05-04 08:53:11
Your offset time is: 2024-05-04 08:53:11