Data Realms Fan Forums http://45.55.195.193/ |
|
GetDataModule, or some other way to find all modules http://45.55.195.193/viewtopic.php?f=73&t=45299 |
Page 1 of 2 |
Author: | clunatic [ Wed May 29, 2013 2:38 am ] |
Post subject: | GetDataModule, or some other way to find all modules |
I'm trying to make an explosion where the gibs will ignore the users team (or beter yet ignore any actors from a particular tech) I tried a bunch of stuff along the lines of detecting the nearest actor and deleting the gib if it's on the users team, but that didn't seem to make any difference. Does anyone know of an easy way to do this? |
Author: | Arcalane [ Wed May 29, 2013 12:03 pm ] |
Post subject: | Re: Making a MOpixel ignore your team/tech |
If I remember rightly this can be solved by using emissions, rather than gibs; gibs have no team assigned, which is probably why they're not being deleted. The script is checking, but the value it's checking against isn't the same as the one you actually want it to be. That said, emissions are a little trickier to use. You'll probably need to use a script to spawn the AEmitter that emits the damaging particles, and simply have scripts on those that filter out that Tech in particular by checking which .rte it comes from. |
Author: | p3lb0x [ Wed May 29, 2013 1:09 pm ] |
Post subject: | Re: Making a MOpixel ignore your team/tech |
Alternatively, spawn EVERYTHING from the lua file. That way you have control over all parameters. About not hitting a certain tech, you'll probably have to have each particle do its own checks. But that's probably really expensive |
Author: | clunatic [ Tue Jun 18, 2013 3:04 pm ] |
Post subject: | Re: Making a MOpixel ignore your team/tech |
Thanks for the replies guys, I sorta got it working, but I decided to scrap it in the end. It didn't add much to gameplay and turned out to be rather overpowered. Anyway, I started working on something else. I wanted a beter way of controlling multiple units, so I cobbled together this script using some base scripts and a parent finding method Bad Boy posted elsewhere in this forum and stuck it on a gun firing a fake bullet: It works pretty well, you fire the gun and a nearby friendly actor will get a waypoint added where you're pointing. The targetpos part is still rather crude, I definitely need a beter way of doing that, but what I'd really like some help with is getting this to work for more than one actor. I'm guessing I'd need to stick all the found actors into a table and then apply the waypoint lines to all of them, I just have no idea what that would look like. Anyone mind writing that part for me or pointing me in the direction of a script that I could use as a reference? the prints are just for debugging purposes, I had some troubles with finding the actors and getting the rays working, but that's sorted now. |
Author: | Bad Boy [ Mon Jun 24, 2013 4:42 am ] |
Post subject: | Re: Finding multiple actors. |
Whoops, I meant to reply to this and help you out a while back, sorry about the delay here. I'd like to preface by saying that I haven't actually looked at your script (a brief glance at most) so I'm kinda guessing what you want to do by your descriptions. If I'm understanding right, and you want 1 actor's actions to be mimicked by a bunch of actors then yes, tables would probably be the best idea for what you want. Tables are actually really straightforward once you get the hang of them. They're really just an organization tool, they let you collect a group of similar things under 1 name to save space and make it easy to check through all of them. While they may seem hard at first, especially since their syntax is less easy to understand than most in lua (I know I balked at them for quite a while), they become invaluable once you know how to use them. In the limits of CC lua, they're absolutely the best way to store information. Here's the lua-users instructions for them but I found all that kind of a pain to learn from. Instead, look at scripts that use them and see how they're used. To start you off, you can add things to a table in a couple of ways but the easiest (imo) and most commonly used syntax here on drl is Code: self.tablenamehere[#self.tablenamehere+1] = value To iterate through the table, there are also several ways of doing it, but the one most used on drl is Code: for i = 1, #self.tablenamehere do --perform actions here, where self.tablenamehere[i] will reference the value in the table. e.g. self.tablenamehere[i]:GetController():SetState(Controller.WEAPON_FIRE, true); end To remove things from a table, you use Code: table.remove(self.tablenamehere, number you want to remove); --e.g. to remove all but the first element of a table for i = 1, #self.tablenamehere do if i ~= 1 then table.remove(self.tablenamehere, i); end end --or better yet, saving space: for i = 2, #self.tablenamehere do table.remove(self.tablenamehere, i); end Lemme know if you need any help. |
Author: | clunatic [ Mon Jun 24, 2013 5:46 pm ] |
Post subject: | Re: Finding multiple actors. |
Thanks so much, this was just what I needed! It took me 15 minutes to make it do what I wanted. Thank you thank you thank you! |
Author: | clunatic [ Wed Jul 31, 2013 12:51 am ] |
Post subject: | Re: Finding multiple actors. |
New question: why is this script, which is attached to a MOSRotating fired from a gun: giving me the error: "ERROR: Tried to add a Particle that already exists in the simulation!" in the console? It was just one actor shooting and the gun only fires 1 particle at a time, so it's not as if I was spamming particles. |
Author: | Abdul Alhazred [ Wed Jul 31, 2013 7:15 am ] |
Post subject: | Re: Help with adding particles |
Some obscure bug in the engine sometimes cause that error if you try to spawn things in the Destroy function. One workaround is to move it to Update(), like this: Code: function Update(self) if self.ToDelete then -- Whether this MO is marked for deletion or not for i = 1, 4 do local cloud = CreateMOPixel("Ritans.rte/Bomber Cloud") cloud.Pos = self.Pos cloud.Vel = Vector(math.random()*4,0):RadRotate(math.random()*(math.pi*2)) MovableMan:AddParticle(cloud) end end end |
Author: | clunatic [ Wed Jul 31, 2013 6:19 pm ] |
Post subject: | Re: Help with adding particles |
Thanks, that did it. |
Author: | clunatic [ Fri Sep 13, 2013 12:58 am ] |
Post subject: | Re: Help with adding particles |
I sure do seem to be the only still using this sub forum, but ok, new question again: I'm trying to make an activity that randomises the team of all actors on a key press or when a brain enters an area or so, just as a sort of test activity. To quickly see if something like that was possible I wrote this code: Along with the usual start, pause and end functions for an activity. The code works, in that it randomises the team of all the right actors, but after the teams have been changed cortex command crashes as soon as I try to buy something or switch actor. No errors in the console before it crashes, it just stop working and crashes to desktop. Anyone have any idea why this happens and how I can fix it? |
Author: | Arcalane [ Fri Sep 13, 2013 1:32 am ] |
Post subject: | Re: Randomising actors team |
As far as I'm aware, you can't. Actors switching teams has never worked properly to my knowledge. |
Author: | Bad Boy [ Fri Sep 13, 2013 7:45 am ] |
Post subject: | Re: Randomising actors team |
To be more/less specific, it's complicated and glitchy at best. You'll have to change controllers around to match teams and even then it doesn't really work well. Basically it's usually not a good idea to change teams of added actors, unless it's for a quick gimmick (e.g. change an actor's team when the mission is won, but the actor can't be selected or anything still). In terms of reliability, and someone please correct me if I'm wrong but you'd probably be better off saving each actor (i.e. position, health, inventory, etc.), removing it and readding it with the team changed. It'd be more of a pain to code and it'd be slower but you'd avoid controller/engine issues. |
Author: | clunatic [ Fri Sep 13, 2013 3:26 pm ] |
Post subject: | Re: Randomising actors team |
I was afraid of that. I know Weegee posted a method to save and transfer inventory from one actor to another, somewhere in this forum section, maybe I'll give that a try. It's such a shame that so many things need to be handled so needlessly complicated. Anyway, thanks guys! |
Author: | MacStacker6 [ Sat Sep 14, 2013 2:11 am ] |
Post subject: | Re: Randomising actors team |
Not sure if this helps, but this is a mod with an item that switches the team of an actor when used: http://forums.datarealms.com/viewtopic.php?f=61&t=14641&hilit=disguise+kit |
Author: | clunatic [ Sat Sep 21, 2013 8:16 pm ] |
Post subject: | Re: Randomising actors team |
Thanks, but I already got it working, thanks to some scripts that Weegee made. While I got the "randomise the team of all actors on a button press" part working, I ran into a different problem elsewhere, forcing me to turn to the lua gods with yet another question: I made a function that stores all the actor's positions, presetnames and teams in tables and then spawns all the actors using those tables on the press of a button. But the position part doesn't work. On the first button press it sets the position to 0,0 for all the actors. On every press of the button after that, it uses the current position of the actors spawned on the first button press, or 0,0 if the actor is dead . Everything works, except the position part. Prints show that the position is getting saved in the save actors part, but in the spawn part its suddenly been changed to 0,0. Is there an error in my code somewhere that I keep overlooking or am I yet again trying to do something in the wrong way? Also, but less important, why am I having to use Carnage. (the name of the activity) instead of self. in this function? I defined all the variables and tables as self.whatever in the create function, but in this function I have to use Carnage.? What's up with that? |
Page 1 of 2 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |