Convert script to use ware without plugin manager

Home Board Index » X3AP » Scripts and Modding » Convert script to use ware without plugin manager

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

Hey,

This is aimed mainly at roguey although any one who has an idea dont hesitate!
I am trying to implement a script into the mod. The issue is i would like to be able to use the script (and the ware it is 'linked' to) without having to install the plugin manager.... i have been trying to manipulate the setup script but without success. Bellow you will find the setup script for the script in question:

$page.id = 7540
load text: id=$page.id


* lets use the ware manager to add our wares
$stationType = Equipment Dock
@ if not [THIS] -> call script plugin.waremanager.add : ???=$stationType ???=Boron ???= ???=-1 ???=[TRUE]
* didn't add, ware manager is missing
$text = read text: page=$page.id id=2
send incoming message $text to player: display it=[TRUE]
return null

end


* add the hotkey using the hotkey manager
$key.text = read text: page=$page.id id=1
@ if [THIS] -> call script plugin.hotkeymanager.add : Hotkey Name ID='advthrust' Display Text=$key.text Hotkey Script='plugin.advthrust.hotkey'
* added fine, so lets check if we had an old one, and remove it
$key = get global variable: name='plugin.advthrust.key'
if $key
unregister hotkey $key
set global variable: name='plugin.advthrust.key' value=null
end

* not added, no hotkey manager?
else
$key = get global variable: name='plugin.advthrust.key'
if ! $key
$key = register hotkey $key.text to call script plugin.advthrust.hotkey
set global variable: name='plugin.advthrust.key' value=$key
end
end

return null


First the red highlighted code needs to be removed to prevent a popup coming up when you start a game telling you the script manager is not installed. From then i have no clue what to do. i have tried changing the blue highlighted text to: @ = [This] -> call script lib.cy.addware ect but that hastn worked and also various variations of that code. still nothing.... if any one could explain to me how i can manipulated this so that when the ware thruster control is installed this script recognises that and gives you access to its abilities, that would be really helpful!

btw the ??? in the blue highlighted code are of course replaced with the correct values by the plugin manager once it is installed. to clarify that bit is not an error in the script or anything.

Thanks,

Miles

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

Well the first bit, to add the ware to the wares to boron Equipment Dock could be replaced with something like:

$WareToAdd = (something)

$stations = get station array: of race Boron class/type=Equipment Dock
$stationcount = size of array $stations

while $stationcount
dec $stationcount =
$station = $stations[$stationcount]
$station -> add product to factory or dock: $WareToAdd
end

RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

well that worked in the sense that it successfully added it to what ever dock i told it to... the issue now is that the script still does not recognise that when the ware is installed on the ship, it should initialize the script when the hotkey is pressed.

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

that issue must have something to do with the next script in line, the plugin or initialisation of the hotkey:

$ship = [PLAYERSHIP]
skip if $ship -> get amount of ware in cargo bay
return null



if $ship -> get local variable: name='plugin.advthrust.on'
$ship ->set local variable: name='plugin.advthrust.on' value=null
= speak text: page=13 id=1358 priority=100
= speak text: page=13 id=1352 priority=90
return null
end

= speak text: page=13 id=131 priority=100
$ship ->set local variable: name='plugin.advthrust.on' value=[TRUE]
$rotAlpha = $ship -> get rot alpha
$rotBeta = $ship -> get rot beta
$sector = $ship -> get sector

$newPos = $ship -> get position as array

$curRange = 0
while $ship -> get local variable: name='plugin.advthrust.on'
$curSector = $ship -> get sector
skip if $curSector == $sector
break

$speed = $ship -> get current speed
if $speed call script lib.cycrow.math.forward : Distance=$curRange Rotation Alpha=$rotAlpha Rotation Beta=$rotBeta Position=$newPos
$curRange = 0
end

$x = $newPos[0]
$y = $newPos[1]
$z = $newPos[2]
$curRotA = $ship -> get rot alpha
$curRotB = $ship -> get rot beta
$curRotG = $ship -> get rot gamma
$oldPos = $ship -> get position as array
$ship ->force position: x=$x y=$y z=$z
@ = wait $wait ms
end

$ship ->set local variable: name='plugin.advthrust.on' value=null
= speak text: page=13 id=1358 priority=100
= speak text: page=13 id=1352 priority=90

return null


i believe the section in red has to be changed, would you agree?

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
RobertSchafer

RobertSchafer avatar
Level badge Skillguey (7)
Posted 10 years ago.

i managed to get it to work hahaha did not expect that. i replaced the red section with the following:

$ship = [PLAYERSHIP]
if [PLAYERSHIP] -> get true amount of ware Advanced Thruster Control in cargo bay
end


It works perfectly but could you confirm that that is the correct way to do it?

edit: it works...but now the hotkey always works :p and is no longer linked to whether or not you have the ware advanced thruster control is installed....

edit: it is fun when you figure it out haha. subtituted if [Playership] with do if [Playership]... And now it only works if that ware is installed!! So thats perfect haha

thanks again for the help

---- X3ap Battlestar Galactica mod ----
Latest update: 06/01/2014.
Team recruitment: Texture artist
Mod updater/downloader via our website:
www.x-battlestar.com
Roguey

Roguey avatar
Level badge Trueguey (22)
Posted 10 years ago.

no problem, glad to see you got it working in the end Smile

sorry I havnt been posting as much, but as you know - kind-of busy with things Smile

1


You need to log-in to post here.