rezecib

[Guide] Getting started with modding DST (and some general tips for DS as well)

Recommended Posts

Kajshi    0

Hello.

I can't find any info about how to set variable amount of items.

My mod (only own use) base on  Auto Planting

In contradistinction to "Auto planting" my mod don't planting items at offset algorithm, but return so much new items as much as I put to container.

And there is in "Auto planting"-mod such code:

if inst.components.container:Has("dug_sapling", 1) then
	inst.components.container:ConsumeByName("dug_sapling", 1)
	inst.plants = "sapling"
	GLOBAL.ThePlayer.components.inventory:ConsumeByName("nightmarefuel", amount)
end

Instead number (there it is 1), I want use variable amount "n", which I will set as "local n = I don't know what code to use here".

I tried to use "local n = self.obj.components.stackable:StackSize()", but it don't work.

And so here is my question: how to set variable amount of items, that based on  the amount of items that I'm going to put in the container. I don't want to set a fixed amount of items, because with each use, amount of items will be different, depending on how many I want use.  

Sorry for my bad english. It's not my native language.

Share this post


Link to post
Share on other sites
Lumina    1,499
16 hours ago, Kajshi said:

 

I can't find any info about how to set variable amount of items.

For specific problems it's better to have specific topics.

Share this post


Link to post
Share on other sites
9bjames    0

Hey, new to modding, blah blah blah...

Found this thread really helpful as a starting point, but just wanted to ask if gates are part of that "currently not (nicely) moddable" list. Had a few gate related mod ideas; minor tweaks, new mechanics, different kinds of gates etc.; so I've been searching online/ looking through the Lua scripts to find the best approach.

I'll make my own topic if I need to pick people's brains too much, but just wanted to confirm: am I right in thinking gates cannot currently be tweaked/ built upon too much without scripting them from scratch?

Thankyow =P

Share this post


Link to post
Share on other sites
Lumina    1,499

Hard to say, there are gates now since a ANR update, so maybe it's easier to tweak now ?

  • Like 1

Share this post


Link to post
Share on other sites
9bjames    0
Posted (edited)

Well looking through the scripts there's nothing in prefabs for fence gates. The best I've found is a zipped file under "data\anim\fence_gate.zip". I'd be surprised if there isn't anything for gates in the scripts, but if there is I'm just not seeing anything.

Also I'm guessing if it's under compiled code then it's pretty much off-limits, right?

Edited by 9bjames

Share this post


Link to post
Share on other sites
9bjames    0

Yeah, I've seen some custom gate mods and have already considered asking to use parts of their code if "vanilla" fence gates are inaccessible. Anywho, I'll keep looking and move this to another topic if I decide to pursue it. Sounds like it'll be more work than I first imagined at any rate. Just like anything in programming... yay... ._.

Share this post


Link to post
Share on other sites
Lumina    1,499
8 hours ago, 9bjames said:

Well looking through the scripts there's nothing in prefabs for fence gates.

fence.lua seems to contain fence and fence_gates.

Also, the code looks pretty complex.

 

8 hours ago, 9bjames said:

Also I'm guessing if it's under compiled code then it's pretty much off-limits, right?

I don't understand what it means.

  • Like 1

Share this post


Link to post
Share on other sites
9bjames    0
Posted (edited)

Hah, fence.lua... updated DST today and there it is plain as daylight... Either I'm blind or things have been changed around a bit (correction, I'm definitely blind).

At any rate, by compiled code I meant anything that's in the core "compiled" part of the game written in C++, as opposed to the parts scripted in Lua. I'm not the most experienced programmer so I could be wrong, but I'm pretty sure compiled code is, at best, a pain to get into/ modify.

Edited by 9bjames
grammar

Share this post


Link to post
Share on other sites
mikesmullin    13

More detail on Replicas

## EntityScript Replica Components

Replicas only affect the component values of an EntityScript.

Adding components to entities is straight-forward,
for example:

```
	local e = CreateEntity();
	e:AddComponent("named");
	assert(e.components.named == require("components/named"));
```

By default all components are designed to operate locally.
For example, if the following line were evaluated only by
the client, it would not change the value for the same
component on the same entity on any other simulator on the
network:

```
	e.components.named:SetName("SecretBilly");
```

For every component that requires network synchronization,
a components/*_replica.lua is created. The name is also
registered via AddReplicableComponent().

While the original component and replica component may
share the same interface, the replica's job is to sync
its data so all machines in the network receive the same
values, using netvars and RPC. For example, if the server
evaluates the following code, all clients with a copy of
the same entity will receive the same changes to their 
component values, as well:

```
	// component names listed in REPLICATABLE_COMPONENTS list
	// automatically have their replica components added to 
	// the entity during the AddComponent() step above.
	assert(e.replica.named == require("components/named_replica"));
	e.replica.named:SetName("EverybodyKnowsBilly");
```

The named component is a real example, so read its source
for more detailed examples.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now