Forum

> > Stranded II > Scripts > Better option for crafting unique items?
Forums overviewStranded II overview Scripts overviewLog in to reply

English Better option for crafting unique items?

4 replies
To the start Previous 1 Next To the start

old Better option for crafting unique items?

Fafhred
User Off Offline

Quote
By that, I mean craftable once only.

At the moment I see 3 possible ways, but I would like to know if there is a simpler way.

Options I see:
- crafting counter for that item, denied if count is reached.
- lockcombi at the end of first crafting action (more elegant way).
- one-off digging event instead of crafting (simpler but no crafting).

What I would really prefer is a lock on the object already existing or not, but so far I do not see a way for that.

Planned usages: map, watch (I do not remember if it actually gave the time).

old How To Build A Script II

JasJack67
Super User Off Offline

Quote
You can make a variable that is always 0 or 1. You can put this variable in the game.inf file at the top with the other variables under the ON:START section. Don't put it in the ON:LOAD section or it will be reset to 0 every time the player loads a save.

$locked=0;


now in the script you ask if that variable is 0, if it is, then do the craft. If it is 1 then you can not do the craft.

1
2
3
if($locked==0){
    //craft/combo the item goes here
}

So you start out and make the item (cuz variable = 0) and upon making the item you set the variable to 1. (variable=1)

1
2
3
4
if($locked==0){
    //craft/combo the item goes here
    $locked=1;
}

Now when the player goes to make it again, and the script asks if the variable is 0 it will not be...so the script ends there, or send the player a message in script.
1
2
3
4
5
6
7
if($locked==0){
    "craft/combo the item"
    $locked=1;
}else{
    msg "I have already crafted this!",3;
    speech "negative";
}
edited 2×, last 29.01.17 10:31:18 am

old Re: Better option for crafting unique items?

Fafhred
User Off Offline

Quote
Basically this is one way to code my first option detailed, and again I did not need you to write a code example for it.
What I was asking for was just suggestions for a better method than the 3 I could already see, and more importantly if there is anything in the script language (not the code, the command and its syntax) allowing me to know if a given item already exist; something like a hard-coded counter for the number of exiting items of a given type.

I already have a number of new and unlocked items with recipes in my WIP, all tested and working fine.
How to make a new item was nowhere near my question.

old Re: Better option for crafting unique items?

JasJack67
Super User Off Offline

Quote
Yes there is, you can use the count command to count how many items, or units, or objects, or even timers...are in existence.

$tmp=count(item,ID);

then use $tmp as the count in your script.

> http://www.strandedonline.de/s2_commands.php

p.s. Please keep in mind that when I post, I post with the thought that other people will be using the SEARCH option to find answers to their questions in this forum...this is why I post answers the way I do...some info i throw in there for that one person who is looking for similar/related info...it is not intended to belittle or patronize YOU, just to inform/help future members when they land on my posts through searches.
edited 1×, last 29.01.17 11:35:01 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview