Jump to content
The Dark Mod Forums

Recommended Posts

Posted

How do I spawn an entity from script? This is what I've got so far, triggered by a switch in-game. the test light toggles on and off OK but no hammer is spawned that I can see...

 

 

 

entity g_testPart; //define global entity

void spawnParts()
{
sys.trigger($light_371); //test light works OK
g_testPart = sys.spawn("atdm:moveable_weapon_hammer");
$g_testPart.setOrigin('-1973 -1336 79');
}

Posted

Obsttorte: Hide is not a bad idea but I need to create a loop of entities. When a new one is created then the oldest in the queue needs to be deleted so that there are not too many. Maybe I can just teleport the oldest to the front of the queue. It's not obvious how to simulate a sequence without arrays. In script I might have a variable with the latest number and increment it. Then a series of conditional checks to see which entity corresponds to that value.

 

Sotha: I'm unsure myself about the dollar sign. I saw an example like mine in another script so hope it's OK. My tenuous belief is that the spawn line creates an entity and names it g_testPart. Until then, no entity exists for this so I don't think I can stick a $ at the front. After that it's a normal entity and is referenced with the dollar sign. That's the theory at any rate. But... since it doesn't work - who knows? In support of that, there is no error such as wrong variable type or whatever.

Posted

If you are refering to entityname you need the dollar sign.

If you are refering to a variable you don't use the dollar sign.

 

You are creating a variable that holds in the entity data, you are not setting it's entityname.

 

That's my belief, you need to test to be sure.

 

EDIT:

here is one example I found with quick googling:

http://www.doom3world.org/phpbb2/viewtopic.php?f=4&t=4999

Clipper

-The mapper's best friend.

Posted

Ah thanks - that fixed it. I'm a bit rusty. I remember now, that variable just holds the entity.

 

got a hammer - doesn't drop but probably needs activate.

 

That's the easy bit now to see if I can create a loooooooooop.....

Posted

When a new one is created then the oldest in the queue needs to be deleted so that there are not too many.

you could hide it then ;)

 

well, for the loop thing, I guess you could just use several variables according to the number of entities you want to have in-game at maximum and an iterating number, I'm not sure if there's a modulo operator in the d3 scripting language, that would make things easier for you

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Posted

OK, this is solved now. I create the moveables I want first, use an incrementing script to teleport into position then activate a trigger relay that targets it to force it to drop (it won't drop by direct activate for some reason.)

Posted

Yeah, the scripting language really badly needs array support. It unfortunately a bit out of my league, but I could have used it a lot already. Right now I am playing tricks with storing stuff on spawnargs on entities (or the player, since that entity is always available). Really nasty workaround to just doing "for (i = 0; i < array.length; i ++) { ..}" :(

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • JackFarmer

      Hello mappers and taffers! 

      Are you still out there? It is so calm here these days and I am afraid this is no good sign.
      Proof me you, tell your best friend (=me), that you are still here and that you will not go away!
      · 0 replies
    • JackFarmer

      Happy Labour Day, my taffing taffers & hard working mapping friends!
      And remember the poor souls who, within the Inventors’ organization, labor under Jonus’s yoke to ensure the success of that very guild! Always remember the hard workers!
      · 2 replies
    • datiswous

      Is there a script command to make a screenshot?
      I just though it could be interesting to be able to create a screenshot at a certain point in time. Then use that screenshot possibly in a debrief.
      I guess the second question is: Can you use a (in-game made) screenshot in a (debrief) gui?
      · 1 reply
    • Bikerdude  »  Display Cement

      So what type, and what ratio of portland to sand 😏
      · 1 reply
    • JackFarmer

      Our esteemed professional mapping predecessors from 20 years ago faced the same challenges we do today!
      · 2 replies
×
×
  • Create New...