Well, once again I need help with lua stuff for campaign.
Here's what I'm trying to achieve:
For the 'commando' part of my campaign, I'm trying to set up a 'puzzle with four high intensity scanners. They can't be passed unless you hack the corresponding terminal.
There are four scanner arrays. Each one consisits of prop objects, a damageregion (eg 'scanner1'), a bunch of effect objects (1 for each beam, eg called 's1_b1', 's1_b2', 's1_b3' , 's1_b4', 's1_b5').
Each scanner has a terminal that when 'hacked' (actually destroyed with a fusion cutter), disables it - removes the s1_b1-5 effect objects and the damageregion.
The tricky bit is getting the 'puzzle' part to work - only one scanner can be disabled at any one time. So hacking a terminal not only disables the scanner connected to it, but also respawns (if possible) all the other scanner's effect objects and regions.
Anywy, any help on the lua coding I should use (and even how to 'nest' it properly, I'm not very good at that) would be appreciated.
Help needed with setting up Puzzle (lua based)
Moderator: Moderators
- Sky_216
- Droid Pilot Assassin

- Posts: 2086
- Joined: Mon Feb 13, 2006 3:28 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
-
Grev
- Hoth Battle Chief

- Posts: 3132
- Joined: Sun Dec 09, 2007 11:45 pm
- Projects :: No Mod project currently.
- Location: A Certain Box Canyon
Re: Help needed with setting up Puzzle (lua based)
I'm using a similar type of code for a gamemode I'm making, and while I don't have the script on hand, look at the space assault scripts, they will have the code for disabling something when an object it destroyed: (like the ngines inside and outside a capital ship).
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: Help needed with setting up Puzzle (lua based)
Rather than write it out for you, I'll suggest that you download my Spira script. It's got a lot of examples for different types of puzzle setups (and I refer to it regularly, too). I uploaded it with a lot of other assets from Spira, and it can be found in the Assets forum; if you prefer to just download the script (I know you're on a download budget), use this link:
http://files.filefront.com/FFXg+elilua/ ... einfo.html
http://files.filefront.com/FFXg+elilua/ ... einfo.html
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Help needed with setting up Puzzle (lua based)
Wow, 5820 lines. Programming Tip: When you find yourself copying and pasting code, you can generally change your design slightly (like by using tables) and remove all the copied code.Maveritchell wrote:...my Spira script...
The best way to design your puzzle is to use tables of all things that change and functions that do one type of action for a given table. However without knowing exactly how you want everything, that is hard to correctly describe over a few forum posts.
Instead, create functions for everything you want to do. You would have a function to disable scanner 1, enable scanner 1, disable scanner 2, etc... The disable/enable scanner functions would change all of that scanner's effects. (that table method would be like having only one function to disable a scanner and only one to enable a scanner. Then you would pass the table of scanner 2 into the enable scanner function to enable scanner 2. But i'm not telling you to do it that way.)
At the next 'higher level', create a function that takes the 'name' of a scanner. When you call this function, it should call the functions to enable all the other scanners and the function to disable the named scanner.
At the next 'higher/top level', you have your event call-back. When a scanner object is destroyed, call the 'lower function' with the name of the scanner that was destroyed.
Note: The 'higher level' and 'lower level' are just ideas and have no effect on code placement within the script file itself.
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: Help needed with setting up Puzzle (lua based)
I know it's inefficient code - at the time, though, it was easier. You'd know better than I, but as far as learning goes, I feel that it was easier to learn how to actually make happen what I wanted to happen first, and then learn how to make my code less bulky second.[RDH]Zerted wrote:Wow, 5820 lines. Programming Tip: When you find yourself copying and pasting code, you can generally change your design slightly (like by using tables) and remove all the copied code.Maveritchell wrote:...my Spira script...
However, I like to use that fat script as a demonstration because all the code is written out - I think it makes reading single sections at a time easier (if perhaps more difficult to find).
- Sky_216
- Droid Pilot Assassin

- Posts: 2086
- Joined: Mon Feb 13, 2006 3:28 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Help needed with setting up Puzzle (lua based)
Thanks Mav, didn't realise you released the script. And you're right, it'll help more than you spelling out what I should do (help's me learn + saves you time). Thanks again.
