Goto https://www.stucuk.netGoto https://www.atlanticaonlinewiki.comGoto https://www.game-requirements.comGoto https://www.owsupport.com
It is currently Thu Sep 28, 2023 7:33 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: make hud elements toggle
PostPosted: Mon May 29, 2017 2:15 pm 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
Is it possible to make HUD elements toggle with a certain keyboard input?

Example:

addControl("paGame->MissionList","TMissionList",{
visible=1, enabled=0, ticked=1,

I know I have to make visible=0 and enabled=1 (I have no idea what "ticked" stands for), but how do I include the keyboard shortcut to toggle this list?
Hotkey="M" doesn't work...


Top
 Profile  
 
PostPosted: Wed May 31, 2017 4:45 am 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5019
Location: UK, Scotland
Basically its creating a TMissionList inside the games exe. TMissionList is a class in the game side. I am not sure exactly what ticked is in this instance, but it basically means that each frame the object will be given the time since the last "tick"(or frame) and it can then do something.

I havn't tried it, but i think you need to add a THotKey.

interface\hotkeys\HotKeys.lua:
Code:
addControl("HotKeyPanel->hkF12(THotKey)" ,{
 hotkey="F12",
 onKeyDown="iDebug.Toggle()",
})


so something like:

Code:
MLTV = true;

function missionlisttoggle();
 if (MLTV) then
  set("paGame->MissionList::visible",0);
 else
  set("paGame->MissionList::visible",1);
 end;
 MLTV = not MLTV;
end;

addControl("HotKeyPanel->MLT(THotKey)" ,{
 hotkey="M",
 onKeyDown="missionlisttoggle()",
})


Note: There is a "get_visible" but its not used anywhere and looks like if it does work it only works on TMegaButton's.

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
PostPosted: Wed May 31, 2017 4:48 pm 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
So this is now my Hotkeys.lua...




addControl( "HotKeyPanel->hkGameMenu(THotKey)" ,{
hotkey="ESC",
onKeyDown="iActions.GameMenu()",
})

MLTV = true;

function missionlisttoggle();
if (MLTV) then
set("paGame->MissionList::visible",0);
else
set("paGame->MissionList::visible",1);
end;
MLTV = not MLTV;
end;

addControl("HotKeyPanel->MLT(THotKey)" ,{
hotkey="M",
onKeyDown="missionlisttoggle()",
})




...but the mission list doesn't toggle.
Moreover, the ESC hotkey doesn't work anymore...

Any ideas what could be wrong here?


Top
 Profile  
 
PostPosted: Wed May 31, 2017 9:44 pm 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5019
Location: UK, Scotland
you want to use the -devmode parameter when making mods. It will force the game into a 1024x768 window but will also display a debug window to the right (Which you can enter lua code into to test stuff. Given the way lua works you can literally overwrite stuff including functions). Lua errors are also shown. Its most likely something is wrong in the code i posted.

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 3:04 pm 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
In dev mode when inserting your code the whole game freezes...


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 6:11 pm 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5019
Location: UK, Scotland
moddernoob Wrote:
In dev mode when inserting your code the whole game freezes...


Adding it at the main menu it didn't freeze for me. The problem is the ; after function missionlisttoggle(), it shouldn't be there. It also seems like you only use the elements name when using set.

Code:
MLTV = true;

function missionlisttoggle()
if (MLTV) then
set("MissionList::visible",0);
else
set("MissionList::visible",1);
end;
MLTV = not MLTV;
end;

addControl("HotKeyPanel->MLT(THotKey)" ,{
hotkey="M",
onKeyDown="missionlisttoggle()",
})

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 9:54 pm 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
I inserted the code in-game. Maybe that makes a difference too. I can't check right now, but I'll try your new code when I get home and I'll get back to you.
Thank you for going through the trouble of testing!


Top
 Profile  
 
PostPosted: Sat Jun 03, 2017 2:44 am 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5019
Location: UK, Scotland
moddernoob Wrote:
I inserted the code in-game. Maybe that makes a difference too

I just used the debug window. But adding it to the actual file shouldn't make a difference. The issue is that if the LUA doesn't compile that file, the whole contents of the file is ignored(Which could then cause the game to crash as elements don't exist which it expects).

Its safer to test new lua code using the debug window first and then add it to actual lua files (If there is no compile errors it will just say it added it, otherwise you get an error message which may include the code you just sent. Meaning you may need to scroll up to see the error).

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
PostPosted: Sat Jun 03, 2017 8:22 am 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
I meant to say that I inserted the code via the dev window, not at the main menu like you did, but when I was already in the game.
The dev mode is really handy, by the way!

Your code works. Only thing is, that the mission list will pop up by itself when a new objective is added. I tried to locate the lua where this was specified, but was unable to do so. Would you happen to know where I should look for the code of this behaviour?


Last edited by moddernoob on Sat Jun 03, 2017 10:19 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Jun 03, 2017 9:22 am 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5019
Location: UK, Scotland
functions.lua holds stuff which sets the missionlist. Its likely that when something is added that it forces it to be visible in the games side. So you may need to find all instances of set("MissionList:: and after them add code to hide the mission list if it should be hidden

I.E
Code:
function AddObjectiveReal(id,text)
  -- id - ñòðîêîâûé èäåíòèôèêàòîð
  -- text - òåêñò çàäàíèÿ
  set("MissionList::MissionText",text);
--  set("itNewMissionText::Text",text);  -- ïî íàñòîÿíèþ Fademan
  set("MissionList::Add",id);

  if (not MLTV) then
   set("MissionList::visible",0);
  end;
end;

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
PostPosted: Sat Jun 03, 2017 10:23 am 
Offline
Soldier level 0
Soldier level 0

Joined: Fri May 26, 2017 7:26 pm
Posts: 10
Right... and I was searching for "MissionList::visible" thinking that that was the (only) way for the game to have the mission list pop up ;)
Thanks, Stu!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group