Jump to content
The Dark Mod Forums

How do I spawn an entity from script?


Fidcal

Recommended Posts

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');
}

Link to comment
Share on other sites

why don't you use hide/unhide?

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

      Somehow I admire the fact that the material from Dune has now been filmed for the third time. Personally, I could never do much with the material, but as a child of the 80s, I of course know the David Lynch movie...and that movie was at least funny!
      · 2 replies
    • Baal

      Episode 3 of the second best Doom 3 mod, Phobos,  was just released.
      · 5 replies
    • snatcher

      TDM Modpack v4.2 released!
      · 1 reply
    • The Black Arrow

      Hey @nbohr1morehow come the zombies in The Dark Mod don't have a "resurrection" mechanic to it, similar to how Thief has it?
      They're quite a weak creature as of right now, it's merely a walking corpse that slashes you, making attacking them to kill them an actual strategy.
      Would be better if they had some cool mechanism to it that truly makes them a danger, such as the resurrection idea itself.
      · 7 replies
    • Ansome

      Query: when was the last time a zombie in a video game was unnerving or scary to you? I'm chipping away at my anniversary submission and I've been trying to gather opinions on the subject. I'm perfectly capable of lighting them well, changing their sfx, and creating effective ambience, but I'm worried that zombies at their core are just too overdone to be an effective payoff to the tension I'm creating.
      · 14 replies
×
×
  • Create New...