Code: Select all
GameInfo {
AddEventHandlers = "KeyTest"
}
Code: Select all
CLASS KeyTest : ACTOR {
}
Then I did this:
Code: Select all
CLASS KeyTest : StaticEventHandler {
}
How do I get started with this?
Moderator: GZDoom Developers
Code: Select all
GameInfo {
AddEventHandlers = "KeyTest"
}
Code: Select all
CLASS KeyTest : ACTOR {
}
Code: Select all
CLASS KeyTest : StaticEventHandler {
}
Code: Select all
version "4.5"
#include "some/other/file.zsc"
class MyClass { }
//etc
Code: Select all
Map MAP01 "Crock Town and Terminal Field" {
Cluster = 1
LevelNum = 1
UsePlayerStartZ
Music = "M_MAP01"
EventHandlers = "KeyTest"
}
Code: Select all
CLASS KeyTest : EventHandler {
override bool InputProcess(InputEvent e){
Return True;
}
}
Well, it depends on what you intend to achieve with that code.SPZ1 wrote:I got this far but I don't know what to do now
Code: Select all
version "4.5.0"
class TestHandler : EventHandler
{
override bool InputProcess(InputEvent e)
{
// For special keys (e.g. arrows, F1-F12, mouse buttons etc.) use e.KeyScan
// (see EDoomInputKeys in gzdoom.pk3/zscript/events.zs)
// For normal keys, use KeyChar or KeyString
if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_RightArrow)
{
// TODO: Handle input here
//...
// Remove the next line if you want the game to process input for this key normally
return true;
}
return false;
}
}
Code: Select all
class TestHandler : EventHandler
{
override void NetworkProcess(ConsoleEvent e)
{
if (e.Name ~== "testevent")
{
// TODO: Process the event here
// e.Player is the number of the player who triggered this event
// Access their PlayerInfo via players[e.Player] or PlayerPawn via players[e.Player].mo
// Note that in network games the event can be received after the player has left the game!
// (verify that playeringame[e.Player] is true before accessing players[e.Player].mo)
}
}
}
Code: Select all
addkeysection "My Mod Special Commands" MyModSpecialCommandsKeysection
addmenukey "Test Event" "netevent testevent"
Code: Select all
CLASS BankKeyRepeater : EventHandler {
override bool InputProcess(InputEvent e){
if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_UpArrow){
//ACS_NamedExecute("Turn_Bank_Menu_Up___Handler", 0, 0, 0, 0);
ACS_Execute(5, 0, 0, 0, 0);
} else if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_DownArrow){
//ACS_NamedExecute("Turn_Bank_Menu_Down___Handler", 0, 0, 0, 0);
ACS_Execute(6, 0, 0, 0, 0);
} else if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_Enter){
ACS_Execute(7, 0, 0, 0, 0);
}
if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_UpArrow){
// Need to restart here!!
} else if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_DownArrow){
// Need to restart here!!
}
Return False;
}
}
Code: Select all
// TODO: Replace MyScriptName with the name of your script
ACS_Execute(-int('MyScriptName'), 0, 0, 0, 0)
Sorry, but I have no idea what you mean by that. I may be able to provide more help if you could describe in as much detail as possible how you want your code to work.SPZ1 wrote:I still am where I was before where I needed a way to make the code repeat itself.
Code: Select all
world int 1:TotalRupeesInPocket;
world int 2:TotalRupeesInBank;
function void Pause__Movement(bool is__){
SetActorProperty(42, APROP_Invulnerable, is__);
SetActorProperty(42, APROP_NoTarget, is__);
SetHudSize(1024, 768, FALSE);
SetFont("HowlingNightmare");
if (is__){
HUDMessageBold(s:"\c[White]Lock-Out:\c[Red] Activated"; HUDMSG_PLAIN, 123654, CR_WHITE, 1024.2, 768.2, 6.0);
SetActorProperty(42, APROP_Speed, 0.0);
}else{
HUDMessageBold(s:"\c[White]Lock-Out:\c[Green] DeActivated"; HUDMSG_PLAIN, 123654, CR_WHITE, 1024.2, 768.2, 6.0);
SetActorProperty(42, APROP_Speed, 1.0);
}
}
// Add rupees, also makes the indicator appear with 0 to add
script 255 (int amount){
TotalRupeesInPocket += amount;
if (TotalRupeesInPocket > 500){
TotalRupeesInPocket = 500;
}
SetFont("Rupee_Numbers");
HUDMessageBold(i:TotalRupeesInPocket,s:" :$"; 0, 9000, CR_GREEN, 1.0, 0.85, 0);
}
Code: Select all
script 04 (void){
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
}
int whichItemSelected = 0;
int tempMoney = 0;
bool menuDepth = FALSE;
bool isInBank = FALSE;
script "Turn_Bank_Menu_On" (void) {
Pause__Movement(TRUE);
isInBank = TRUE;
SetHudSize(1024, 768, FALSE);
SetFont("HowlingNightmare");
if (!menuDepth){
HUDMessageBold(s:"\c[Blue]Welcome to the Crock Town Bank\n\c[White]Your Money: \c[Green]",i:TotalRupeesInBank; HUDMSG_PLAIN, 695, CR_WHITE, 128.1, 64.1, 0);
if (whichItemSelected == 0){
HUDMessageBold(s:"\c[Green]Deposit Money\c[White]\nWithdraw Money\nExit"; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0);
} else if (whichItemSelected == 1) {
HUDMessageBold(s:"\c[White]Deposit Money\n\c[Green]Withdraw Money\c[White]\nExit"; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0);
} else if (whichItemSelected == 2) {
HUDMessageBold(s:"\c[White]Deposit Money\nWithdraw Money\n\c[Green]Exit"; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0);
}
} else {
HUDMessageBold(s:"..."; HUDMSG_PLAIN, 695, CR_WHITE, 128.1, 256.1, 0.01);
if (whichItemSelected == 0) {
HUDMessageBold(s:"Deposit Money: ",d:tempMoney; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0);
} else if (whichItemSelected == 1){
HUDMessageBold(s:"Withdraw Money: ",d:tempMoney; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0);
}
}
}
script 05 (void){
if (isInBank){
ACS_NamedExecute("Turn_Bank_Menu_Up", 0, 0, 0, 0);
}
}
script "Turn_Bank_Menu_Up" (void){
if (menuDepth){
if (tempMoney+1 < TotalRupeesInPocket)
tempMoney++;
} else {
whichItemSelected--;
if (whichItemSelected == -1){
whichItemSelected = 2;
}
}
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
}
script 06 (void){
if (isInBank){
ACS_NamedExecute("Turn_Bank_Menu_Down", 0, 0, 0, 0);
}
}
script "Turn_Bank_Menu_Down" (void){
if (menuDepth){
tempMoney--;
if (tempMoney < 0)
tempMoney = 0;
} else {
whichItemSelected++;
if (whichItemSelected == 3){
whichItemSelected = 0;
}
}
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
}
//script "Enter_Bank_Menu" (void){
script 07 (void){
if (!isInBank){
Terminate;
}
SetHudSize(1024, 768, FALSE);
SetFont("HowlingNightmare");
// Exit the menu
if (whichItemSelected == 2 && !menuDepth){
HUDMessageBold(s:"..."; HUDMSG_PLAIN, 695, CR_WHITE, 128.1, 256.1, 0.01);
HUDMessageBold(s:"..."; HUDMSG_PLAIN, 694, CR_WHITE, 128.1, 384.1, 0.01);
Pause__Movement(FALSE);
isInBank = FALSE;
whichItemSelected = 0;
Terminate;
}
if ((whichItemSelected == 0 || whichItemSelected == 1) && !menuDepth){
menuDepth = TRUE;
} else if (whichItemSelected == 0 && menuDepth){
if (tempMoney > TotalRupeesInPocket){
HUDMessageBold(s:"\c[Red]You do not have this much money in your wallet!!"; HUDMSG_PLAIN, 699, CR_WHITE, 128.1, 128.1, 4.0);
Delay(35 * 4);
} else {
TotalRupeesInBank += tempMoney;
TotalRupeesInPocket -= tempMoney;
tempMoney = 0;
}
menuDepth = FALSE;
} else if (whichItemSelected == 1 && menuDepth){
if (tempMoney > TotalRupeesInBank){
HUDMessageBold(s:"\c[Red]You do not have this much money in the bank!!"; HUDMSG_PLAIN, 696, CR_WHITE, 128.1, 128.1, 4.0);
Delay(35 * 4);
} else {
TotalRupeesInBank -= tempMoney;
TotalRupeesInPocket += tempMoney;
tempMoney = 0;
}
menuDepth = FALSE;
}
Delay(45);
ACS_Execute(255, 0, 0, 0, 0);
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
}
Code: Select all
// Turn Menu Up
script 05 (void){
if (isInBank){
if (menuDepth){
if (tempMoney+1 < TotalRupeesInPocket){
tempMoney++;
}
} else {
whichItemSelected--;
if (whichItemSelected == -1){
whichItemSelected = 2;
}
}
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
Delay(3);
Restart;
}
}
// Turn Menu Down
script 06 (void){
if (isInBank){
if (menuDepth){
tempMoney--;
if (tempMoney < 0){
tempMoney = 0;
}
} else {
whichItemSelected++;
if (whichItemSelected == 3){
whichItemSelected = 0;
}
}
ACS_NamedExecute("Turn_Bank_Menu_On", 0, 0, 0, 0);
Delay(3);
Restart;
}
}
Code: Select all
CLASS BankKeyRepeater : EventHandler {
override bool InputProcess(InputEvent e){
if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_UpArrow){
ACS_Execute(5, 0, 0, 0, 0);
} else if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_DownArrow){
ACS_Execute(6, 0, 0, 0, 0);
} else if (e.Type == InputEvent.Type_KeyDown && e.KeyScan == InputEvent.Key_Enter){
ACS_Execute(7, 0, 0, 0, 0);
}
if (e.Type == InputEvent.Type_KeyUp){
ACS_Terminate(5, 0);
ACS_Terminate(6, 0);
}
Return False;
}
}