Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

7 hours ago, Obsttorte said:

The value of the lightgem is passed to the gui via the code. There is not much to improve here.

But custom scripts can't access it. That's because you need the overlay handle of the GUI element using that GUI float. I tried using the custom overlay specific to my mod, and unsurprisingly $player1.getGuiFloat(mygui, "gui::lightgem_val") always returns 0.

Link to comment
Share on other sites

@Obsttorte, I'm sure that "get" functions are more easily implemented than callbacks, so if I was proposing a specific API expansion, that would be the place to start.

@Dragofer, thinking further about the Signal system as currently defined, I'm not sure what it brings to the table. Is there any thing you can do with it that you can't do more gracefully by using entity spawnargs like "frob_action_script"?

Link to comment
Share on other sites

1 hour ago, MirceaKitsune said:

But custom scripts can't access it. That's because you need the overlay handle of the GUI element using that GUI float. I tried using the custom overlay specific to my mod, and unsurprisingly $player1.getGuiFloat(mygui, "gui::lightgem_val") always returns 0.

The GUI number is something below 10.

try 1, 2, 3, etc. until you find the one that works.

Link to comment
Share on other sites

@Geep The signal system supports different kinds of events than the action script system. Signals can i.e. watch for an entity getting touched by something else (at least the player), an entity getting removed or a func_mover getting blocked. Since it's quite old it doesn't know about "frobbing".

Both systems are covered as sub-topics on this page A to Z Scripting: Ways of calling a script

Link to comment
Share on other sites

1 hour ago, grayman said:

The GUI number is something below 10.

try 1, 2, 3, etc. until you find the one that works.

Is it not something predefined? It seems unsafe to guess and use this way, if it might change in the future and then the mod would break and need to be edited to reflect a new handle. Overall it sounds like it might work, but is pretty hacky to use in this form. I'll think if to at least write down some suggestions in this regard.

Link to comment
Share on other sites

12 minutes ago, MirceaKitsune said:

Is it not something predefined? It seems unsafe to guess and use this way, if it might change in the future and then the mod would break and need to be edited to reflect a new handle. Overall it sounds like it might work, but is pretty hacky to use in this form. I'll think if to at least write down some suggestions in this regard.

You could cycle through each GUI handle until you find one that gives you a non-0 result for the lightgem value. That should be future-proof.

For the rare cases where the mission has no ambient light and the player starts in total darkness, you could keep cycling through those 10 handles until the player moves into an area with light, allowing you to finally identify the correct GUI.

Link to comment
Share on other sites

I am still fuzzy on the utility here.

For custom HUD you can just pass the gui::lightgem_val

For AI, they already check the lightgem value when performing searches. Why not just create a custom AI def and (if needed)

script to modify it's behavior?

To "enhance" the player by lowering the lightgem there is already a lightgem modifier.

What do you need to implement that doesn't involve:

1) Showing the lightgem in a custom HUD

2) Letting AI know your lightgem value

https://wiki.thedarkmod.com/index.php?title=Visual_scan

3) Changing your lightgem value relative to it's current value?

userEntity.setLightgemModifier("lantern", value ));

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

6 hours ago, MirceaKitsune said:

But custom scripts can't access it. That's because you need the overlay handle of the GUI element using that GUI float. I tried using the custom overlay specific to my mod, and unsurprisingly $player1.getGuiFloat(mygui, "gui::lightgem_val") always returns 0.

I know. I was refering to Geeps proposal for using it in a custom gui. That case is already covered by the code.

The reason getGuiFloat returns zero is that you are probably using it wrong. The first argument is the gui handle of your gui. I am also not sure whether the second argument is "gui::lightgem_val", it could also be just "lightgem_val".

3 hours ago, MirceaKitsune said:

Is it not something predefined? It seems unsafe to guess and use this way, if it might change in the future and then the mod would break and need to be edited to reflect a new handle. Overall it sounds like it might work, but is pretty hacky to use in this form. I'll think if to at least write down some suggestions in this regard.

As stated earlier it is GUI_HUD (corresponding to the integer 1 iirc, but you can use GUI_HUD). It is predefined and very unlikely to change.

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

I've had a small trigger_once that fires a script function OK when the player walks into it, but now I'm trying to make it both persistent and auto-reset when the player is outside it, so it can be used again. I know this can't be done with trigger_once, which gets removed from the game once triggered. But I was surprised that trigger_multiple didn't do it either, even with wait time of either "-1" or "32000" specified.

So I'm moving on to try info_tdm_objective_location for this. But I'd like to change the Triggers wiki to be more helpful. Would the following be the correct understanding?  Instead of:

trigger_multiple

Similar to trigger_once but will activate again and again, use "Wait" spawnarg to control how many seconds between triggerings.

...replace with...

trigger_multiple

Similar to trigger_once but will trigger repeatedly as long as the entity that triggered it remains within its volume, after which the trigger_multiple is removed from the map. The "wait" spawnarg controls the seconds between triggerings. A wait of "-1" makes it equivalent to trigger_once.

 

Link to comment
Share on other sites

Trigger_multiples can be re-used as often as one wants and won't be deleted from the map, unless I'm very mistaken. If you want to use the trigger_multiple as a resettable trigger_once, you might be able to toggle it off by triggering it. Might have to infer that the player is still inside, i.e. by checking if there are 2 trigger events within "wait" seconds of each other.

  • Like 1
Link to comment
Share on other sites

OK, so a lot of questions. I won't change the wiki. In the FM, I re-implemented using "within radius" objectives, all working well. Unlike info_tdm_objective_location, which I bug-reported as apparently broken last year.

 

Link to comment
Share on other sites

I have been hitting my head on this for days. I can't get the speaker to play any sound (custom sounds or TDM standalone sounds) using either right-click "create speaker" or "create entity".

I made a sndshd file with my custom sound and a text file with the sound as a wav and ogg --neither worked. So I made a speaker using the create speaker, and still have no sounds. My debugging info says that the default cannot be found.

Any ideas, please?

 

I'm runing DarkRadiant 2.9 on Linux Mint x64 and TDM 2.8

 

mmij-nosound.txt

Link to comment
Share on other sites

My first advice is, it might be good to open up another FM and see how it set up a custom speaker and double check every element with the tutorial in case you misinterpreted something. It could be something like a typo in a spawnarg in the speaker, or in the soundshader, or not have the shader in the right folder, or it not referring to the proper folder where the sound file is, etc.

Worst case, if you still can't figure it out, then you can just flat out copy and paste a custom speaker & all the relevant stuff from another FM into your map and change it from there.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

@mmij, here's a thought. If you've set your speaker up to play a non-looped sound when triggered, you have to remember to add the spawnarg "s_waitfortrigger 1". Otherwise, the sound plays on world start, and you're probably not positioned to hear it.

Unfortunately, s_waitfortrigger is not listed among the default spawnargs in the Entity Inspector, so it's easy to overlook.

Link to comment
Share on other sites

Here's my problem du jour...

I've got a door that, depending on conditions I evaluate in a script, either opens fully or just cracked. If I needed to do just one of those two, I'd just set the "rotate" value appropriately. But I don't think there's a way to set "rotate" from script. (The setSpawnArg function would only work before you spawn the door, not afterwards. It would get messy to spawn the door dynamically just-in-time.)

So I tried creating a named "door stop" object, which I can easily remove via script when I need to. The problem now is that the door travels through the door stop as if it's not there. This is true with both a func_static door stop, and a stock moveable (the builder stone hammer) with "notpushable 1" set.

Anything else to try?

 

Link to comment
Share on other sites

Maybe the physics of the door stop moveable hasn't been activated yet, i.e. by something pushing it. Could try to see if grabbing the moveable makes it become solid to the door. If yes, maybe you could briefly call a grab script event on the moveable?

Link to comment
Share on other sites

Didn't seem like the player grabbing the movable first made any difference. I tried wrapping the hammer in a forcefield and giving it a nudge with that too, to activate physics. No luck.

I guess I could use an AI as door stop, that might work... but will introduce other problems.

 

Link to comment
Share on other sites

22 minutes ago, Geep said:

Didn't seem like the player grabbing the movable first made any difference. I tried wrapping the hammer in a forcefield and giving it a nudge with that too, to activate physics. No luck.

I guess I could use an AI as door stop, that might work... but will introduce other problems.

 

I know that the wooden plank moveable reliably blocks the door leading out of the player's starting location in Perilous Refuge until he carries it away, you could try to copy-paste that setup into your map and then incrementally transform it to what you need.

  • Like 1
Link to comment
Share on other sites

Solved! I didn't need to copy/paste, your suggestion was enough. I arranged a moveable plank on the floor that is hit by the opening door. The other end of the plank is against an immovable knob of worldspawn... required!

Regarding the earlier attempts, it remains surprising to me that setting "notPushable 1" on a moveable doesn't make it act like worldspawn to the physics engine.

  • Like 1
Link to comment
Share on other sites

On 1/17/2021 at 8:28 PM, Geep said:

Here's my problem du jour...

I've got a door that, depending on conditions I evaluate in a script, either opens fully or just cracked. If I needed to do just one of those two, I'd just set the "rotate" value appropriately. But I don't think there's a way to set "rotate" from script. (The setSpawnArg function would only work before you spawn the door, not afterwards. It would get messy to spawn the door dynamically just-in-time.)

So I tried creating a named "door stop" object, which I can easily remove via script when I need to. The problem now is that the door travels through the door stop as if it's not there. This is true with both a func_static door stop, and a stock moveable (the builder stone hammer) with "notpushable 1" set.

Anything else to try?

 

Sorry, I am a bit late, but the "setKey" script function can change (spawn)args even after spawn. According to the description on the Wiki, the behaviour is not changed in most cases, but I know this works for the "text" argument on atdm:gui_message entities. I think it may depend on when/how the argument is handled, but it might be worth a try to set "rotate" that way.

Regarding the "notPushable" spawnarg: The help text in DR reads: "When set to 1, this entity cannot be pushed by the player. If this entity is a moveable, this spawnarg will prevent it from being affected by external impulses as dealt by arrows, for instance.", so I am not sure if it is really meant the way you think it is. I assume that an opening door does not have the kind of impulse that is required to be affected by this spawnarg.

  • Like 1
Link to comment
Share on other sites

Good to hear about setKey. Since I have a working system, I'll just stick with that. I likely couldn't just drop "setKey" into my current script code, because that code is triggered by the door opening, so would probably be too late to change the door limits. I'd likely have to set up another trigger zone in front of the door to see if rotate changes stick.

As for a notPushable moveable, I wonder, if you shoot an arrow at it, does the arrow pass right through it? Because that's what the door does. I'm not saying that's wrong, just for me unexpected (and perhaps undocumented).

Edited by Geep
Link to comment
Share on other sites

Finally figured out how to read the light value at an entity's location after some experimenting, as an alternative to accessing the lightgem value directly via a hacky getGuiFloat() call. You need to use the following function with the following parameters to get the proper results, as a roughly 0 to 1 range... where 0 is the player standing in complete darkness and 1 in maximum light:

vector lts = $player1.getLightInPVS(1.0, 0.01);
float lt = sys.vecLength(lts);

 

Link to comment
Share on other sites

I'm trying to give a projectile a special effect... Ive been snooping around the weapon defs to learn more and this is what I have so far:

1) most projectile entities point to a separate "result" entity which spawns upon impact.

2) the result entity usually contains a Stim. NPC definition files contain a Response to that Stim (damage, heal, blind, gas knockout and so on)

I want to put together a response that will trigger a script function- whats the best way to do this? none of the responses seem to use STIM_TRIGGER, so I can't find any good references to use.

 

one possible solution that doesn't need Stim/Responses is turning the Result entity into a trigger_once that will call the desired function, but Id like to avoid this as its not very practical

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

    • The Black Arrow

      Any of you heard Age of Wonders 4's OST?
      https://www.youtube.com/watch?v=Q0TcoMGq4iA
      I love how after all these years, Michiel van den Bos still conserves his "Melodic" spirit.
      · 0 replies
    • nbohr1more

      Moddb article is up:  https://www.moddb.com/mods/the-dark-mod/news/the-dark-mod-212-is-here
      · 3 replies
    • Petike the Taffer

      I've been gone for a while, but now I'm back, have a new desktop and I want to get back to making missions and playing missions. And doing other contributions. Waiting for my reset password for the wiki, but I'll take a look at it soon. Hello, all.
      · 4 replies
    • snatcher

      TDM Modpack 4.0 for The Dark Mod 2.12 released!
      · 1 reply
    • nbohr1more

      Congrats to all the busy Dark Mod developers! TDM 2.12 is here!
      · 4 replies
×
×
  • Create New...