changing how loadout is used
by Jonas · in Torque 3D Professional · 03/30/2011 (11:29 pm) · 4 replies
Hi!
What im trying to do is move my loadout to each specific game type
so that it can be specific to each game type(this was very easy and is already done).
the second stage is to make loadout dependant on a .gui file/ a acompanied .cs file
with the functions to decide what the player will spawn with. I got the order down
on how i need to move around spawn/oncliententer/and cmd to server.
What i need help with is a function (using two drop down menues) decide upon two different
weapon types (main/secondary weapon) that it then can pass on to a cmd to server function
that later on changes the loadout.
I have tried to check in the files/forums as much as possible but cant really find any
info on drop down menues and how to setup a function for them. If im looking right at it
please point me in the general direction.
I was thinking of using a sort of IF/else system for the loadout but im not 100% sure
if thats the best way to do it.
Best regards
Jonas
What im trying to do is move my loadout to each specific game type
so that it can be specific to each game type(this was very easy and is already done).
the second stage is to make loadout dependant on a .gui file/ a acompanied .cs file
with the functions to decide what the player will spawn with. I got the order down
on how i need to move around spawn/oncliententer/and cmd to server.
What i need help with is a function (using two drop down menues) decide upon two different
weapon types (main/secondary weapon) that it then can pass on to a cmd to server function
that later on changes the loadout.
I have tried to check in the files/forums as much as possible but cant really find any
info on drop down menues and how to setup a function for them. If im looking right at it
please point me in the general direction.
I was thinking of using a sort of IF/else system for the loadout but im not 100% sure
if thats the best way to do it.
Best regards
Jonas
About the author
Freelance 3D artist at day scripter/coder on Enduring Life at night. Lover of all things TorqueScript.
#2
This will call if you select the second option:
thefcnyouwanttocallonselect("the value 2");
Do a GuiPopUpMenuCtrl.dump() in the console if you need more info... you can color code the popup list for example using a third parameter.
03/31/2011 (12:43 pm)
Build by hand or use the gui editor to make a guipopupmenuctrl:MyPopup = new GuiPopUpMenuCtrl() {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
isContainer = "0";
profile = "GuiPopUpMenuProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "206 20";
canSave = "1";
visible = "1";
tooltipprofile = "GuiToolTipProfile";
canSaveDynamicFields = "0";
};
MyPopup.command = "thefcnyouwanttocallonselect(MyPopup.getValue());";
MyPopup.add("The Displayed Option 1", "the value 1");
MyPopup.add("The Displayed Option 2", "the value 2");
MyPopup.add("The Displayed Option 3", "the value 3");This will call if you select the second option:
thefcnyouwanttocallonselect("the value 2");
Do a GuiPopUpMenuCtrl.dump() in the console if you need more info... you can color code the popup list for example using a third parameter.
#3
Bennett i tested your example form but it contain a error or two i need to ask about.
the first row "MyPopup = new GuiPopUpMenuCtrl() {"
the "MyPopup =" is a syntax error i think you just put it there to show "this is the gui function" but what i cant figure out is where to make the connection between the myPopup.command/MyPopup.add and the guipopipMenuCtrl lines.
Using MyPopup as name does not give me any result and the line 25 in your example gives me a error for it instead i guess because it cant find the guipopupmenuctrl called "MyPopup".
This is what i got so far:
new GuiPopUpMenuCtrl(MyPopup) {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "24 115";
extent = "259 19";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiPopUpMenuProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
MyPopup.command = Loadout_configstg1(MyPopup.getValue());
MyPopup.add("Weapon 01", %Loadout_MweaponValue = 1);
MyPopup.add("Weapon 02", %Loadout_MweaponValue = 2);
MyPopup.add("Weapon 03", %Loadout_MweaponValue = 3);
Is there something i have miss understood
Best regards
Jonas
04/01/2011 (3:44 am)
Hi again, thanks for the replys.Bennett i tested your example form but it contain a error or two i need to ask about.
the first row "MyPopup = new GuiPopUpMenuCtrl() {"
the "MyPopup =" is a syntax error i think you just put it there to show "this is the gui function" but what i cant figure out is where to make the connection between the myPopup.command/MyPopup.add and the guipopipMenuCtrl lines.
Using MyPopup as name does not give me any result and the line 25 in your example gives me a error for it instead i guess because it cant find the guipopupmenuctrl called "MyPopup".
This is what i got so far:
new GuiPopUpMenuCtrl(MyPopup) {
maxPopupHeight = "200";
sbUsesNAColor = "0";
reverseTextList = "0";
bitmapBounds = "16 16";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "24 115";
extent = "259 19";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiPopUpMenuProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
MyPopup.command = Loadout_configstg1(MyPopup.getValue());
MyPopup.add("Weapon 01", %Loadout_MweaponValue = 1);
MyPopup.add("Weapon 02", %Loadout_MweaponValue = 2);
MyPopup.add("Weapon 03", %Loadout_MweaponValue = 3);
Is there something i have miss understood
Best regards
Jonas
#4
Fixed the Gui side of the problem its worknig beautiful now.
I decided to go with a button based gui instead of a menu oriented one and i simply used a set of variables to configure it.
This is how i built it:
Variable decided by button > press !SPAWN! > Sending server command > sending second command to server calling Weapon_Spawn > Weapon_Spawn finds a spawnsphere and spawn a player then calls loadout(error on loadout)
(Weapon_Spawn function is located within the game mode itself)
(Server gets a different variable number based on what weapon you picked)
So the problem at hand is that i have moved Loadout/Spawn/prepareplayer scripts from gamecore to the gamemode and when tested that way it worked fine.
Then i moved loadout to be called via another function (Weapon_spawn) and now it give me:
Scripts/server/****.cs (150): unknown command loadout.
Object LocalClientConnection(10159) LocalClient Connection -> GameConnection -> GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject
This is the main 2 parts of the code:
function ****::Weapon_Spawn(%game, %client)
{
%playerSpawnPoint = pickPlayerSpawnPoint($Game::DefaultPlayerSpawnGroups, %client);
%game.spawnPlayer(%client, %playerSpawnPoint);
%game.loadOut(%client.player);
}
function DeathMatchGame::loadOut(%game, %player)
{
%Weapon_Pick = $Weapon_Selected;
%Weapon_Pick_Second = $Weapon_Selected_Second;
echo("Beginning Loadout");
if(%Weapon_Pick == 1)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1 );
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick == 2)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick == 3)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick_Second == 1)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
}
($Weapon_Selected; $Weapon_Selected_Second; is defined when loadout is first called)
Best regards and thanks in advance!
Jonas
04/14/2011 (6:40 pm)
Back again!Fixed the Gui side of the problem its worknig beautiful now.
I decided to go with a button based gui instead of a menu oriented one and i simply used a set of variables to configure it.
This is how i built it:
Variable decided by button > press !SPAWN! > Sending server command > sending second command to server calling Weapon_Spawn > Weapon_Spawn finds a spawnsphere and spawn a player then calls loadout(error on loadout)
(Weapon_Spawn function is located within the game mode itself)
(Server gets a different variable number based on what weapon you picked)
So the problem at hand is that i have moved Loadout/Spawn/prepareplayer scripts from gamecore to the gamemode and when tested that way it worked fine.
Then i moved loadout to be called via another function (Weapon_spawn) and now it give me:
Scripts/server/****.cs (150): unknown command loadout.
Object LocalClientConnection(10159) LocalClient Connection -> GameConnection -> GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject
This is the main 2 parts of the code:
function ****::Weapon_Spawn(%game, %client)
{
%playerSpawnPoint = pickPlayerSpawnPoint($Game::DefaultPlayerSpawnGroups, %client);
%game.spawnPlayer(%client, %playerSpawnPoint);
%game.loadOut(%client.player);
}
function DeathMatchGame::loadOut(%game, %player)
{
%Weapon_Pick = $Weapon_Selected;
%Weapon_Pick_Second = $Weapon_Selected_Second;
echo("Beginning Loadout");
if(%Weapon_Pick == 1)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1 );
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick == 2)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick == 3)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
if(%Weapon_Pick_Second == 1)
{
echo("Condition met! spawnning with ****");
%player.setInventory(****, 1);
%player.setInventory(****Ammo, %player.maxInventory(****Ammo));
%player.mountImage(****Image, 0);
}
else
{
echo("condition not met! you did not pick ****!");
}
}
($Weapon_Selected; $Weapon_Selected_Second; is defined when loadout is first called)
Best regards and thanks in advance!
Jonas
Associate Steve Acaster
[YorkshireRifles.com]
1. Load mission with custom Gametype
2. Spawn camera but have your "weapon selection gui" display
3. Select weapon, add variable.
4. Press go, pass variable to spawn/equip player functions