Skip to content

Commit

Permalink
Fixed logic in version analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
simustyt committed Jun 4, 2024
1 parent 9fe7195 commit dbbe656
Showing 1 changed file with 57 additions and 25 deletions.
82 changes: 57 additions & 25 deletions pak128.prototype/scenario/tutorial/scenario.nut
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,26 @@ function string_analyzer()

// Analyzer scenario simutrans version -----------------------------------------------------------------------------------------
local value_a = ""
for(local j=nr_a;j<s_siz.a;j++){
for(local j=0;j<s_siz.a;j++){
local tx = format("%c",simu_version[j])
if(tx=="."){
nr_a = j+1
val_a.push(value_a.tointeger())
value_a = ""
continue
local result = get_integral(tx)
if(result.res){
value_a += tx
if(j == s_siz.a-1) {
val_a.push(value_a)
continue
}
}
value_a += tx
if(j == s_siz.a-1) {
val_a.push(value_a.tointeger())
else {
if(j == s_siz.a-1) {
val_a.push(value_a)
continue
}
if(result.val == "."){
val_a.push(value_a)
value_a = ""
continue
}
}
}
//-------Debug ====================================
Expand All @@ -185,34 +194,36 @@ function string_analyzer()

// Analyzer current simutrans version -------------------------------------------------------------------------------------
local value_b = ""
for(local j=nr_b;j<s_siz.b;j++){
for(local j=0;j<s_siz.b;j++){
local tx = format("%c",current_st[j])
if(j == s_siz.b-1) {
val_b.push(value_b.tointeger())
}
try {
tx.tointeger()
local result = get_integral(tx)
if(result.res){
value_b += tx
if(j == s_siz.b-1) {
val_b.push(value_b)
continue
}
}
catch(ev) {
if(tx=="."){
nr_b = j+1
val_b.push(value_b.tointeger())
else {
if(j == s_siz.b-1) {
val_b.push(value_b)
continue
}
if(result.val == "."){
val_b.push(value_b)
value_b = ""
continue
}
nr_b++
continue
}
value_b += tx
}
//-------Debug ====================================
/*

local txtb = ""
for(local j=0; j<val_b.len() ;j++){
txtb += (val_b[j] +" :: ")
}
gui.add_message("list B: "+txtb +" -- val_b siz: "+val_b.len())
*/

//-------Debug ====================================
//------------------------------------------------------------------------------------------------------------------------------

Expand All @@ -223,7 +234,7 @@ function string_analyzer()
for(local i = 0; i < siz_va && i < siz_vb; i++ ) {
local num_a = val_a[i]
local num_b = val_b[i]
//gui.add_message("Array test -- val_a "+num_a+" value_b "+num_b+" -- siz_A "+siz_va+" siz_B "+siz_vb)
//gui.add_message("Array test -- val_a "+num_a+" val_b "+num_b+" -- siz_A "+siz_va+" siz_B "+siz_vb)
if(num_a < num_b) {
result.st = true
return result
Expand All @@ -248,6 +259,27 @@ function string_analyzer()
return result
}

function get_integral(tx)
{
local result = {val = null, res = false}
local evet = false
try {
tx.tointeger()
}
catch(ev) {
evet = true
}
if(evet){
result.val = tx
result.res = false
}
else{
result.val = tx.tointeger()
result.res = true
}
return result
}

{
//Check version and pakset name
resul_version = string_analyzer()
Expand Down

0 comments on commit dbbe656

Please sign in to comment.