Goat Simulator

Goat Simulator

Create, share and find content by the Community.
Do you want a flying goat? Do you want a completely new map? The Steam Workshop gives you the ability to create anything you want using the same tools the developers used!
Geneosis 75 16 Nov, 2015 @ 12:52pm
[SOLVED] Need help about Action Script
Hi there, this thread is for either the game devs or advanced Unreal Script devs ^^

Here is the situation: I'm trying to give an independent inventory to a vehicle, for that I'm highjacking the existing inventory code and want to use the existing HUD to display it.

So basically I created a custom class child of GGInventory and changed the functions I wanted to work with a GGSVehicle owner (not only a GGGoat owner). Then I added to my vehicle class a variable of this type and I'm now redefining some functions of GGHUDGfxInGame to make them display the content of my vehicle's inventory.

So far almost everything works fine, I can open and close the inventory and when it's open I see the usual HUD window.

The problem is: The inventory list is always empty.

I tracked the problem down to the following function that I redefined:
function PopulateInventory() { local int i; local GFxObject tempObject, dataProviderArray, dataProviderObject; local array<ASValue> args; dataProviderArray = mHUD.CreateArray(); for( i = 0; i < mHold.mInventorySlots.Length; ++i ) { WorldInfo.Game.Broadcast(self, "inventoryItem=" $ mHold.mInventorySlots[ i ].mName); tempObject = mHUD.CreateObject( "Object" ); tempObject.SetString( "label", mHold.mInventorySlots[ i ].mName ); dataProviderArray.SetElementObject( i, tempObject ); } dataProviderObject = mHUD.mRootMC.CreateDataProviderFromArray( dataProviderArray ); mHUD.mInventory.SetObject( "dataProvider", dataProviderObject ); args.Length = 0; mHUD.mInventory.Invoke( "validateNow", args ); mHUD.mInventory.Invoke( "invalidateData", args ); }
This function was originally defined in GGHUDGfxInGame and works perfectly well in that class, the problem is that since I moved it to my custom vehicle class it have no effect at all on the HUD...

For info, mHold is an object of my child of GGInventory, and mHUD a reference to the GGHUDGfxInGame of the vehicle driver.

As you can see in the code up there I added a log to make sure that the GGInventory contains the right items, and that works fine, the items are there, it's just that they are never diplayed by this code, and I have no idea how to debug this function as it contains mainly Action Script calls...
Last edited by Geneosis; 18 Nov, 2015 @ 5:29am
< >
Showing 1-6 of 6 comments
botman 16 Nov, 2015 @ 5:32pm 
Are you calling...
mHUD.mInventory.Setup();
before you call your PopulateInventory()?

(see PostWidgetInit() in the GGHUDGfxInGame.uc class).
Last edited by botman; 16 Nov, 2015 @ 5:33pm
Geneosis 75 17 Nov, 2015 @ 2:09am 
yep, I have that when a driver enter my vehicle:
if(mHUD.mInventory == none) { mHUD.AddInventory(); mHUD.mInventory.Setup(); mHUD.ShowInventory( false ); mHUD.mInventoryDescription.Setup(); mHUD.SetInventoryDescription(); }
Last edited by Geneosis; 17 Nov, 2015 @ 2:10am
[!CSS] Stefan 1 17 Nov, 2015 @ 10:18pm 
Hi Geneosis! Maybe I can be of assistance =)

Can you try and separate the init phase and the population of data? That's why I'm using PostWidgetInit(), to give it an extra frame so that the flash assets can be properly initialized before used.

My suggestion is to have AddInventory() when the HUD movie is created and then call Setup() in PostWidgetInit(). This way you only have to unhide the inventory hud and populate the data when you enter the vehicle.

If this fixes your issue I can explain why you need to do it this way =)
Geneosis 75 18 Nov, 2015 @ 5:29am 
Thanks a lot Stefan :)

I can't do what you propose because I do not own the HUD movie, I use the default one, so I can't change the content of its PostWidgetInit() function ;)

Anyway I tried to move the Setup() function to another place, this didn't help, but when testing it I accidentally found that the HUD was correctly updated when objects were added when the inventory was open ^^ This allowed me to understand an important thing: if you call PopulateInventory() when the inventory is not yet visible on the screen it have no effect XD

So the real problem was that I was calling PopulateInventory() too soon (on the keypress that open the inventory) and at that time the inventory was in fact not yet on the screen :) After moving the PopulateInventory() function to the next tick, everything started to work like a charm :p
[!CSS] Stefan 1 19 Nov, 2015 @ 5:17am 
Yeah you hit it with the needing of an extra frame. Though I don't think that the actual visibility is an issue. It's more about the initialization of the flash object.

There are a few issues that I've come across after working with Scaleform on Sanctum and Goat Simulator. And what bothers me the most is that things aren't fully initialized and ready for use even if they are by the game marked as so. For instance; the event WidgetInitialized() is the place where you should do init things on widgets. However lists and their listitemrenderers require an extra frame before they can be used by some mysterious reason.

Anyways, great to see that you got it working ;)
Ultimate Doge 8 Dec, 2015 @ 3:58pm 
:fireball:
Last edited by Ultimate Doge; 8 Dec, 2015 @ 3:58pm
< >
Showing 1-6 of 6 comments
Per page: 1530 50