Data Realms Fan Forums
http://45.55.195.193/

Lua scripts that interact with eachother? *Solved
http://45.55.195.193/viewtopic.php?f=73&t=16858
Page 1 of 1

Author:  CaveCricket48 [ Sat Oct 17, 2009 4:02 pm ]
Post subject:  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?

Author:  zalo [ Sat Oct 17, 2009 4:18 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

Global Variables. EVERYTHING can access those.

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

Author:  CaveCricket48 [ Sat Oct 17, 2009 4:40 pm ]
Post subject:  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.

Author:  Roon3 [ Sat Oct 17, 2009 5:04 pm ]
Post subject:  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 ♥♥♥♥.

Author:  findude [ Sat Oct 17, 2009 5:54 pm ]
Post subject:  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.

Author:  CaveCricket48 [ Sat Oct 17, 2009 6:00 pm ]
Post subject:  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?

Author:  Roon3 [ Sat Oct 17, 2009 6:23 pm ]
Post subject:  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.

Author:  CaveCricket48 [ Sat Oct 17, 2009 6:40 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

How do you use Lua to drop the weapon you're currently holding?

Author:  TheLastBanana [ Sat Oct 17, 2009 10:35 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

Code:
local cont = actor:GetController();
cont:SetState(Controller.WEAPON_DROP);

Author:  CaveCricket48 [ Sat Oct 17, 2009 10:52 pm ]
Post subject:  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 3667 times ]

Author:  TheLastBanana [ Sat Oct 17, 2009 10:53 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

Pastebin the code.

Author:  CaveCricket48 [ Sat Oct 17, 2009 10:56 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

Pastebin
http://pastebin.com/m68eacc18

Author:  TheLastBanana [ Sat Oct 17, 2009 11:01 pm ]
Post subject:  Re: Lua scripts that interact with eachother?

Looking at that, I'm not really sure.

Author:  CaveCricket48 [ Sat Oct 17, 2009 11:29 pm ]
Post subject:  Re: Lua scripts that interact with eachother? *Solved

NVM, got it working using: self.parentactor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true);

Author:  TheLastBanana [ Sat Oct 17, 2009 11:31 pm ]
Post subject:  Re: Lua scripts that interact with eachother? *Solved

Ah, crap. I forget the second argument. That would be the problem.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/