Moding qwestion warehouse features / <interrupts> / hot keys

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Post by j.harshaw » Tue, 6. Mar 18, 23:12

Ah, now i remember! A list of blocking actions, and (very important!) the order in which those blocking actions are written in each script is kept and, if the order has changed or a new blocking action is inserted, it throws that compatibility error.

Just to be clear: blocking actions are those actions that block the script from continuing past that point for a certain amount of time because the action itself needs some time before it can finish. These are actions such as move_to, wait, jump, etc. The order is important because, when you save a game, the index of the blocking action is saved. So, for example, you have a script with

<wait exact="1ms"/>
<move_to object="this.ship" destination="this.ship.position"/>
<wait exact="1ms"/>

and save the game while the entity is doing the move_to, the game remembers that it was doing that script, is in the second blocking action, and that that action is a move_to. If, upon loading a game, the second blocking action is no longer a move_to, the game plays it safe and throws the entity back to the calling script and lets you know that there was an error.

To maintain compatibility, you could increment the version of the script and add a sinceversion property to the inserted action. So, say for example, we wanted to insert a jump action between the wait and the move_to, the order would now be:

<wait exact="1ms"/>
<jump sinceversion="1"/>
<move_to object="this.ship" destination="this.ship.position"/>
<wait exact="1ms"/>

Upon loading the game would see that the second action changed but that this is a new version of the file so it would assume that you've handled the change.

Anyhow, yes, restarting the calling script should restart the whole thing.
Andy_MB wrote:I understood a lot. But not all )
Sorry if anything is unclear. Please don't hesitate to ask. i sometimes trip over myself when i get excited.

And i apologize if you already know this stuff. i don't know what you know, and i think it's best to be thorough if unsure.

@Uni, where have you gone? You and i both know you know this stuff better than i do.

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Wed, 7. Mar 18, 00:02

Thank you! Now I understand much more! )
I'll go and try ...

ps:
And, @Uni just knows too much! )
2 years ago he said that he can catch pressing specific buttons bypassing gameoptions.lua In that time i tried to add a button to the gameoptions.ua , but nothing happened.
gameoptions.lua forbidden to change.

I wanted to catch the push of "Shift + J" for an emergency jump in my MOD.
_____________

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Wed, 7. Mar 18, 18:47

sorry, i was a bit tired after work the last few days, and i didnt bother to read up because i already saw a reply from j.harshaw ^^

regarding hotkeys: yep, experimented a lot with that, but sadly no satisfactory results... somehow something always bugged out or didnt work.. the only Keys i could semi-sucessfuly hijack in the end were the ones which are already handled via MD (Maps and a few other Menus)
gameoptions.lua (as any other lua file) can be freely changed, but you must put them into a subst_01.cat/dat in your Mod for a full file replacement, loose files or ext_01.cat/dat dont work for that.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Wed, 7. Mar 18, 22:58

Thanks, @Uni!
I'll try this!

2 years ago i tryed to do this:

1. put subst_01.cat/dat into the root (nothing happens)
2. fully repack 09.cat/dat w/ changed gameoptions.lua. (game loaded, but gameoptions menu is not appears)

Maybe I made a mistake in the file itself.
I must resume my efforts! )
_____________

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Wed, 7. Mar 18, 23:57

ah, you are trying it? then another hint: also include a copy of the lua file renamed to .xpl - no need to make a binary file from it, just a plain text version is enough.. Also its very easy to mess something up with the lua stiuff, and locating errors using the log output is nearly impossible because the log often points you not to the original mistake, but somewhere completely diffrent.... so best make small, incremental changes and then test... the "reloadui" command for the debug command line might be helpful for that - either for recovering from an crashed UI or for loading ui changes into an already running game..

PS disclaimer: its been a long time since i experimented with this stuff. i think i was successful with minor changes (like adding lines/buttons), but couldnt get the functionality i wanted to work in the end.. (hope i dont need to mentoin i prefer ai/md scrits over lua by far) but its too long ago for me to say for certain...
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Thu, 8. Mar 18, 08:32

I tried to start with this.
But I do not understand how to do it.
I think it is necessary to insert here:

Code: Select all

	menu.controls["functions"] = { 
		[1] = { 
			["name"] = ReadText(1005, 16),	-- "Menu back"
			--["name"] = ReadText(1001, 2669),	-- "Back"
			["definingcontrol"] = {"actions", 16}, 
			["actions"] = { 2, 14, 15, 16, 103, 134, 135, 138 }, 
			["states"] = {}, 
			["ranges"] = {},
			["contexts"]= { 1, 2, 3, 4, 5 }
		},  
...
--AMB change
		[14] = {
			["name"] = ReadText(1005, 226), 
			["definingcontrol"] = {"actions", 226},
			["actions"] = { 226 },
			["states"] = {},
			["ranges"] = {}
		}
-- end of changes
	}

and
...
if (context == "keyboard_space") or (context == "vrtouch_space") or (context == "vrvive_space") then
		menu.controlsorder = { 
			[1] = {
				["title"] = ReadText(1001, 4865),	-- "Steering: Analog"
...
},
			[8] = { 
				["title"] = ReadText(1001, 2664),	--"Misc"
				["mapable"] = true,
				{ "functions", 10 },
				{ "actions", 167 },
				{ "actions", 168, nil, ReadText(1026, 2604) },	-- "Target Object" (near crosshair)
				{ "actions", 169 },
				{ "actions", 170 },
				{ "actions", 213 },
				{ "actions", 214 },
				{ "actions", 275 },
				{ "actions", 177, nil, ReadText(1026, 2608) },
				{ "actions", 178, nil, ReadText(1026, 2609) },
				{ "functions", 9 },
				{ "actions", 225, nil, ReadText(1026, 2610) },
				{ "actions", 223, nil, ReadText(1026, 2611) },
				{ "actions", 117 },
				{ "actions", 120 },
				{ "actions", 219 },
				{ "states", 80, nil, ReadText(1026, 2612) },
--AMB change
				{ "functions", 14 }
--end of changes

I try to do this:

Code: Select all

-- Addon for Ingame Options Main Menu 2017.10.23 (v. 4.30)

local menuAddon = {
	entry = {
				["name"] = ReadText(1005, 226), 
				["definingcontrol"] = {"actions", 226}, 
				["actions"] = { 226},
				["states"] = {},
				["ranges"] = {}
			}
    
}
local menuAddon2 = {
	entry = { "functions", 14 	}
}


local function createSetupAddButton(menu)
    for _, subMenu in ipairs(menu.controls["functions"]) do
        
			table.insert(subMenu.list, menuAddon.entry)
        
    end
	for _, subMenu in ipairs(menu.controlsorder) do
--        if subMenu.title == ReadText(1001, 2664) then	--"Misc"
			table.insert(subMenu[8], menuAddon2.entry)
--        end
    end

end

local function createSetupWrapper()
    menuAddon.origCreateSetup()
	createSetupAddButton(menuAddon.menu)
end

local function init()
	if Menus then
		for _, menu in ipairs(Menus) do
            if menu.name == "OptionsMenu" then
                menuAddon.menu = menu
                menuAddon.origCreateSetup = menu.createSetup
                menu.createSetup = createSetupWrapper
                break
            end
		end
	end
end
More text is needed:

Code: Select all

<language id="44">

<page id="1005" title="Input Action Texts" descr="0" voice="no">
  <t id="226">Emergency Jump</t>
</page>
Still need to describe the action (226), but I do not understand where and how !?
inputmap.xml ?

Code: Select all

  <action id=226 source="INPUT_SOURCE_KEYBOARD" code="INPUT_KEYCODE_J_SHIFT"/>
What do You think about this?
_____________

Andy_MB
Posts: 72
Joined: Fri, 24. Jul 15, 17:47
x4

Post by Andy_MB » Fri, 9. Mar 18, 15:41

Wishes for programmers!!!

Please make the event generation by pressing / releasing one key. Or in combination with alt / shift / ktl.
In xml it would be possible to track by:
<event_key_pressed> w/
<param = "INPUT_SOURCE_KEYBOARD">
<param2 = "INPUT_KEYCODE_J_SHIFT" comment = "Same Action Code from inputmap">
<param3 = "pressed / released">

I have no idea - how track key press. (

ps: maybe in X4 Foundation, in a future...

Thank You!
_____________

Post Reply

Return to “X Rebirth - Scripts and Modding”