Jump to content

Levelled Item Lists or script?


Guest

Recommended Posts

Posted

Hello,

 

I took a look to levelled item lists, but it doesn't seem they do what I have in mind.

Essentially, I would like that inside a container there's an item OR another item. For what I understood, using levelled lists creates a % condition that would allow me to find both, one or no item, and it's not what I want.

 

So I thought about a workaround, attaching a script to the container, something like this:

 

OnActivate blocktype

 

if doonce == 0

   rContainer == GetSelf

   (give me a random %, if value < 50 then add item 1 to rContainer)

   (else add item 2 to rContainer)

   set doonce to 1

   rContainer.activate

 

   else

   rContainer.activate

endif

 

This should be viable, but I'm wondering if it's a good solution or if there's something easier, to not spam hundreds of scripted containers all around the worldspace.

 

ALSO, if the above script is the only viable solution:

 

- Should I use GetSelf because GetContainer should be used on a scripted item inside the container itself? Is it correct?

 

- "Because reference functions can be called on the scripted reference implicitly by omitting explicit reference syntax, the following code structure should never be used" (referred to reference.function) . It happened to me more than once, that "activate" wasn't activating the reference containing the script, on a OnActivate block. It wanted me to specify it or it wasn't working, doing nothing ingame. So I started to specify always the reference in functions (i.e. rContainer.Activate). Is it too much wrong? are there bad consequences for this, something worser than just spending 3 more seconds writing the explicit reference name on the script?

 

Thank you

Posted

I haven't tested it, but..

I think that it doesn't matter if you do specify the reference implicitly, you just shouldn't need to. I think the 'never be used' doesn't mean it will cause problems if you do.

 

The script should work, I don't think it matters if you are creating lots of them because it will only run when you activate the container. Even if for some reason the container had a GameMode block it would only run whilst you were in the cell. (Although actor GameMode blocks can run outside of it with 'no low level processing' unchecked). I believe you need to have at least one item in a container for it to not show 'empty' when you hover over it, but you can remove that with the script.

 

You can add some console print to check its all working correctly

Posted

Thank you very much Odessa. Also, the "empty" thing is a great idea, I really didn't think about it!

I was asking if there was a way to avoid that script with some... list? because my only concern is the fact every istance/variable/result of every script of every container will be saved, I don't know how much is this "limit" but I wouldn't like users having save bloats after some hour of play.

Posted

How many containers, and where? If they're all pretty much in the same place, you can put things in them when the player enters the cell, maybe.

 

Implied reference should be fine; maybe earlier trouble with that had to do with the rest of the activate syntax - there's the actionref to specify or not, the flag for bypassing usual activation or not, etc.

Posted

Doctasax, I would say "many containers". Think to clutter as fridge, oven, but also many other new, in both internal cells and worldspace, about 400 cells. Every type has its own script, because the items contained are different.

 

But I didn't get what do you mean with ActionRef. I will specify that the action works only with the player, if it is what you were meaning, or who knows what could happen... there are so many possibilities that I probably would put me in trouble if I don't do that.

 

What flag bypasses usual activation? I remember if using a OnActivate block attached to a container was automatically executing the code in the script and not opening it until I wasn't specifying Activate... am I missing something?

Posted

That many cells? Is this meant to override vanilla containers then? If so, that's a prime source of conflicts.

 

specifying the actionref: i meant instead of

rContainer.activate

you go

rContainer.activate playerref

 

The flag, forget I said anything. If you call activate from an OnActivate script block on a container's object script, it doesn't have to/shouldn't be set anyway.

Posted

I said a wrong thing, those were Chunks. Cells are around 4500+, I just checked on LOD details. But well it's just to give an idea of why there are many containers. Anyway I don't want to override vanilla, they all will be new IDs in the new worldspace.

 

rContainer.activate playerref

I just ask for curiosity, is it very different than putting if (GetActionREF == player) as first condition of the OnActivate block? or is it better if I use both of them?

 

Thank you Viktoria, I'll try that, but it should not give me the result I want. If I put my two items in a leveled list with 0% chance of none, I think the result is between 3 cases: Item A, or Item B, or Item A and Item B; what I want is Item A or Item B. Anyway I really want to try it, I'm quite ignorant on leveled lists.

Posted

No Vik, still didn't try because I must go out and I'm in late, but I'll do it as soon as I go back home. So are you saying the solution is in the flag "Calculate for each item in count"?

 

EDIT:

Awww I couldn't go out without trying that. Maybe I found the solution and I feel shame for this... it's not in that flag (until I won't nest more leveled lists). Simply leveled lists don't calculate all the possibilities, they spawn only the number of items I put on Item Count, so if I don't put a flag like "Use all" and I put a "Count" value of 1, it will always spawn a single item and the script is pointless. God, these lists are a useful tool I never managed to understand very well, as a ton of other things, shame on me.

 

At this point I think it would be the best solution so I can stick with a lower number of scripts in execution. If someone has a known reaason why I still should still use a script I'm very glad to know that, I mean something like "no if you do that it won't work good because... (wrong probability calculation etc.etc.)"

Posted

No Vik, still didn't try because I must go out and I'm in late, but I'll do it as soon as I go back home. So are you saying the solution is in the flag "Calculate for each item in count"?

 

The Chance None is sure for avoid to get zero items in the container, then I chose to go with Calculate for each item in count and worked out at the first try but shouldn't matter this one. 

 

Essentially, I would like that inside a container there's an item OR another item.

 

Tested on 50 fridges and the simple thing did the job, one item OR another item, no zero items, no both. So should be fine.

 

 

so if I don't put a flag like "Use all" and I put a "Count" value of 1, it will always spawn a single item and the script is pointless. God, these lists are a useful tool I never managed to understand very well, as a ton of other things, shame on me.

Yes, I used too count 1 and obviously "Use all" is to avoid. And yes, they are useful indeed! :)

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...