EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
Unexpected Issue With Script-Editor
Post new topic Reply to topic
View previous topic :: View next topic
Author Message
N3ophyt3





Joined: 19 May 2011
Posts: 4 on topic

Thank you for registering your game
PostPosted: Mon, 28. May 18, 12:14    Post subject: Unexpected Issue With Script-Editor Reply with quote Print

Hey there,

I am playing Litcube´s Universe at the moment. Many scripts do not work with this mod, so I decided to take my first steps into scripting myself.

So far I already wrote some cool scripts, but I am kind of stuck with the current script.

Any help one of you could provide, will be highly appreciated. Smile


The Script:
Basically the script will get a ware array of a specific factory/ dock etc.
Furthermore it will create a menu where you can select one specific ware out of the pool of availabe wares at the selected factory/ dock.

After this the script opens a new menu where you can change the amount of the stored ware to a percentage of 0, 25, 50, 75 or 100.

So far so good.

The script is working fine and it does what it is supposed to do.

BUT:

The first entry of the first menu (where you can chose a stored ware) is not selectable. Every other entry works fine.
I can not figure out, what went wrong with this script. I tried to get the script (completely) working but can not find the source of the issue.


Here you can see three images; first one shows the code, the second one shows the first menu and the third one shows the sub-menu, which will show up, when you select s.th. in the first menu:

https://imgur.com/gallery/LcOfQRo


Hopefully someone got the special hint to make the first item on the list selectable too.

Best regards





This is the code I am using right now:

<![CDATA[
$input = [THIS] -> get user input: type=Var/Station, title='Select A Station'
$TradeableWares = $input -> get tradeable ware array from station


$IdStation = $input -> get ID code
$NameStation = $input -> get name

$SizeArray1 = size of array $TradeableWares

$A = 'a'
$B = 'b'
$C = 'c'
$D = 'd'
$E = 'e'
$counterarray = 0
$returnvalue = 0
$w = $TradeableWares[$counterarray]
$TextIntro = sprintf: fmt='Tradeabel Wares Of Your %s (%s)', $NameStation, $IdStation, null, null, null

$CustMenu = create custom menu array: heading='Your Selected Ware'
$custmenu2 = create custom menu array
add custom menu item to array $custmenu2: text=' 0 %' returnvalue=$A
add custom menu item to array $custmenu2: text=' 25 %' returnvalue=$B
add custom menu item to array $custmenu2: text=' 50 %' returnvalue=$C
add custom menu item to array $custmenu2: text=' 75 %' returnvalue=$D
add custom menu item to array $custmenu2: text='100 %' returnvalue=$E

while $counterarray < $SizeArray1
$w = $TradeableWares[$counterarray]
$aow1 = $input -> get max. store amount of ware $w
$aow2 = $input -> get amount of ware $w in cargo bay
$aow3 = $input -> get ware storage percentage: ware=$w
$text = sprintf: fmt='%s (%s // %s) (%s %)', $w, $aow2, $aow1, $aow3, null
add custom menu item to array $CustMenu: text=$text returnvalue=$returnvalue
@ $wait = wait 10 ms
inc $counterarray =
inc $returnvalue =
end

Menu1:
$return1 = open custom menu: title='Tradeable Wares' description=$TextIntro option array=$CustMenu

if $return1 == $returnvalue
goto label Menu2
else if $return1 == -1
@ $scriptcall = [THIS] -> call script AA.Menu :
return null
end

Menu2:
$return02 = open custom menu: title='Set Your Stock Level' description='Stock Manipulation' option array=$custmenu2

$getreturnvalue = 0

while $getreturnvalue < $returnvalue
$ware = $TradeableWares[$getreturnvalue]
$maxamount = $input -> get max. store amount of ware $ware
$A1 = $maxamount / 4
$A2 = $maxamount / 4 * 2
$A3 = $maxamount / 4 * 3
$A4 = $maxamount
if $return1 == $getreturnvalue AND $return02 == $A
$a = $input -> add -9999999 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $B
$b = $input -> add -9999999 units of $ware
$c = $input -> add $A1 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $C
$d = $input -> add -9999999 units of $ware
$e = $input -> add $A2 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $D
$f = $input -> add -9999999 units of $ware
$g = $input -> add $A3 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $E
$h = $input -> add -9999999 units of $ware
$i = $input -> add $A4 units of $ware
else if $return1 == $getreturnvalue AND $return02 == -1
goto label Menu1
end
@ $wait = wait 10 ms
inc $getreturnvalue =
end

return null[/list]

Back to top
View user's profile Send private message
Joubarbe





Joined: 31 Oct 2006
Posts: 3426 on topic
Location: France
Thank you for registering your game
PostPosted: Mon, 28. May 18, 12:48    Post subject: Reply with quote Print

The first element in your list has a $returnvalue of 0. $returnvalue can't be 0.


_________________
Mayhem - Satellites Monitoring - ADS (Joubarbian Edition) - The Joubarbian Toolkit - EasyConnect
Back to top
View user's profile Send private message
N3ophyt3





Joined: 19 May 2011
Posts: 4 on topic

Thank you for registering your game
PostPosted: Mon, 28. May 18, 13:23    Post subject: Reply with quote Print

@Joubarbe

Quote:
The first element in your list has a $returnvalue of 0. $returnvalue can't be 0.


That did the trick. Thank you!!
Unfortunately it causes a gap of 1 integer to $getreturnvalue.

Quote:
Menu2:
$return02 = open custom menu: title='Set Your Stock Level' description='Stock Manipulation' option array=$custmenu2

$getreturnvalue = 0

while $getreturnvalue < $returnvalue
$ware = $TradeableWares[$getreturnvalue]
$maxamount = $input -> get max. store amount of ware $ware
$A1 = $maxamount / 4
$A2 = $maxamount / 4 * 2
$A3 = $maxamount / 4 * 3
$A4 = $maxamount
if $return1 == $getreturnvalue AND $return02 == $A
$a = $input -> add -9999999 units of $ware



For anyone who might be interested in this topic:
To work around this I added a new variable $truegetreturnvalue which starts at 0, while the $getreturnvalue starts at 1.
This closes the gap between $returnvalue and $getreturnvalue.



The script looks like this now:

$input = [THIS]-> get user input: type=[Var/Station], title='Select A Station'
$TradeableWares = $input-> get tradeable ware array from station


$IdStation = $input-> get ID code
$NameStation = $input-> get name

$SizeArray1 = size of array $TradeableWares

$A = 'a'
$B = 'b'
$C = 'c'
$D = 'd'
$E = 'e'
$counterarray = 0
$returnvalue = 1
$w = $TradeableWares[$counterarray]
$TextIntro = sprintf: fmt='Tradeabel Wares Of Your %s (%s)', $NameStation, $IdStation, null, null, null

$CustMenu = create custom menu array: heading='Your Selected Ware'
$custmenu2 = create custom menu array
add custom menu item to array $custmenu2: text=' 0 %' returnvalue=$A
add custom menu item to array $custmenu2: text=' 25 %' returnvalue=$B
add custom menu item to array $custmenu2: text=' 50 %' returnvalue=$C
add custom menu item to array $custmenu2: text=' 75 %' returnvalue=$D
add custom menu item to array $custmenu2: text='100 %' returnvalue=$E

while $counterarray < $SizeArray1
$w = $TradeableWares[$counterarray]
$aow1 = $input-> get max. store amount of ware $w
$aow2 = $input-> get amount of ware $w in cargo bay
$aow3 = $input-> get ware storage percentage: ware=$w
$text = sprintf: fmt='%s (%s // %s) (%s %)', $w, $aow2, $aow1, $aow3, null
add custom menu item to array $CustMenu: text=$text returnvalue=$returnvalue
$wait = wait 10 ms
inc $counterarray
inc $returnvalue
end

Menu1:
$return1 = open custom menu: title='Tradeable Wares' description=$TextIntro option array=$CustMenu

if $return1 == $returnvalue
goto label Menu2:
else if $return1 == -1
$scriptcall = [THIS]-> call script 'AA.Menu' :
return null
end

Menu2:
$return02 = open custom menu: title='Set Your Stock Level' description='Stock Manipulation' option array=$custmenu2

$getreturnvalue = 1
$truegetreturnvalue = 0

while $getreturnvalue < $returnvalue
$ware = $TradeableWares[$truegetreturnvalue]
$maxamount = $input-> get max. store amount of ware $ware
$A1 = $maxamount / 4
$A2 = $maxamount / 4 * 2
$A3 = $maxamount / 4 * 3
$A4 = $maxamount
if $return1 == $getreturnvalue AND $return02 == $A
$a = $input-> add -9999999 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $B
$b = $input-> add -9999999 units of $ware
$c = $input-> add $A1 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $C
$d = $input-> add -9999999 units of $ware
$e = $input-> add $A2 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $D
$f = $input-> add -9999999 units of $ware
$g = $input-> add $A3 units of $ware
else if $return1 == $getreturnvalue AND $return02 == $E
$h = $input-> add -9999999 units of $ware
$i = $input-> add $A4 units of $ware
else if $return1 == $getreturnvalue AND $return02 == -1
goto label Menu1:
end
$wait = wait 10 ms
inc $getreturnvalue
inc $truegetreturnvalue
end

return null

Back to top
View user's profile Send private message
Joubarbe





Joined: 31 Oct 2006
Posts: 3426 on topic
Location: France
Thank you for registering your game
PostPosted: Mon, 28. May 18, 13:32    Post subject: Reply with quote Print

You could also return the ware itself.

If you're on X-Studio, you should use the foreach macro.


_________________
Mayhem - Satellites Monitoring - ADS (Joubarbian Edition) - The Joubarbian Toolkit - EasyConnect
Back to top
View user's profile Send private message
N3ophyt3





Joined: 19 May 2011
Posts: 4 on topic

Thank you for registering your game
PostPosted: Mon, 28. May 18, 14:20    Post subject: Reply with quote Print

I will give that a try as well.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic
 
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Sat, 18. Aug 18, 11:57

All times are GMT + 2 Hours

[ Disclaimer / Impressum ] | [ Privacy Policy / Datenschutz ]

Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.18306 seconds, sql queries = 19