View unanswered posts | View active topics It is currently Wed Dec 25, 2024 5:12 pm



Reply to topic  [ 29 posts ]  Go to page 1, 2  Next
 GetDataModule, or some other way to find all modules 
Author Message

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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?


Last edited by clunatic on Sun Feb 09, 2014 10:58 pm, edited 5 times in total.



Wed May 29, 2013 2:38 am
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post 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.


Wed May 29, 2013 12:03 pm
Profile YIM
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post 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


Wed May 29, 2013 1:09 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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.


Tue Jun 18, 2013 3:04 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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
This sets the next empty spot for the table to be the value you want, in this case the actor you want to control.
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.


Mon Jun 24, 2013 4:42 am
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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!


Mon Jun 24, 2013 5:46 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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.


Wed Jul 31, 2013 12:51 am
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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


Wed Jul 31, 2013 7:15 am
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post Re: Help with adding particles
Thanks, that did it.


Wed Jul 31, 2013 6:19 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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?


Fri Sep 13, 2013 12:58 am
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Randomising actors team
As far as I'm aware, you can't. Actors switching teams has never worked properly to my knowledge.


Fri Sep 13, 2013 1:32 am
Profile YIM

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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.


Fri Sep 13, 2013 7:45 am
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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!


Fri Sep 13, 2013 3:26 pm
Profile
User avatar

Joined: Thu Aug 29, 2013 1:34 am
Posts: 8
Reply with quote
Post 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


Sat Sep 14, 2013 2:11 am
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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?


Sat Sep 21, 2013 8:16 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 29 posts ]  Go to page 1, 2  Next

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.047s | 13 Queries | GZIP : Off ]