December 22, 2024, 05:10:13

Author Topic: create a wreckyard  (Read 16059 times)

Offline Hades

  • Recruit
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
    • http://
create a wreckyard
« on: August 12, 2009, 00:19:45 »
Hey need your help guy !
I would make a wreckyard, lot of ship with damaged device.
Is there a way to select all devices of a list of ship ?
I tried execlist(listships,selectdevices(1,s.this,inset(s.this,XX)));
But it does nothing and with dump(1) It appear in the console only appear 1piece of each device :/

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #1 on: August 12, 2009, 00:51:15 »
Hi Hades,

You're not far off.
Once you've created your list of ships in the yard (we'll call it 'MyShips' for now), try this...

Code: [Select]
ExecList(MyShips,
           MyDevices:=GetFreeSel();
           SelectDevices(MyDevices,S.this, InSet(S.this, 31) | Not(InSet(S.this, 31));
           Dump(MyDevices);
);

Basically, we select any Set 31 devices and then any that aren't Set 31, therefore collecting any and all devices aboard the wrecks.  :)
Better to look the fool by asking, then prove them right with ignorance.

Offline Hades

  • Recruit
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
    • http://
(No subject)
« Reply #2 on: August 12, 2009, 01:57:15 »
Thanks for the help Old Dragon ;), it seems it select all devices, but i have still an issue with the damage^^
I tried
Code: [Select]
while(numof(mydevices)>0,pickfirst(mydevices):damage:=rnd(0,100);removefirst(mydevices););
and
Code: [Select]
execlist(mydevices,s.this:damage:=rnd(0,100));
and when i launch the game none of the devices are damaged :/

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #3 on: August 12, 2009, 02:19:16 »
Have you tried placing the code in the 'SceneInit' rule?

I have a mission set up with some targets floating about in it. Placing this in the SceneInit rule has the desired effect for me.

Code: [Select]
Targets:=GetfreeSel();
selectShips(Targets,S.race=#race_Target_Bouys);
Execlist(Targets,
MakeFullyKnown(S.this);
FreezeReconState(S.this,1);

                      Devs:=GetFreeSel();
SelectDevices(Devs,S.this,InSet(S.this,31)|Not(InSet(S.this,31)));
ExecList(Devs,S.this:Damage:=rnd(0,100));
Dump(Devs);
);

Though it didn't want to play when placed in the 'In' rule of the 'Director' machine...
Better to look the fool by asking, then prove them right with ignorance.

Offline Hades

  • Recruit
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
    • http://
(No subject)
« Reply #4 on: August 12, 2009, 14:04:24 »
Yeah it was in the sceneinit, but I find why it didn't work.

Need to put everything about the devices (select them and execution) in the execlist of the list "myships" the way I did was that

Code: [Select]
selectships(myships,s.race=#race_OSEC);dump(myships);
execlist(myships,makefullyknown(s.this);freezereconstate(s.this,1););
execList(MyShips,MyDevices:=GetFreeSel();SelectDevices(MyDevices,S.this,InSet(S.this, 31) | Not(InSet(S.this, 31));));
execlist(mydevices,s.this:damage:=rnd(0,100));
We must put  the last one next the selectdevices, but i don't know why lol.
It works now thanks !  :love:

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #5 on: August 12, 2009, 14:29:53 »
Glad to help. :thumbup:
Better to look the fool by asking, then prove them right with ignorance.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #6 on: August 12, 2009, 22:04:39 »
Another simple way to do that:

Code: [Select]
SelectEx(S.device & InSelection(MyShips, S.owner), S.this:damage := rnd(0,100));
If you just want to select stuff to execute commands on these items once and then forget about them, better use "SelectEx()" instead of "Select()" and "ExecList()". SelectEx combines both commands and doesn't store anything in a permanent list.

Offline Hades

  • Recruit
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
    • http://
(No subject)
« Reply #7 on: August 14, 2009, 23:56:53 »
I tried to use the selectex command several times but I fall on a problem :

What is wrong in these commands ?

Code: [Select]
selectex(s.race=#race_player,disappear(s.this));
selectex(s.race=#race_player,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););

It says : s.this is not a ship, but i selected all ships that the player controls :/


other question about something else : can we send a boat to an ally ship ?
And the universe variable U.sthg, that says that we can use these variables everywhere in the universe folder ?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #8 on: August 15, 2009, 11:42:30 »
Quote from: Hades
What is wrong in these commands?

Code: [Select]
selectex(s.race=#race_player,disappear(s.this));
selectex(s.race=#race_player,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););

It says : s.this is not a ship, but i selected all ships that the player controls
Actually you didn't. Just replace these commands with the following and you'll see, what you really selected:

Code: [Select]
Select(1, s.race = #race_player);
Dump(1);

This should give you a list of all player controlled ships and all devices in the scene (even the ones on AI ships).

Why this happens:
Nexus employs a rather liberal use of variables. You can check objects for variables, that they don't actually have set. These variables will return a value of 0, if they haven't been set to anything else. You can try Select(1, S.MyOwnVar = 0); to select about everything in the scene, because every object reports a value of 0 for your newly invented variable - so the Select condition is always true.

The same happens here: devices don't have a race variable, so you'd think they shouldn't be returned by the above Select or SelectEx statements. However, #race_player usually represents the numeric value of 0 (check "races.ini" for that... #race_player is most likely to be "RACE 0"). Knowing that, the condition "s.race = #race_player" actually means "s.race = 0" and that returns true for all ships belonging to that race and all other objects not having their own race-variable (like devices).

How to fix it:
Long story short, simply include "& s.ship" in your SelectEx condition and everything else not being a ship won't be catched by that statement:

Code: [Select]
selectex(s.race=#race_player & s.ship,disappear(s.this));
selectex(s.race=#race_player & s.ship,SetLongRangeDir(s.this,JumpVector,0,0);longrangearrive(s.this););

Offline Hades

  • Recruit
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
    • http://
(No subject)
« Reply #9 on: August 15, 2009, 18:21:49 »
ok thanks ! :) But when I do this, the game editor crashes lol, think I will use the classical selectships/execlist

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #10 on: August 15, 2009, 20:14:00 »
Tested it and yeah, it does crash. I believe, that's because Disappear() as well as LongRangeArrive() remove the ship from the scene, which confuses the selection somewhat. Every other command I threw at it worked fine so far. Don't hesitate to use SelectEx(), just don't use it for Disappear() or LongRangeArrive() ;)