A way to consolidate this script piece?
Posted: Thu Oct 25, 2012 7:45 pm
This piece of script is used to decide what buttons are displayed on the OSD for adding and removing items from buildings on zoric. Because of this, it will be replicated for each item in each building. The main thing I want to know is, in order to cut down on sheer length due to being for each item, can anybody see an easy way to consolidate it a bit since most of it is replicated? Mainly, the parts 'add and remove stocks' and the following part 'if player is owner' since they are completely identical.
Code: Select all
if ("$gBuildingVar128=0")
{
osdaddat(OSDFADEDBUTTON, 200, xx1, 25, 25, " ", "1")
}
if ("$gBuildingVar128<5")
{
osdaddat(OSDFADEDBUTTON, 225, xx1, 25, 25, " ", "5")
}
if ("$gBuildingVar128<2")
{
osdaddat(OSDFADEDBUTTON, 250, xx1, 30, 25, " ", "All")
}
if ("$item1=0")
{
osdaddat(OSDFADEDBUTTON, 300, xx1, 25, 25, " ", "1")
}
if ("$item1<5")
{
osdaddat(OSDFADEDBUTTON, 325, xx1, 25, 25, " ", "5")
}
if ("$item1<2")
{
osdaddat(OSDFADEDBUTTON, 350, xx1, 30, 25, " ", "All")
}
if ($gPlayerVar26=1) \\--------------------------If player is employee
{
if ($gBuildingVar13=1) \\--------------------------add stocks only
{
if ("$item1>0")
{
osdaddat(OSDFADEDBUTTON, 200, xx1, 25, 25, " ", "1")
}
if ("$item1>4")
{
osdaddat(OSDFADEDBUTTON, 225, xx1, 25, 25, " ", "5")
}
if ("$item1>1")
{
osdaddat(OSDFADEDBUTTON, 250, xx1, 30, 25, " ", "All")
}
if ("$item1>0")
{
osdaddat(OSDBUTTON, 300, xx1, 25, 25, "b##v128a1", "1")
}
if ("$item1>4")
{
osdaddat(OSDBUTTON, 325, xx1, 25, 25, "b##v128a5", "5")
}
if ("$item1>1")
{
osdaddat(OSDBUTTON, 350, xx1, 30, 25, "b##v128aa", "All")
}
}
if ($gBuildingVar13=2) \\--------------------------add and remove stocks
{
if ("$gBuildingVar128>0")
{
osdaddat(OSDBUTTON, 200, xx1, 25, 25, "b##v128r1", "1")
}
if ("$gBuildingVar128>4")
{
osdaddat(OSDBUTTON, 225, xx1, 25, 25, "b##v128r5", "5")
}
if ("$gBuildingVar128>1")
{
osdaddat(OSDBUTTON, 250, xx1, 30, 25, "b##v128ra", "All")
}
if ("$item1>0")
{
osdaddat(OSDBUTTON, 300, xx1, 25, 25, "b##v128a1", "1")
}
if ("$item1>4")
{
osdaddat(OSDBUTTON, 325, xx1, 25, 25, "b##v128a5", "5")
}
if ("$item1>1")
{
osdaddat(OSDBUTTON, 350, xx1, 30, 25, "b##v128aa", "All")
}
}
}
if ($gBuildingOwnerID = $gPlayerID) \\--------------------------If player is owner
{
if ("$gBuildingVar128>0")
{
osdaddat(OSDBUTTON, 200, xx1, 25, 25, "b##v128r1", "1")
}
if ("$gBuildingVar128>4")
{
osdaddat(OSDBUTTON, 225, xx1, 25, 25, "b##v128r5", "5")
}
if ("$gBuildingVar128>1")
{
osdaddat(OSDBUTTON, 250, xx1, 30, 25, "b##v128ra", "All")
}
if ("$item1>0")
{
osdaddat(OSDBUTTON, 300, xx1, 25, 25, "b##v128a1", "1")
}
if ("$item1>4")
{
osdaddat(OSDBUTTON, 325, xx1, 25, 25, "b##v128a5", "5")
}
if ("$item1>1")
{
osdaddat(OSDBUTTON, 350, xx1, 30, 25, "b##v128aa", "All")
}
}