Jump to content

Problems with Message scripting


Vandrosch

Recommended Posts

Hi Folks,

 

so for some days i´ve been trying to build my first mod ever (yeah i´m a damn noob *lol) - a reconsideration of the repair-system. We may call it a "portable repair device"... (still working on the final name/description)

 

So I created a new Misc Item, some MESG, Some notes etc. and 1 Script

 

What it does atm:

>>If the new item is added to Inventory - add Note (works) - wanted!

then>> If this item is dropped and activated - show Message 1 (works) - wanted!

then>> If Buttons in Message 1 get clicked - remove Item X and add item Y (works) - wanted!

then>> Show Message 2 (Message 2 has only ONE Button) (works) wanted!

then>> If this button is clicked the placed item goes back to inventory - I DO NOT WANT THAT ;-) ... instead I´d wish to show Message 1 Again...

 

So is it possible to "combine" 2 Messages in a Script like

>Show me Message 1

>Press Button in Message 1

>Show me Message 2

>Press Button in Message 2

>Show me Message 1 again

and so on?

 

Add here is my script (not the whole one... just the problematic lines) so far :-)

 

 

begin onactivate

set passSkill to 15

if (IsActionRef player == 1)

if player.getav repair >= passSkill

showmessage SchematicsSparePartSetSmallGunMsg ;if skill is >=15 this message shows up (works how it should)

elseif showmessage SchematicsSparePartSetSmallGunFailMsg ; if skill is <15 this message shows up (works how it should)

endif

endif

end

 

 

Begin GameMode

if IsActionRef player == 1

activate

endif

 

set Button to GetButtonPressed

 

As i wanted these buttons from the message apear if the player´s skill is high enough

 

if button == 0 first button in the Message - works

If (getitemCount Paintgun > 0) && (getitemCount MotorcycleHandbrake > 0) && (getitemCount spareparts > 0)

ShowMessage SparePartSuccessMsg

 

So here is the problematic point... If i click on the buttons in Message 1 all this player.removeitem and player.additem stuff is working fine and ShowMessage SparePartSuccessMsg works, too.. BUT i´d like to return to THIS SchematicsSparePartSetSmallGunMsg (First Message) message after clicking on the button in SparePartSuccessMsg (Second Message)

 

Player.removeitem PaintGun 1

Player.removeitem MotorcycleHandBrake 1

Player.removeitem SpareParts 1

Player.additem SmallGunSpareParts 1

PlaySound UIRepairWeapon

endif

endif

 

if button == 1

 

and so the script goes on :-)

 

I hope you undestand my problem

Please help me i´m getting :wallbash:

 

Greeting Van

Link to comment
Share on other sites

Now the script looks like this... and it works just fine in my RecycleToRepair Mod.... well i don´t now wether this is a "good looking" script or not... but it works :-)... this is not the entire script... just 3 example buttons...

 

This script does:

 

When the item is optained for the first time

- The "schematicsSparePartSetSmallGunNote" Note is added if the player hasn´t got this note yet.

if player.gethasnote SchematicsSparePartSetSmallGunNote == 0

- If the player already has the note... no note is added

 

To activate the item has to be dropped from the inventory.

If activated the Script checks wether a particular Skil is high enough to use the item.

In this case it´s the repair Skill that has got to be 15 or higher

(SetPassSkill)

 

If the players Repair Skill is >= (higher or equal) 15 the Menu

SchematicsSparePartSetSmallGunMsg is shown and can be used.

Else (so if the Skill is < (less) 15 the Fail Message is shown and the item goes back to the inventory.

 

In the Message SchematicsSparePartSetSmallGunMsg there are buttons from 0 to 7.

Button == 0 to button == 6 have a scripted functions

 

--------------------------------------------------------------------

scn SchematicsSparePartSetSmallGunScript

 

short button

short HasItems

short passSkill

short buttonpressed

 

begin onadd

if player.gethasnote SchematicsSparePartSetSmallGunNote == 0

player.addnote schematicsSparePartSetSmallGunNote

endif

end

 

begin onactivate

set passSkill to 15

if (IsActionRef player == 1)

if player.getav repair >= passSkill

showmessage SchematicsSparePartSetSmallGunMsg

else

showmessage SchematicsSparePartSetSmallGunFailMsg

endif

endif

end

 

Begin gamemode

if IsActionRef player == 1

activate (4)

endif

 

; (1) this cannot be true when no button in the message was pressed

if buttonpressed == -3

showmessage SchematicsSparePartSetSmallGunMsg

endif

 

set buttonpressed to -1 ; (2) this is true when the last button in the message was pressed

 

set button to GetButtonPressed

 

elseif button == 0

if (player.getitemCount Paintgun >= 1) && (player.getitemCount MotorcycleHandbrake >= 1) && (player.getitemCount spareparts >= 1)

ShowMessage SparePartSuccessMsg ; Simply says, that the Button has done what it should do

Player.removeitem PaintGun 1

Player.removeitem MotorcycleHandBrake 1

Player.removeitem SpareParts 1

Player.additem SmallGunSpareParts 1

PlaySound UIRepairWeapon

set buttonpressed to -3 ; this makes (1) TRUE! and the Message SchematicsSparePartSetSmallGunMsg is shown again!

endif

endif

 

elseif button == 1

if (player.getitemcount Weap10mmPistol >= 1)

ShowMessage SparePartSuccessMsg

player.removeitem Weap10mmPistol 1

player.additem SmallGunSpareParts 3

PlaySound UIRepairWeapon

set buttonpressed to -3

endif

endif

 

elseif button == 2

if (player.getitemcount Weap10mmPistolSilenced >= 1)

ShowMessage SparePartSuccessMsg

player.removeitem Weap10mmPistolSilenced 1

player.additem SmallGunSpareParts 3

PlaySound UIRepairWeapon

set buttonpressed to -3

endif

endif

 

; goes to button == 6

 

;the last Button (would be button == 7) in SchematicsSparePartSetSmallGunMsg is empty and so (2) is TRUE!

; and so the item is simply activated (4) which sends it back to the inventory.

; if any other button in the Message is pressed, (1) is TRUE and the Script starts again....

 

end

 

---------------------------------

Hope this is understanable :-)

 

 

At the moment i am trying to write a script with a Main Menu and several sub menus ... but i cannot figure out how to configure the buttons in the submenus :-( if anyone has an idea i´d be clad to here it :-)

Link to comment
Share on other sites

I tried setting up sub-menus earlier today but didn't have time to really get it working. It went crazy on one script, so I think I'll try setting up a different quest and script for each sub-menu. Each one will check for a variable on the master script for when to show the new message; something like this on the master...

 

if buttonpressed == 1

set showmessage1 to 1

endif

 

Then on the slave...

 

if masterscript.showmessage1 == 1

showmessage message1

endif

 

It would also need a check to keep from running all of the time.

Link to comment
Share on other sites

Hmmm sounds good i think.... i´ll test that, but i don´t know wether you can make one script check another script...

 

tested it.... does not work this way :-(

 

i tried this....

 

MASTER

scn ArmorRecycleHiTecScript

 

short button

short buttonpressed

short showmessage1

 

begin onactivate

if (IsActionRef player == 1)

showmessage Main Menu

endif

end

 

 

Begin gamemode

 

if IsActionRef player == 1

activate

endif

 

if button == 0

set showmessage1 to 1

endif

 

end .... works - the menu is shown when the item is activated....

 

SLAVE

scn Menu1SCRIPT

 

short button

short buttonpressed

short showmessage1

 

 

Begin gamemode

 

set button to getbuttonpressed

 

if armor ArmorRecycleHiTecScript.showmessage1 == 1

; i also tried if showmessage1.ArmorRecycleHiTecScript == 1

showmessage MENU1

endif

end

 

Problem:

- if ArmorRecycleHiTecScript.showmessage1 == 1 GECK says:

Unknown variable or function "Showmessage1"

- if showmessage1.ArmorRecycleHiTecScript == 1 GECK says:

Unknown variable or function "ArmorRecycleHiTecScript"

 

So it seems, that the two scripts don´t work together... or there might be a command to let them refere to each other...

 

D´OH!

 

there´s gotta be a way to do that....

Link to comment
Share on other sites

So it seems, that the two scripts don´t work together... or there might be a command to let them refere to each other...

 

D´OH!

 

there´s gotta be a way to do that....

Sorry for being misleading. I was well overdue for sleep when I wrote that. You'll have to reference the object/quest that the script is attached to for getting the variable. (As in masterobject.variable instead of masterscript.variable.)

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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