So in this case I'm trying to access the integer variable "toggle" that is outside the "HPIc_OpenMenu()" function which as stated previously GZDoom returns it back as "unknown identifier". The Item "MT_HPICube_Item" only purpose is to call a ZScript function and do nothing else, seeing as there is no "pukenamed" equivalent for ZScript, as ideally when this function is fully implemented should open up a crafting menu.
- Code: Select all • Expand view
Class HPICube_Func : EventHandler
{
bool picloaded;
TextureID nicepic;
bool showpic;
int toggle;
// PLAY scope : collect data
override void WorldTick() // PLAY scope
{
if (!picloaded)
{
nicepic = TexMan.CheckForTexture ("ENCEA0", TexMan.Type_Any);
picloaded = true;
showpic = false;
}
if (toggle == 1)
{
showpic = true;
}
else
{
showpic = false;
}
}
// UI Scope: you cannot alter data here
override void renderOverlay(RenderEvent e) // UI scope
{
if (picloaded &&showpic)
Screen.DrawTexture(nicepic, false, 0, 0,
DTA_KeepRatio, true, DTA_VirtualWidth, 640, DTA_VirtualHeight, 400);
}
static void HPIc_DisplayCubes(Actor self)
{
int i0, i1;
/*
for (i0 = 0; i0 < 10; i0++)
{
for(i1 = 0; i1 < 10; i1++)
{
self.A_Log("A");
}
}
*/
}
static int HPIc_GetToggle(Actor self)
{
self.A_Log("JUST toggle it.");
return 0;
//return toggle;
}
static void HPIc_OpenMenu(Actor self)
{
int cubei, togglo;
cubei = self.CountInv("MT_HPICube_Item");
if (self.CountInv("MT_HPICube_Item") == 1)
{
//toggle = 0;
self.A_Log("OFF");
self.SetInventory("MT_HPICube_Item", 2);
}
else if (self.CountInv("MT_HPICube_Item") == 2)
{
//toggle = 1;
self.A_Log("ON");
self.SetInventory("MT_HPICube_Item", 1);
HPIc_DisplayCubes(self);
}
togglo = HPIc_GetToggle(self);
//self.A_LogInt(toggle);
}
}
Class MT_HPICube_Item : CustomInventory
{
Default
{
// +INVENTORY.INVBAR
Inventory.Icon "FGRSB0";
Inventory.PickupMessage "Picked up: HPI Cube";
Inventory.Amount 1;
Inventory.MaxAmount 2;
Inventory.InterHubAmount 2;
Tag "HPI Cube";
}
States
{
Use:
TNT1 A 0;
TNT1 A 0;
TNT1 A 0
{
//HPICube_Func.HPIc_OpenMenu(invoker.owner);
CallEm(self);
}
Fail;
}
static void CallEm(Actor self)
{
//self.A_Log("HUUH");
let playa = playerpawn(self);
if (playa == null) return;
HPICube_Func.HPIc_OpenMenu(playa);
}
}