Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Scripting help needed - Custom Container


thejadeshadow
 Share

Recommended Posts

Hi all! Or anyone willing or able to help! It would be appreciated.  

 

I have a house mod i'm working on. I've been working with scripts (some custom, some just edited like the claw or mask placing scripts).

 

However, I am stumped. I have this treasure vault i'm working on. In the vault is a container chest. When the player adds say...100 gold, I want some gold coins to enable near the chest. If they player adds 1000 gold, I want even more gold to be enabled near the chest. And when the player adds 10000 gold, I want even more gold enabled (etc etc). Basically, I need a script that will automatically display gold in the vault, based on how much you put into the container. (And vice-versa...if you remove gold from the vault, the script would remove the displayed gold as well)

 

Would I use the OnItemAdded and OnItemRemoved function?  How would I set up those scripts with the container to make this work?

 

 

Link to comment
Share on other sites

A 'general what you might do' list follows:

 

1. Place a bunch of gold piles, each with a reference name, all 'initially disabled'. I would probably number them, like "ModNameGoldPile01REF".

 

2. Attach every gold pile you placed to your script via properties.

 

3. There are lots of ways you 'could' script the events to occur, and the two you have would probably work fine. So you would check how much gold is in the chest in each event (GetItemCount) and enable and disable the gold piles based on math.

 

Depending on how many gold piles you want to create, you could say each gold pile is 100, 500 or 1000 coins and divide your math out accordingly.

 

myGold = GetItemCound(gold)

*This implies you also set a property to 'gold' in your script.

 

if myGold < 100

  ModNameGoldPile01REF.disable

  ModNameGoldPile02REF.disable

  ModNameGoldPile03REF.disable

elseif myGold < 500

  ModNameGoldPile01REF.enable

  ModNameGoldPile02REF.disable

  ModNameGoldPile03REF.disable

elseif myGold < 1000

  ModNameGoldPile01REF.enable

  ModNameGoldPile02REF.enable

  ModNameGoldPile03REF.disable

elseif myGold < 1500

  ModNameGoldPile01REF.enable

  ModNameGoldPile02REF.enable

  ModNameGoldPile03REF.enable

endif

 

*Since I am using 'elseif', only the first TRUE statement will execute, that is why this will work without specifying greater than (>) values as well.

So if there is only 90 gold in the chest, all gold piles will be disabled because only the first check of ( < 100 ) will execute.

Link to comment
Share on other sites

Here is what I have so far: 

 

 

Scriptname EE_VaultChestScript extends ObjectReference  
 
ObjectReference Property EE_GoldPile01REF Auto
ObjectReference Property EE_GoldPile02REF Auto
 
Event OnItemAdded(Form BaseItem, int ItemCount, ObjectReference ItemReference, ObjectReference SourceContainer)
 
myGold = GetItemCount(gold)
 
if myGold< 100
  EE_GoldPile01REF.disable
  EE_GoldPile02REF.disable
elseif myGold < 500
   EE_GoldPile01REF.enable
   EE_GoldPile02REF.disable
elseif myGold < 1000
   EE_GoldPile01REF.enable
   EE_GoldPile02REF.enable
elseif myGold < 1500
   EE_GoldPile01REF.enable
   EE_GoldPile02REF.enable
endif
 
EndEvent
 
 
I know some things are wrong.... such as I don't know how to define myGold as a property. Also, i feel I need an event (which is why i added Even OnItemAdded) but I don't think i'm defining it correctly in the script.
Link to comment
Share on other sites

You add the properties to your script for gold, just like you did for your gold piles. Gold is a MiscItem. You would use it in your script with the below code, and call it 'gold001' when your checking gold in your script.

 

miscobject Property gold001  Auto 

 

myGold = GetItemCount(gold001)

 

I have never used OnItemAdded, but the wiki says you can add a filter so it only runs when the item gold is added or removed from the chest.

Link to comment
Share on other sites

Here is my current script:

 

 

Scriptname EE_VaultChestScript extends ObjectReference  
 
ObjectReference Property EE_GoldPile01REF Auto
ObjectReference Property EE_GoldPile02REF Auto
miscobject Property gold001 Auto 
Actor Property PlayerREF Auto
 
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
 
If akSourceContainer == PlayerREF
if (Game.GetPlayer().GetItemCount(gold001) < 100)
    EE_GoldPile01REF.disable
    EE_GoldPile02REF.disable
elseif (Game.GetPlayer().GetItemCount(gold001) < 1000)
    EE_GoldPile01REF.enable
    EE_GoldPile02REF.disable
elseif (Game.GetPlayer().GetItemCount(gold001) < 10000)
    EE_GoldPile01REF.enable
      EE_GoldPile02REF.enable
endIf
endif
 
EndEvent
 
 
I am getting an error back when I compile:
 
(12,24): disable is not a property on script objectreference or one of its parents
(13,24): disable is not a property on script objectreference or one of its parents
(15,24): enable is not a property on script objectreference or one of its parents
(16,22): disable is not a property on script objectreference or one of its parents
(18,25): enable is not a property on script objectreference or one of its parents
(19,24): enable is not a property on script objectreference or one of its parents

 

 

I have no idea what I am supposed to do now  :S  

Link to comment
Share on other sites

Scriptname EE_VaultChestScript extends ObjectReference
ObjectReference Property EE_GoldPile01 Auto
ObjectReference Property EE_GoldPile02 Auto
miscobject Property gold001 Auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

Int myGold = GetItemCount(gold001)
    If myGold < 100
        EE_GoldPile01.disable();
        EE_GoldPile02.disable();
    ElseIf myGold < 1000
        EE_GoldPile01.enable();
        EE_GoldPile02.disable();
    ElseIf myGold < 10000
        EE_GoldPile01.enable();
        EE_GoldPile02.enable();
    EndIf
EndEvent
 

That is my code. (I do have references filled out by the way). But nothing is happening.  Nothing is enabling or disabling. I've been working on it for hours and hours. 

 

 

EDIT: The gold piles are enabling when I put money into the container. But when I remove the gold from the container, the gold piles don't disable. Any ideas?

Edited by thejadeshadow
Link to comment
Share on other sites

  • 4 weeks later...

ok ill here is wat i have so far i just want to add 100,000 gold to a activator so when u activate the button its gives you that ammount of gold.

Scriptname addgoldx10 extends Actor

int Property TrainerType Auto

;

;This script is added on an activator to fake an object being harvestable

; it mimics the normal harvest behavior

;==============================================================

 

ingredient property IngredientHarvested auto

{ingredient added when harvested}

potion property PotionHarvested auto

{potion added when harvested}

bool property deleteSelfOnHarvest = false auto

{if true, delete this object when harvested}

message property HarvestMessage auto

{Message that appears when you have successfully harvested something}

message property FailureMessage auto

{Message that appears when you fail to harvest something}

 

 

sound property HarvestSound auto

{Sounds played on harvest}

;===================================================================

;;STATE BLOCK

;===================================================================

auto state readyForHarvest

event onActivate(objectReference akActivator)

 

fakeHarvest(akActivator)

if deleteSelfOnHarvest

disable()

delete()

endif

endEvent

endState

 

event onActivate(objectReference akActivator)

FailureMessage.show()

endEvent

 

 

;===================================================================

;;FUNCTION BLOCK

;===================================================================

function fakeHarvest(objectReference akActivator)

if (akActivator as actor)

HarvestMessage.show()

HarvestSound.play(self)

if IngredientHarvested

(akActivator as actor).addItem(IngredientHarvested, 100000, true)

endif

 

if PotionHarvested

(akActivator as actor).addItem(PotionHarvested, 100000, true)

endif

endif

endFunction

 

 

 

MiscObject Property goldadded Auto

 

 

this is the one that i used for my moonshine mod adn it gave you 5 bottles of moonshine each time u clicked on it. now i want to do the same wiht gold :D

Link to comment
Share on other sites

It would be much easier to read your script if you format it as code using the "<>" button on the editor toolbar.

 

What is your activator? You say you want gold after pressing a button. But your script is for an Actor, and a button activator is an ObjectReference. Is your script attached to the button, or is it attached to your character for some reason? If so, why?

 

The script seems extremely complex for a simple job of dispensing gold. Gold is not normally a harvestable ingredient, and a button is not normally a harvestable resource. Why is the script DOING all of these things, like playing harvest sounds? Is that really necessary for what you want to do?

 

A script should never do anything that is not directly related to the goal you have in mind. It should never, ever contain any properties or variables that are not needed to get that job done.

 

I think your first job should be to define a clear set of goals, which will help us decide what you need to accomplish those goals.

 

If all you want is to push a button and get gold, you should not need anything other than a simple ObjectReference script with a property for the gold and a short OnActivate event to add X-amount of gold to your inventory. You do not need all the clutter of ingredients, potions, things that delete themselves, state blocks, function blocks, etc.!

 

Edit: When you post a script that isn't working, it also helps to say whether or not it compiled correctly. If it didn't, also give any compiler error messages you received. Diagnosing run-time errors and diagnosing compiler errors are two different things.

Edited by BrettM
Link to comment
Share on other sites

ok thanks ya it was a template that i found that worked for another mod of mine adn i thought i could just use it as a template lol :) im new to scripting if you havent figured that out yet bahahaha srry for the confusion. that why i asked for help ;). Also i hadent deleted certian parts aka like the sound or all the extra stuff just yet i was just trying to see if it was goin to add what i wanted to it. and if it did delete all the extra crap that wasnt nessary or related to it.

Edited by vinny1919
Link to comment
Share on other sites

Basically you need a simple activator script, like the one for the valve that I showed you in response to a question you asked a couple of weeks ago about filling a barrel. If you can't find that thread, see my tutorial on filling a trough and look at the script for the valve. Your script should look something like this:

Scriptname AddSomeGoldSCRIPT extends ObjectReference  

Actor Property PlayerREF Auto
{Efficient reference to player}

MiscObject Property AddedGold auto
{Reference to gold coin}

; ---------------------------------------------------------------

Event OnActivate(ObjectReference akActionRef)

    If akActionRef == PlayerREF
        PlayerREF.AddItem(AddedGold,100000)
    EndIf

EndEvent
Edited by BrettM
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...