Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

I have a problem creating readables: I have used the startmap and renamed the xdata file to my mapname. Then I have copied the book "HandwrittenBookStaticShut" and changed the entry "book_handwritten" in the xdata file. But the change does not appear when I start the level. When I change the "book_handwritten" to "book_handwritten2" in both the spawnarg and the xdata, the readable stops working completely (it is still frobable, but upon using it the book darkens and nothing happens; after that it is not possible to frob anything, like doors etc, most likely because the game thinks, that the document is still open but it cannot be closed). For me it appears as if the map uses another xdata file (hence no entry for "book_hadwritten2" and no changes in "book_handwritten"), but I have no idea which one and why.

Link to comment
Share on other sites

I have not used the readable editor so far. The beginning of the xdata file of the startmap and the wiki entry describe quite detailed, how to change the xdata file and I have made it as described. I can exclude a typo, because I have just replaced the generic text "Change this text..." and changed nothing else. I will have a look at the readable editor and the console after the UI broke, when I come home this evening. So, thanks for the quick answer!

 

I also thought about putting the readables last, but then I had just a couple of minutes left before leaving for work and thought, I will make the first one "real quick". Well, we see how that turned out...

Edited by Destined
Link to comment
Share on other sites

Better to check it's not a typo or something like " or ... messing it up

 

I have to second that " is a reserved character and you have to be careful with it inside strings, I had some frustrations with that. Either escape it, like \" or just type two apostrophes like this ''. The latter is a more foolproof way of doing it.

 

I know how xdata files are made but still keep to the readable editor. I've seen that bug, it's usually when you've not reloaded xdata. Are you sure you'e replacing "book_handwritten2" in the xdata contents spawnarg rather than the name?

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

There are no quotation marks in the text I wrote. It was for an appointment book and had two entries, so it looked something like this (have to write from my memory, as I have no access to the file right now):

 

"Afternoon: Lord Hamsworth"

""

"Evening: Abbot Farnsworth"

 

The quotation marks are the same, that were there with the sample text, but the text does not get updated, when I change it and the readable breaks, when I change the name of the xdata entry and spawnarg. As I said: It very much looks like the level points to another xdata file

I am sure that I replaced the xdata spawnarg, it was the first point I checked, when it did not work. For testing I also usually run dmap before starting the level (even if it takes longer, I want to make sure everything works), so I assume that the xdata destinations are also updated.

As I said: I will check the readable editor and the console, when I come home and will write when I know more.

Link to comment
Share on other sites

Ok, the first tests have shown, that apparently the xdata files gets completely ignored. I have moved the file to my desktop (where I think, TDM should not see it, as it has nothing to do with the map path) and the book still showed the "Delete this text and enter your own. One paragraph between each set of quotation marks.

This is another paragraph on the same page. Change this too."

When I change the xdata entry to "book_hadwritten2", the console states, that it cannot find the required entry, but gives no path, where it looked.

 

The readable editor gave a useful information: When I tried to create the text there, the following error message appeared:

"You have imported an XData definition that is contained in a PK4, which can't be accessed for saving. Please rename your XData definition, so that it is stored under a different filename."

So, the question is: Where can I find the XData definition for my current map?

 

Edit: I just found the readable editor settings in the DR preferences. I have set it to my missions xdata folder and restarted DR, but the error message still appears. Slowly I am running out of ideas

Edited by Destined
Link to comment
Share on other sites

I have no problems when I use these settings:

 

Mission is kept in E:/<my_mission_name>/.

 

XData files live in E:/<my_mission_name>/xdata/.

 

Darkmod lives in E:/darkmod/

 

Edit->Preferences->Game Settings -

 

Select a Game: Doom 3

Engine Path: E:/

Mod (fs_game): E:/darkmod/

Mod base (fs_game_base, optional): E:/<my_mission_name>/

 

Plug in the name of your mission folder for <my_mission_name>.

 

Edit->Preferences->Readable Editor Settings -

 

XData Storage Folder: Mod Base/xdata

Custom Folder: <empty>

  • Like 1
Link to comment
Share on other sites

Thanks! It finally worked :smile: I had not defined the Mod Base folder. When I did, there was still an error at first, because the startmap.pk4 was in my darkmod folder (it said, it got 2 possible locations for the xdata). After moving it into another folder it worked. I now used the readable editor and saw that xdata file itself was updated after changing something.

 

@teh_saccade: This could also have been your problem when you renamed your mission: You maybe did also change the folder name and did not update the Mod Base definition, so DR did not find the xdata anymore.

Edited by Destined
Link to comment
Share on other sites

I also use "The Dark Mod 2.0 (standalone)" and it works. This most likely depends on which version you are using.

 

I suggest not only adding it to the A-Z tutorial, but also other wiki entries. As far as I have seen, the need for an update on the Mod Base folder is not mentioned anywhere (neither A-Z tutorial, nor Readables entry, nor Sartmap entry). If it is not generally necessary to be changed, it might at least be mentioned as a possible problem source. Maybe I can get to it later today, but I am not sure if I need permission to change existing wiki entries (I have access, because I want to create an AI stats table, that I have yet to find time/motivation to do; another thing for this weekend...).

 

Edit: I just saw, that the path for the created xdata is mentioned in the Readable Editor entry of the Wiki, so it would most likely be sufficient to refer to that page.

But the A-Z tutorial and Startmap entry would greatly benefit from mentioning of the readable editor.

Edited by Destined
Link to comment
Share on other sites

I need some scripting help. I want the player to frob, say a sack, then get a potion, easy enough. I also want the player to get no more than two potions and disable frobability of the sack; that's easy too - it's a conditional if statement that increments a counter and some "setFrobable" magic. But, I want whenever the player uses the potion, I want that counter to go down and the sack to become frobable again, so it can dispense more potions, essentially making sure that the player can always get more, but never have more than two at one time without spending them first.

 

So far I've tried a custom entityDef with a custom Script Object (which is a potion script object clone). I figured, since the frob/equip/used_action_script spawnargs don't work and I couldn't find any scriptEvents that fetched when a player uses a potion/item in their inventory, a script object (and the InventoryUse routine inside it) would be the only way to detect inventory use and decrement the counter from my main map script.

 

BUT, I have no idea how to make the script object read variables from the map script and send them back (even though the reverse is possible - your map script can read variables from any SO). I would appreciate if someone can tell me if the Script Object approach is a dead end and if there's some scriptEvent I can use that I'm missing.

 

tl;dr: Help me make an object that gives you consumable items, but stops once you hit a cap, then resumes once you're not at the cap because you've consumed some or all of the items.

Edited by Spooks

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

It doesn't seem to be well documented, but I've seen mentions of map namespaces floating around: see http://forums.thedarkmod.com/topic/4946-script-editor-gui-thingy/page-2?do=findComment&comment=92086 and frob_action_script under http://wiki.thedarkmod.com/index.php?title=Frobbing#Entity_Settings

 

Maybe that's how you're meant to reference map script variables...?

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Yeah, frob_action_script would be perfect to carry out the decrement code snippet, but alas, it gets called when the player frobs the potion model to pick it up rather than use it in the inventory. Same for a frob S/R. A player S/R fires when the player holds the potion in their hands. Equip_action_script sounds promising but but does nothing, as I suspect it may only work on weapons.

 

Different namespaces are definitely the issue when it comes to the script object/map script interaction, and I'm not fully acquainted with how to make them work yet. Hmm, I wonder... If I put a variable at the top of tdm_custom_scripts.script (which gets included in tdm_main), would that make it a global variable that could be accessed (and modified) both through the Script Object and map script namespaces? Will have to investigate tomorrow...

 

edit: Yes, it does, soon as I get around to it I'll see if I can make this work and if I do, post an example here for posterity.

Edited by Spooks

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

When I said 'see frob_action_script', I meant look for a snippet about namespaces; if I'd thought more clearly I'd simply have quoted it:

Note that you must specify the scope to call the script in. If it's on the same entity, you should use "<name of entity scriptobject>::<function>". Similarly, if the script to call is within the namespace of a map, you should use "<map namespace>::<function>". Otherwise, just inputting "<function>" will call a global scriptfunction.


Or maybe the bag could have a script object and maintain the counter itself? Edit: actually, that might not even need another script object; maybe just storing the counter in the bag's spawnargs would do, and the potion script object could call $bag.getIntKey("counter") and so forth.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

tl;dr: Help me make an object that gives you consumable items, but stops once you hit a cap, then resumes once you're not at the cap because you've consumed some or all of the items.

I'd use an invisible reversible objective for this:

- have 2 potions, success makes the chest unfrobable, failure makes the chest frobable

 

You'd have to make the potions undroppable to avoid exploits, and you might need to have a delay between each potion handout at the chest to give the objective enough time to react.

Link to comment
Share on other sites

When I said 'see frob_action_script', I meant look for a snippet about namespaces; if I'd thought more clearly I'd simply have quoted it:

I didn't know that, very interesting that you can just put that on the value. I've not had to explicitly specify the map script's namespace when putting a function from there in my frob_action_script spawnargs though. Out of interest do you happen to know how you would call the map namespace in a frob_action_script if you had to? Is it just "my_map_name::my_function"? What's the name of the map namespace, that is. "<map namespace>::<function>"" tells me nothing.

 

I got it working with scripts in my test map, but

 

I'd use an invisible reversible objective for this:

- have 2 potions, success makes the chest unfrobable, failure makes the chest frobable

 

You'd have to make the potions undroppable to avoid exploits, and you might need to have a delay between each potion handout at the chest to give the objective enough time to react.

this is a far more user-friendly solution, thank you Dragofer. The only advantage the script approach has is that you don't have to make the potions undroppable, but I wouldn't want them to be for my purposes anyway. I might just adopt that approach for the real map.

 

As promised, here's how I did it in script:

 

 

Assuming you have a custom entity definition called "atdm:playertools_duckblood" with a default script object "playertools_duckblood"

 

in the beginning of tdm_custom_scripts.script:

//both of these are declared here because both the script object and the map scrip need to access them

float duck_points; //counter
entity Frob_Glob; //the frobber which has a Frob s/r response and dispenses the potion

/*the getFrobable scriptEvent doesn't work with immediate references (dunno why)
and you can't immediately reference an entity data type
so we use this function to fetch the real entity's name*/
entity fetchFrob_Glob(){
	Frob_Glob = sys.getEntity("frobglob");
}

then, in myTestMapsName.script:

entity duck_blood; //the potion entity

void spawnBloodVial(){
		if (duck_points < 2) {
		duck_blood = sys.spawn("atdm:playertools_duckblood");
		duck_blood.addItemToInv($player1);
		duck_points++;
		sys.println("Duck point added, currently at "+duck_points);
		}
		
		/*this makes the frobber unfrobable, which is simply cosmetic; it won't dispense potions
		either way but it looks better if the player can't frob it*/
		if (duck_points == 2) {
		Frob_Glob.setFrobable(0); 
		sys.println("Duck points at max: "+duck_points);
		}
		
}

//the frob S/R on "frobglob" points to this code
void execute() {
	fetchFrob_Glob();
	spawnBloodVial();
} 

and then, again, in tdm_custom_scripts.script, the custom script object:


#ifndef __CUSTOM_PLAYERTOOLS_SCRIPT__
#define __CUSTOM_PLAYERTOOLS_SCRIPT__

/*there is a bunch of cloned code from the playertools_holywater script object here,
we will just skip that and move to the part where I've made changes*/

void playertools_duckblood::inventoryUse(entity userEntity, entity frobbedEntity, float buttonState)
{
	// If we have a previous thread still running, terminate it
	if (_updateThreadNum != -1)
	{
		sys.terminate(_updateThreadNum);
	}

	// Callback to decrease the inventory stack count
	userEntity.changeInvItemCount(getKey("inv_name"), getKey("inv_category"), -1);

	// Deduct a duck point, check if the counter's maxed, make frob_glob frobable again if it isn't
	duck_points--;
	if (duck_points < 2) {
		fetchFrob_Glob();
		Frob_Glob.setFrobable(1);
		sys.println("Duck points are less than two, frobglob is frobable.");
	};
	sys.println("Duck point taken, currently at "+duck_points);	
	
	// Play the activate sound
	userEntity.startSoundShader(getKey("snd_activate"), SND_CHANNEL_ANY);
	
	// Swap the waterarrow projectiles
	userEntity.changeWeaponProjectile(getKey("weapon_name"), getKey("def_projectile_holy"));

	// Start a new script thread for updating the timer and resetting the projectile
	_updateThreadNum = thread update(userEntity);
}

#endif

 

 

Edited by Spooks

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

I didn't know that, very interesting that you can just put that on the value. I've not had to explicitly specify the map script's namespace when putting a function from there in my frob_action_script spawnargs though. Out of interest do you happen to know how you would call the map namespace in a frob_action_script if you had to? Is it just "my_map_name::my_function"? What's the name of the map namespace, that is. "<map namespace>::<function>"" tells me nothing.

The other link I dug up suggests the namespace needs to be declared explicitly if you want one. https://www.iddevnet.com/doom3/script_map.php seems to bear that out...

 

http://modsonline.com/Tutorials-read-173.html suggests that namespaces are an alternative way of setting up a map script, if you want an arbitrary location for its file.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Is it possible to have a moveable entity always face the player? even as they move the object moves to face them?

Link to comment
Share on other sites

tdm_custom_scripts.script is actually meant to include your custom scripts, which should then go into their own respective files. I mean you can also put code in there, but if you are going to use several scriptobjects things might become confusing. In addition it is harder for other mappers reusing your scripts.

 

So the default way would be to put the code in a script file like myscriptobject.script and than put the line

 

#include "scripts/myscriptobject.script"

into the tdm_custom_scripts.script file for it to get included.

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

Is it possible to have a moveable entity always face the player? even as they move the object moves to face them?

If it's a flat surface you could use deform sprite. For anything else I think a script would be needed.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

If it's a flat surface you could use deform sprite. For anything else I think a script would be needed.

 

It's a moveable entity so a model and unfortunately that wouldn't work but that is a good idea nonetheless.

 

I've been tinkering with it but I can't get it to move, i've never seen it done before (at least not that I can remember) in TDM so i'd say chances are it's not possible.

 

I remember some crow entity from a few years back that would follow the player with its head but I have no idea who has that as it would help.

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

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 0 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...