Forum

> > Stranded II > Mods > Food spoilage
Forums overviewStranded II overview Mods overviewLog in to reply

English Food spoilage

4 replies
To the start Previous 1 Next To the start

old Food spoilage

Malzar
User Off Offline

Quote
Hello How to make the change from one item to another in player's inventory?
Eg replacement of fresh meat on rotten meat.

In stores, I realized how to do, but how I do not know in a backpack.

old Re: Food spoilage

Hurri04
Super User Off Offline

Quote
s2 cmd alteritem
but there is no reliable way to do this for every single item of the same type as they cannot save stats when they stack like e.g. the info when they were created.
using timers would slow the game down en masse and also has the problem that when sleeping the time on the clock jumps forward but the timer doesnt.

many tried this before but the best that could have come up with was a random selection.
e.g. there also was an item like "jar filled with strawberry jam" in the extension mod(?) and they wanted to store 3 portions in it so the result was that on use it would roll a dice from 1 to 100 and if it was smaller than 33 then the jar would empty

but once Stranded 3 comes out this will be possible properly as it allows items to store stats individually.

old Re: Food spoilage

JasJack67
Super User Off Offline

Quote
hmmm...

you could just use "count_stored unit 1, item fresh meat" and set that "returned" number to a variable...like $tmp1..let say you had 10 fresh meat so $tmp1=10.

then delete "free" all of fresh meat "free_stored unit 1, item fresh meat($tmp1)" item from your inventory.

assign your rotted meat amount count, to another variable like $tmp2... say you wanted to have 4 of the meat go bad...so $tmp2=4.

now:
"create" item ID "the rot $tmp2(4 bad meat)" at the unit,1 position $x,$z, then store the ID "the 4 rot $tmp2" in unit,1....unit 1 now has 4 rotted meat.

then:
"create" item ID the "fresh meat count $tmp1(10good meat) - rotted meat count $tmp2(4bad meat)=$tmp3(6goodmeat)" or simply ($tmp1-$tmp2=$tmp3) the same way at unit,1 x,z position...and then store the ID($tmp3) in unit,1. Now unit 1 the player, has 4 rotted meat and 6 fresh meat instead of 10 fresh meat.

edit: here is an example of the above but a more thought out version.
1
2
3
4
5
6
7
8
9
10
11
12
local $x,$z,$id,$tmp1,$tmp2,$tmp3,$tmp4;
$x=getx("unit",1);
$z=getz("unit",1);
if (this condition is true or false) {
        $tmp1=count_stored("unit",1,FreshMeatID);       //if he has 10 $tmp1=10
        $tmp2=4;                                        //the rotted meat count if you want for $tmp2=4
        $id=create("item",RottedMeatID,$x,$z,$tmp2);    //create the 4 rotted meat at player postion x,z
        store $id,"unit",1;                             //store the ID 4 rotted meat in the players backpack
        $tmp3=$tmp1-$tmp2;                              //6=10-4
        $tmp4=$tmp1-$tmp3;                              //4=10-6
        freestored "unit",1,FreshMeatID,$tmp4;          //delete $tmp4...your simply deleting 4, leaving 6 in the backpack
}

now the player has 4 rotted meat and 6 fresh meat
edited 5×, last 21.07.14 05:49:48 pm

old Re: Food spoilage

Hurri04
Super User Off Offline

Quote
@user JasJack67: your example is way too complicated again and it missed the point of what I said:
changing the type is not a problem but knowing when to do this is.

let's say you pick up
• 2 meat on day 1
• 5 meat on day 2
• 3 meat on day 3
• ...

if you want them to go bad after the same amount of time (+/- a slight s2 cmd random variance), you'd have to start a timer each time a piece of meat is created.

just as an example, let's say the meat goes bad after just two days:
• on day 1 you start 2 timers
• on day 2 you start 5 timers so you have 7
• on day 3 you start 3 timers so you have 10 and after that the 2 timers from day 1 time out which still leaves you with 8 timers
• ...

this could of course be optimized to only create 1 timer when multiple pieces of meat are created at once by saving the number.
but at least when there is an hour between the creation of 2 pieces of meat you'd have to start another timer.


then there is the problem with sleeping as I mentioned earlier.


and not to forget:
assuming that you also eat some of the meat, does that mean that the player always eats the oldest meat first, thus decreasing the counter for the pieces of meat which are going to go bad next? anything else could lead to problems, such as that the game lets meat go bad which timer hasnt counted down yet or tries to replace fresh meat with bad meat when you dont even have any meat left anymore.
edited 1×, last 21.07.14 09:27:51 pm

old Re: Food spoilage

JasJack67
Super User Off Offline

Quote
oh yes...i do see your point now. hmmm...yeah that makes sense.

every piece of meat would have to have it's own variable assigned it seems. Then track the days++ for each. That would be pretty dam redundant in script.

if there was a lower limit attached to a player for, how many pieces he could have in storage, then this could be feasible.
If he could only have x amount then it could be done.

But unlimited or anything above 25-30 would be a time consuming script i think. would lag probably.
To the start Previous 1 Next To the start
Log in to reply Mods overviewStranded II overviewForums overview