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

    • OrbWeaver

      Has anyone had any luck with textures from Polyhaven? Their OpenEXR normal maps seem too washed out and give incorrect shading in the engine.
      · 5 replies
    • datiswous

      I tried to upscale the TDM logo video. First try:

      briefing_video.mp4 You can test it ingame by making a copy of the core tdm_gui.mtr and place it in your-tdm-root/materials/ , then edit line 249 of that file into the location where you placed the new briefing.mp4 file.
      What I did was I extracted all the image files, then used Upscayl to upscale the images using General photo (Real-Esrgan) upscale setting and then turn it back into a video.
      I might have to crop it a bit, the logo looks smaller on screen (or maybe it's actually better this way?). My video editor turned it into a 16:9 video, which I think overal looks better than 1:1 video of original.
      · 1 reply
    • nbohr1more

      Trying to be productive on my down-time before Capcom releases Akuma and my son is constantly on my PC playing Street Fighter...
      · 1 reply
    • OrbWeaver

      Finally got round to publishing a tutorial on baking normal maps in Blender, since most of the ones we have are inaccessible or years out of date.
      · 3 replies
    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
×
×
  • Create New...