Jump to content

[LE] [Script] "AND" or "OR" operator help


anb2004

Recommended Posts

I'm dumb with script, so bear with me.

Already set a trigger for auto sorting 2 different armor in player inventory and stored which is set by a script.

  if (akActivator.getItemCount(ArmorA) >= 1) && (akActivator.getItemCount(ArmorB) >= 1); Player have the items? 

That goes well if player has both items in the inventory but what if there is only one of the armor ? fiddling it around still no avail. How to expand it so it can auto sorting with only one of the armor please

 

Thank you.

 

Link to comment
Share on other sites

if (akActivator.getItemCount(ArmorA) > 0) || (akActivator.getItemCount(ArmorB) > 0); Player has just one of the items?

That should do it. :smile:

 

I've changed the evaluation to

> 0

as

>=

are actually two types of evaluations (greater and equal), which is a bit more demanding.

It shouldn't be that big of a deal, but as long as you don't really need the ">=" evaluation, I recommend to just use the ">" with asking if it is greater than 0. :wink:

 

 

You can read more about operators here:

https://www.creationkit.com/index.php?title=Operator_Reference

:)

Link to comment
Share on other sites

  On 2/26/2020 at 1:28 PM, SurfsideNaturals said:

 

  On 2/26/2020 at 1:05 PM, anb2004 said:

Good lord that simple !

 

When doing something like this use "else" .

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)

Else
; Do something here.  You do not have both items.  

EndIf

It would be best if you included your entire script.

 

That Else block would fire too, if the item count of both items is 0.

So it is not totally equivalent with the OR operator.

 

 

 

 

  On 2/26/2020 at 1:05 PM, anb2004 said:

Thank you JustChill :thumbsup:

No worries, you are welcome.

 

However, SurfsideNaturals is right about posting more context. :wink:

 

As if you want to have a different behavior when the player has BOTH items in inventory and when there is just ONE of them in the inventory.

 

 

In that case an ElseIf with my example would be necessary too.

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)
; 'Do something here if the player has both items.'
ElseIf akActivator.getItemCount(ArmorA) || akActivator.getItemCount(ArmorB)
; 'Do something else here, when only one of these items is in the players inventory.'
Else
; 'Do something else here. You do not have any of the items.'
EndIf

In addition to that, you could either go

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)
; 'Do something here if the player has both items.'
ElseIf akActivator.getItemCount(ArmorA)
; 'Do something else here, when only ArmorA is in the inventory.'
Elseif akActivator.getItemCount(ArmorB)
; 'Do something else here, when only ArmorB is in the inventory.'
Else
; 'Do something else here. You do not have any of the items.'
EndIf

Yet as we don't exactly know what you are up to, any solution that fits your needs might do it. ^^

 

Anyways, happy modding. :smile:

Link to comment
Share on other sites

  On 2/26/2020 at 1:28 PM, SurfsideNaturals said:

 

  On 2/26/2020 at 1:05 PM, anb2004 said:

Good lord that simple !

 

When doing something like this use "else" .

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)

Else
; Do something here.  You do not have both items.  

EndIf

It would be best if you included your entire script.

 

 

Sorry about that.

 

  Reveal hidden contents

 

 

It's not my script but a modified script originally made by Sjogga Dragon Claw holder that i enquire years ago (ebony_ivory is my old nickname) which i try to apply it with static mannequin because real mannequin is just buggy for me and i like it fast and simple (though, make it requires lots of work but i enjoyed it) no more opening mannequin inventory, simple activate, armor get unequipped/equipped. Not into armors also helped, still using same old custom hide (TehArmor) and custom iron armor (TehArmorB), i just haven't made the static for gauntlets, boots and helmets tho.

 

Just found "equipitem" just won't add the enchantment effect. Another disappoinment :wallbash:

 

Thanks

 

  On 2/26/2020 at 2:04 PM, JustChill said:

 

  On 2/26/2020 at 1:28 PM, SurfsideNaturals said:

 

 

When doing something like this use "else" .

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)

Else
; Do something here.  You do not have both items.  

EndIf

It would be best if you included your entire script.

 

That Else block would fire too, if the item count of both items is 0.

So it is not totally equivalent with the OR operator.

 

 

 

 

  On 2/26/2020 at 1:05 PM, anb2004 said:

Thank you JustChill :thumbsup:

No worries, you are welcome.

 

However, SurfsideNaturals is right about posting more context. :wink:

 

As if you want to have a different behavior when the player has BOTH items in inventory and when there is just ONE of them in the inventory.

 

 

In that case an ElseIf with my example would be necessary too.

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)
; 'Do something here if the player has both items.'
ElseIf akActivator.getItemCount(ArmorA) || akActivator.getItemCount(ArmorB)
; 'Do something else here, when only one of these items is in the players inventory.'
Else
; 'Do something else here. You do not have any of the items.'
EndIf

In addition to that, you could either go

if akActivator.getItemCount(ArmorA) && akActivator.getItemCount(ArmorB)
; 'Do something here if the player has both items.'
ElseIf akActivator.getItemCount(ArmorA)
; 'Do something else here, when only ArmorA is in the inventory.'
Elseif akActivator.getItemCount(ArmorB)
; 'Do something else here, when only ArmorB is in the inventory.'
Else
; 'Do something else here. You do not have any of the items.'
EndIf

Yet as we don't exactly know what you are up to, any solution that fits your needs might do it. ^^

 

Anyways, happy modding. :smile:

 

 

To be honest those makes me even more confused :unsure: but let see if i can fiddle with it.

 

Thanks

Link to comment
Share on other sites

Hm,

I cannot agree with his script being a mess.
Especially as there is no unified way of how to write scripts. If they work, they work.
That's actually the main goal of writing a script, I guess. ^^


@ anb2004
I've read your code and I assume you try to put the armor onto the mannequin and remove it again, when activating.

The only issue I have is, are these two different types of armor or are these just two pieces of armor that can be combined with each other?
As in your screen, I see two different tops, but the same bottoms.

Do you only focus on the tops here?
Where "TheArmor" is one top and "TheArmorB" is the other one and the mannequin has these bottoms per default?

The reason why I am asking this is, that you try to equip both armors at the same time. XDDDD
So, I guess if these are really just the tops you've overthought it here.
No worries, I overthink things either pretty often, SurfsideNaturals knows about. :D

I simply continue my assumptions from the start, that these mannequins are used to display just these two types of tops.

  Reveal hidden contents






In addition:

  On 2/26/2020 at 4:41 PM, anb2004 said:

still using same old custom hide (TehArmor) and custom iron armor (TehArmorB), i just haven't made the static for gauntlets, boots and helmets tho.

Ah sorry, I just read that now.

That makes it a bit more complicated, when you add the other parts either as a linked reference.

Let me think over again. ^^



Another addition:

  Reveal hidden contents




I hope it works. oO

I haven't worked on my own with linked references with keywords before, but I guess this is the only way to check for specific linked references when there are multiple ones.

Anyways, here you add a keyword to a linked reference (LINK).

 

Oh and don't forget to add the message box with 2 buttons (first one = "Add armor pieces to mannequin", second = "Remove armors pieces from mannequin").

You can also add a third button as "Cancel". It will work right away. ^^

This message box only comes, when you have armor pieces in your inventory and there are still some free slots (but also armor pieces in some slots) on the mannequin.

 

If the mannequin is empty you will add all your armor pieces without being asked for.

 

If the mannequin is fully geared, you get all armor pieces back without a question.

 

I try to avoid message boxes, sometimes they are handy. :smile:

Decisions, decision... :wink:

 

 

Also add only one of each armor piece to one mannequin (5 in total)

You can add both body armors overlapping each other in the Creation Engine.

The script will only activate one (favoring "TehArmor").

If you want to add "TehArmorB" on a mannequin be sure that "TehArmor" is not in the players inventory.

 

But if the armor is unique and you have two mannequins, that issue should solve itself. ^^

Link to comment
Share on other sites

Hmm..

 

_AnbMannekinArmorActivator

  Reveal hidden contents

 

Link to comment
Share on other sites

Wow, you both sure give me more headache with those scripts. But i get it and thank you, sincerely to both of you for pushing me to learn scripting better.

 

Wish i can change the thread title to make it more precise about what i'm trying to do, to help those that wanted to do the same thing like i did but sucks with scripting.

 

Thank you guys.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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