View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:37 am



Reply to topic  [ 15 posts ] 
 Lua scripts that interact with eachother? *Solved 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Lua scripts that interact with eachother? *Solved
I want to make a Lua script that interacts with another Lua script directly. Example:

If self.blabla then
self.partnerscript.randcounter = 123
end

How would I do this?


Last edited by CaveCricket48 on Sat Oct 17, 2009 11:28 pm, edited 1 time in total.



Sat Oct 17, 2009 4:02 pm
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Re: Lua scripts that interact with eachother?
Global Variables. EVERYTHING can access those.

But, there's probably a better/more specialized way.


Sat Oct 17, 2009 4:18 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother?
Can you edit Descriptions with Lua the same way you can edit Mass/Health/ect? Maybe I can do that.


Sat Oct 17, 2009 4:40 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Lua scripts that interact with eachother?
Code:
Obj. A

self.Johnny = 1

Obj. B

For x in movableman.stuff do
if x.presetname == Obj. A then
x = self.GuyI'mGonnaInteractWith
end
end

if self.GuyI'mGonnaInteractWith.Johnny == 1 then
stuffs
end

That works IIRC, I'm most likely wrong, and if I am, CC's lua is ♥♥♥♥.


Sat Oct 17, 2009 5:04 pm
Profile WWW
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post Re: Lua scripts that interact with eachother?
That might do the trick, but the partner will be pretty random.

Try looking at the teleporter code for some partnering stuff.


Sat Oct 17, 2009 5:54 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother?
The teleporter script adds itself to a list and the partner does the same. Then it just interacts with the said list. That wouldn't work very well with what I'm doing, since I'm making a Device. Roon's method looks good, going to try it.

EDIT: I was thinking of something. Is it possible to switch the magazine of a gun with a different one?


Sat Oct 17, 2009 6:00 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Lua scripts that interact with eachother?
That's most likely hardcoded, I don't think you can even check it. If you want to have various magazines you can always lua the fireing. Also Findude, that was just an example, you can always make the search more specific.


Sat Oct 17, 2009 6:23 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother?
How do you use Lua to drop the weapon you're currently holding?


Sat Oct 17, 2009 6:40 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Lua scripts that interact with eachother?
Code:
local cont = actor:GetController();
cont:SetState(Controller.WEAPON_DROP);


Sat Oct 17, 2009 10:35 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother?
I changed WEAPON_DROP to BODY_JUMP for testing, and CC crashed with this:
Attachment:
Error.bmp
Error.bmp [ 279.39 KiB | Viewed 3665 times ]


Sat Oct 17, 2009 10:52 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Lua scripts that interact with eachother?
Pastebin the code.


Sat Oct 17, 2009 10:53 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother?
Pastebin
http://pastebin.com/m68eacc18


Sat Oct 17, 2009 10:56 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Lua scripts that interact with eachother?
Looking at that, I'm not really sure.


Sat Oct 17, 2009 11:01 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Lua scripts that interact with eachother? *Solved
NVM, got it working using: self.parentactor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true);


Sat Oct 17, 2009 11:29 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Lua scripts that interact with eachother? *Solved
Ah, crap. I forget the second argument. That would be the problem.


Sat Oct 17, 2009 11:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 15 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.135s | 15 Queries | GZIP : Off ]