Found within zscript/menu/optionitems.txtEd the Bat wrote:What is the best way to check if a string variable is empty or not? if(variable!=null) throws an error.
Code: Select all
if (text.Length() == 0) text = "Unknown";
Found within zscript/menu/optionitems.txtEd the Bat wrote:What is the best way to check if a string variable is empty or not? if(variable!=null) throws an error.
Code: Select all
if (text.Length() == 0) text = "Unknown";
Code: Select all
override void Tick(void)
{
String s = "test";
screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue,
(screen.GetWidth() - SmallFont.StringWidth (s) * CleanXfac_1) / 2, screen.GetHeight() / 2, s,
DTA_CleanNoMove_1, true);
PlayerThink();
Super.Tick();
}
Okay understood about it currently not being available yet; I will wait for event handlers and menus.ZZYZX wrote:You cannot. And it's a bad idea to do it in Tick() and overall bind any drawing to actors.
Drawing should be performed every frame, at a very specific moment of it.
For that, wait for either event handlers or menus to be pulled/implemented.
Otherwise you can abuse subclassing Powerup class and using DrawPowerup method (see examples in gzdoom.pk3).
I blame Graf for ignoring my technical questions about structs and at the same time refusing to pull it without structs.
Graf, have fun observing people hack menus in order to draw things on player HUD :)
Code: Select all
Actor a = null;
a.health = 1;Code: Select all
//because "extend class Actor" doesn't work
class HDActor:Actor{
void nexttic(){
if(!CheckNoDelay()) return;
if(tics!=-1){
if(tics>0)tics--;
while(!tics){
if(!SetState(CurState.NextState)){
return;
}
}
}
}
}
Actually, ZScript guards every single pointer dereference, but when you call a function things are a bit different: The pointer is never dereferenced unless you call a virtual function - it's just being passed as a hidden function parameter, which prevents checking in the call instruction because it isn't part of that - the exception only gets triggered when the pointer actually gets used inside the called function.Xaser wrote: This type of thing is called a "null pointer dereference," and while some languages explicitly throw an error message when you try and do so, ZScript doesn't because it would've involved adding a null check VM instruction to every single function call (lowering performance and whatnot). C++ also lets you shoot yourself in the foot in the same way, for interest's sake.