Jump to content

script problem


Recommended Posts

Hi everyone. I'm trying to make another crafting mod and i have some problems with that.

I've written script, which add XP when item is crafted, but it not works at all.

I'm trying to add xp through dummy item called "XP".

 

scn XPbonusadd  

 short xpcount  
 short cXP  

 Begin GameMode

If Player.GetItemCount xDN10XP  >=1
 Set xpcount  to Player.GetItemCount xDN10XP  
 set cXP to xpcount*10   
 RewardXP cXP  
 player.RemoveItem xDN10XP xpcount 1
EndIf

End

 

What did i wrong?

Link to comment
Share on other sites

What is the script attached to? It may just be that whatever it's attached to isn't allowed to run script, IE: non-persistent object or one not in the immediate area. Try inserting a message box of two and see if they pop up, IE: One after the if test and if that doesn't show up as it should, then one after the Begin Gamemode to just verify that the script is being run. (Will need to get rid of that one as soon as it does start to show up though)

 

Alternatively, since you're adding an object, why not just script the object such that as soon as it's added to the PC's inventory it adds the xp and removes itself?

scn...

begin onadd player
rewardxp 10
removeme
end

Edited by Skevitj
Link to comment
Share on other sites

What is the script attached to? It may just be that whatever it's attached to isn't allowed to run script, IE: non-persistent object or one not in the immediate area. Try inserting a message box of two and see if they pop up, IE: One after the if test and if that doesn't show up as it should, then one after the Begin Gamemode to just verify that the script is being run. (Will need to get rid of that one as soon as it does start to show up though)

 

The script attached to workbench. But the problem is - when i drop misc item "XP" and then take it, the script's not working too.

Link to comment
Share on other sites

The script attached to workbench. But the problem is - when i drop misc item "XP" and then take it, the script's not working too.

Wait, are you talking about the standard workbench? or one you created? This isn't the sort of thing you want to script onto a static object like the workbench, a better bet would be to add it as a quest script, or possibly add to the PC as an ability/perk.

Link to comment
Share on other sites

Wait, are you talking about the standard workbench? or one you created? This isn't the sort of thing you want to script onto a static object like the workbench, a better bet would be to add it as a quest script, or possibly add to the PC as an ability/perk.

 

Yes, i'm talking about the standart workbench. But what the problem in it? I don't use the workbench directly, i'm just trying to add xp when crafted item adds to the inventory. Also player can see, how much XP he'll earn.

http://i016.radikal.ru/1106/8c/6cd1fcf7f743.jpg

Link to comment
Share on other sites

The point was that the type of object the workbench is isn't right for that sort of script. It's better suited to OnActivate blocks. A script like the one you're using needs to be able to be run every frame which the workbench can't allow it to do, however a quest or perk effect script can. That's why I suggested putting the messages into your script, as they'll show if the script is actually being run or not. I suspect it isn't being run which means you'll need to change what you've attached the script to. Edited by Skevitj
Link to comment
Share on other sites

The point was that the type of object the workbench is isn't right for that sort of script. It's better suited to OnActivate blocks. A script like the one you're using needs to be able to be run every frame which the workbench can't allow it to do, however a quest or perk effect script can.

nah, you can use a quest for that of course, but there's absolutely no need to do so. the vanilla workbenches, campfires etc. don't use quests, but ordinary scripts too, by the way.

basically, there's two ways i know to do it quest-less, haven't quite figured out yet which one's better (if any), they both have their advantages and disadvantages.

 

one way would be the gamemode-version.

the thing is, you don't run the whole script gamemode. you want, say, a box, to open a menu, you give it a int-variable like BoxInput and one like BoxButton.

onActivate, when you want to open the menu, you set BoxInput to 1 and in the next line ShowMessage a message-box-message with your menu in it,

then end the activate-block.

then comes a gamemode-block, which is _completely_ in an "if BoxInput == 1"-loop, so gamemode just keeps watching this _one_ variable and else does _nothing_ unless your menue is open;

and within that "if BoxInput == 1"-loop you say "set BoxButton to GetButtonPressed":

as long as none of the items in the message you popped up in the activate block above is clicked, this will return -1.

if one of the items (0,1,2,3,...) in your message is clicked, it returns the number of the button,

so as long as your BoxInput stays 1, the gamemode-block will continue waiting for an entry to set your BoxButton-variable to with your message box open anyway, so gamemode doesn't matter for now.

and in the if BoxInput == 1 loop, there`s another loop asking for if BoxButton > -1 (meaning a button has been pressed), then you set ButtonInput to 0, so gamemode just processes the rest of your BoxButton-loop once and then goes back to only watching the BoxInput-variable again and nothing else.

and in that if boxButton > 1 loop you just have to insert your if button 0, if button 1 etc stuff and that's it.

 

and the other way would be the MenuMode-version, which goes quite similar, with the main difference being, that it only runs when there's a menu open (MenuMode 1001 would be on message boxes only, so it doesn't run on every menue type, you'd use a BoxInput-like variable too, in the activate-block, you set it to 1, then open the message which starts the menu-mode-script with an if BoxInput == 1 loop. then if BoxButton >-1, you'd set BoxInput back to 0, your menumode-block would be processed to the end (with the button-asking in it as above) and then, whenever a menu (or message-box-type in the 1001-case) is opened, watch if BoxInput == 1 and else do nothing.

 

so with some variables and conditioning, you can do quite a lot of stuff with that without any quests. i just scripted a multi-purpose-chemical-set with the menumode-method, and a complete multi-purpose-pet (with customizable waiting location and all) with the gamemode-version, and even something like a little quest between those two with nothing but the above, message boxes and a few ai-packages for the creature. without any quests. :-)

 

if you like you can look up the scripts in my new mole's well-mod here (just a little advertising :-)), Li'l Mo does it gamemode, the chemset does it menumode. :-)

Link to comment
Share on other sites

the vanilla workbenches, campfires etc. don't use quests, but ordinary scripts too, by the way.

All their stock scripts do is show the crafting menu etc. What they're trying to do is check for the presence of an item in a container and remove it (+ others). The script will work fine if they remain near a modified workbench (IE, in the same cell), but they aren't persistent, hence it wont work if they aren't near one (IE, get Veronica to craft the item and it wont work, use a Dead Money hot plate and it wont work). Hence me suggesting attaching it to something which will allow it to always run, quests being the most straightforward IMO.

 

If you don't want to use a quest, just stick a persistent object somewhere and script that. Doesn't need any complicated stuffs attached.

Edited by Skevitj
Link to comment
Share on other sites

  • Recently Browsing   0 members

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