Jump to content

Could someone help me with my script, it doesn't seem to work.


Recommended Posts

For this quest I'm making you walk up to this stand and a menu should pop up. All those choices should give you items, but that doesn't seem to work. It's also is only supposed to show up once but it keeps showing up

This is the script I've written for it.

scn BookVendorStore

short doonce
short button

Begin ontriggerenter player

ShowMessage CinnamorollBookMessage

end

begin menumode

set button to getbuttonpressed

  if (doonce ==0)
  if (button == 0)
   player.additem CinnamonBeeBook 1
   player.additem CinnamonBeeBook2 1
   player.additem CinnamonBeeBook1 1
   player.additem CinnamonBeeBook9 1
   player.additem CinnamonBeeBook8 1
CinnamonMickOne.Disable
CinnamonMickTwo.Disable
CinnamonMickThree.Disable
CinnamonRyanOne.Disable
CinnamonRyanTwo.Disable
endif

 if (button == 1)
   player.additem CinnamonBeeBook4 3
   player.additem CinnamonBeeBook5 1
   player.additem CinnamonBeeBook6 1
CinnamonEJamesOne.Disable
CinnamonEJamesTwo.Disable
CinnamonEJamesThree.Disable
CinnamonEJamesFour.Disable
CinnamonEJamesFive.Disable
 endif

 if (button == 2)
   player.additem CinnamonBeeBook 1
   player.additem CinnamonBeeBook2 1
   player.additem CinnamonBeeBook1 1
   player.additem CinnamonBeeBook9 1
   player.additem CinnamonBeeBook8 1
   player.removeitem caps001 125
CinnamonMickOne.Disable
CinnamonMickTwo.Disable
CinnamonMickThree.Disable
CinnamonRyanOne.Disable
CinnamonRyanTwo.Disable
 endif

if (button == 3)
 player.additem CinnamonBeeBook4 3
 player.additem CinnamonBeeBook5 1
 player.additem CinnamonBeeBook6 1
 player.removeitem caps001 125
CinnamonEJamesOne.Disable
CinnamonEJamesTwo.Disable
CinnamonEJamesThree.Disable
CinnamonEJamesFour.Disable
CinnamonEJamesFive.Disable

endif
set doonce to 1
endif
end

Can someone help me fix it?

Link to comment
Share on other sites

Please review "TIP Basic conditional test syntax" regarding "indentation". When you post "code" in the forum, be sure to place it within a "code tag" (the blue "<>" icon in the menu bar of the "Reply Topic" window) so it will retain that indentation. That will let us tell if you have a conceptual logic problem.

 

Basically every layer of "nesting" should be bounded by an "If ... EndIf" pair, with the optional "Else" statement separating some sets at the same level. (An "Else" is ALWAYS implied in a conditional test; just not always explicitly present. Personally I like to place one in a comment (i.e. "; Else (do nothing)") just so I know I considered the situation later on. The way it is now, can't tell clearly.

 

Also review the "TIP Block Types Multiple vs Single Frame processing". "OnTriggerEnter" is a single-frame block. Your "doonce" variable is not having the effect you intend as it is being set and cleared in the same frame. You need to rethink what is it controlling and (probably) move that first conditional test out into your multi-frame block (probably your "quest script").

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Please review "TIP Basic conditional test syntax" regarding "indentation". When you post "code" in the forum, be sure to place it within a "code tag" (the blue "<>" icon in the menu bar of the "Reply Topic" window) so it will retain that indentation. That will let us tell if you have a conceptual logic problem.

 

Basically every layer of "nesting" should be bounded by an "If ... EndIf" pair, with the optional "Else" statement separating some sets at the same level. (An "Else" is ALWAYS implied in a conditional test; just not always explicitly present. Personally I like to place one in a comment (i.e. "; Else (do nothing)") just so I know I considered the situation later on. The way it is now, can't tell clearly.

 

Also review the "TIP Block Types Multiple vs Single Frame processing". "OnTriggerEnter" is a single-frame block. Your "doonce" variable is not having the effect you intend as it is being set and cleared in the same frame. You need to rethink what is it controlling and (probably) move that first conditional test out into your multi-frame block (probably your "quest script").

 

-Dubious-

scn BookVendorStore

short doonce
short button

Begin ontriggerenter player

ShowMessage CinnamorollBookMessage

end

begin GameMode

set button to getbuttonpressed

  if (button == 0)
   player.additem CinnamonBeeBook 1
   player.additem CinnamonBeeBook2 1
   player.additem CinnamonBeeBook1 1
   player.additem CinnamonBeeBook9 1
   player.additem CinnamonBeeBook8 1
   CinnamonMickOne.Disable
   CinnamonMickTwo.Disable
   CinnamonMickThree.Disable
   CinnamonRyanOne.Disable
   CinnamonRyanTwo.Disable
   rewardkarma -75
endif

 if (button == 1)
   player.additem CinnamonBeeBook4 3
   player.additem CinnamonBeeBook5 1
   player.additem CinnamonBeeBook6 1
   CinnamonEJamesOne.Disable
   CinnamonEJamesTwo.Disable
   CinnamonEJamesThree.Disable
   CinnamonEJamesFour.Disable
   CinnamonEJamesFive.Disable
   rewardkarma -80
endif

 if (button == 2)
   player.additem CinnamonBeeBook 1
   player.additem CinnamonBeeBook2 1
   player.additem CinnamonBeeBook1 1
   player.additem CinnamonBeeBook9 1
   player.additem CinnamonBeeBook8 1
   player.removeitem caps001 125
  CinnamonMickOne.Disable
  CinnamonMickTwo.Disable
  CinnamonMickThree.Disable
  CinnamonRyanOne.Disable
  CinnamonRyanTwo.Disable
   rewardkarma 75
endif

if (button == 3)
   player.additem CinnamonBeeBook4 3
   player.additem CinnamonBeeBook5 1
   player.additem CinnamonBeeBook6 1
   player.removeitem caps001 125
   CinnamonEJamesOne.Disable
   CinnamonEJamesTwo.Disable
   CinnamonEJamesThree.Disable
   CinnamonEJamesFour.Disable
   CinnamonEJamesFive.Disable
   rewardkarma 50
endif
end

Here's my script again without doonce but I have no idea what to replace it with.

Link to comment
Share on other sites

Much clearer now. Though I do have some questions regarding your intent as I see it implemented in the code. (Nothing obviously wrong with the code syntax itself.)

From the presence of the "doonce" you appear to only intend for the Player to interact with this script one time? And in that one visit they will choose one (and only one) button among four? And that choice will add 5 books to the Player's inventory, and give a "karma" reward or loss, while at the same time "disabling" 5 "objects" (presumably the bookshelved items) ALL AT ONCE? Except in two choices (buttons 2 & 3) you are also removing caps/coins from the Player.

Proceeding from that logic, the "doonce" needs to be defined in the quest script (see TIP Best Practice Sharing Variables between Scripts) and set to the "test value" in this script (i.e. "set doonce to 1", generally placed at the bottom after the final "endif", but before the "end" line) so it is the last thing done. (Technically it could be placed anywhere after this script's "Begin" line, as it does not logically depend upon any button being pressed, but you want to keep things "logical" when you look at it six months later.) I would recommend you turn all of the "if (button)" lines except the first into "ElseIf (button)" because you will only get to press it once and you don't have anything defined for what to do if none are pressed in an "Else" statement. As this is running in "GameMode", it is being processed every frame/tick and the button may not have been pressed by the "slow human" yet.

(Optionally: You might want to consider use of the NVSE While function, or the non-NVSE equialent, to create a "loop" to check for the button being pressed. Also look into the Adding an Options Menu page.)

In the quest script you will use a conditional test for the ABSENCE of value that set in this script, and only call this script if it is NOT set (e.g. "if 0 == doonce"). How you "call" the script depends upon how you intend to "trigger" it in the quest: by "Activating" an object such as a door to the shop, or when an Actor speaks a line of dialog (in a "result script" for that line). So you are going to want to have an "Else" for that conditional test to take effect when the value of "doonce" is equal to "1" and the test fails.

 

Keep at it. You are making progress.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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