Jump to content

Making a script need 2 conditions


Deltagamer163

Recommended Posts

So, I'm making a terminal that allows you to check in and check out of a hotel room. The check in command is supposed to check if you have the proper caps to buy, and also check if you have a key already, and gives you a key and takes the caps if you have the proper amount.

 

The scripts work well, and if you don't have the caps it won't give a key, but I noticed that I can still check in if I have a key already.

Could somebody help?

 

Here is the code:

float capsgood

float nokey

if Player.GetItemCount Caps001 >= 50
  set capsgood to 1
else
  ShowMessage InvalidCapsTops
endif

if Player.GetItemCount TopsHotelRoomKey < 1
  set nokey to 1
else
  ShowMessage AlreadyCheckedIn
endif

if capsgood == 1 and nokey == 1
  player.additem TopsHotelRoomKey 1
  player.removeitem Caps001 50
  set capsgood to 0
  set nokey to 0
endif
Edited by Deltagamer163
Link to comment
Share on other sites

In case any new modders have a similar issue to mine, I solved the problem. It seems that if commands cannot use "and", so instead I made it so that if you have at least 1 key, it will just set "capsgood" back to 0 and tell you that you are already checked in, and then made it so that it only checks if capsgood is 1 before giving a key.

Link to comment
Share on other sites

NVSE uses the "&&" symbol for the "AND" operator in a "compound condition". The list of NVSE operators is here. The entire purpose of NVSE (and the various addons to it such as "JIP LN") is to provide modern programming functions left out of the basic GECK tool.

 

Alternatively (if you insist on not using NVSE or need to debug a complex compound conditional test) the logical "AND" operation is a single command line equivalent to a pair of nested "IF" conditional tests:

If (test1) then
  If (test2) then
    <both test statements are true>
  Else
    <test2 is false, but test1 is still true>
  EndIf
Else
  <test1 is false, and test2 was never evaluated>
Endif

The basic "IF ... Then ... ElseIf ... Else" structure is a "logical OR":

If (test1) then
  <test1 is true>
ElseIf (test2) then
  <OR test2 is true and only tested if "test1" failed>
Else
  <all previous individual tests failed>
EndIf

Considering that most mods require NVSE these days, any author insisting on avoiding it has an "undiagnosed mental condition" (in my opinion. I have yet to see a reasonable explanation for that position).

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

In case you are still a bit unsure how/what to do.

Take the FoseLoader.exe from inside the install location same place you find the Game & Geck.exe

Right click ,Make a shortcut or send to desktop ... then right click the new shortcut , select properties.

In the shortcut window it pops up on the "Shortcut" tab ...

Go to the Target field , and add at the end outside the quote

" -editor

notice there is 1 space after the quote. Click apply , OK

Now you use this shortcut every time to launch the Geck.

 

By the way that is some good thinking skills to get stuff done with what ya know.

Keep it up , it will serve you well in figuring out the nuances of the geck. ;)

Link to comment
Share on other sites

It's worth pointing out that Mktavish primarily works on FO3, so he tends to mix up FOSE and NVSE. (NVSE includes everything from FOSE.) Just use whichever is appropriate for the game you are modding.

 

The "GECK Extender" mod (recommended) has a "GECK Patcher" file "to make your GECK 4GB aware and also auto load NVSE as well as fix many bugs in the edit forms (required)". The Extender is a later replacement for the "GECK 1.4 PowerUp" mod. (Do not use both together.) Once patched, you just launch the GECK as always.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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