Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
hello everyone
i would like to use the mktab command to create this data structure:
S S S S
I I I I
I I I I
I I I I
Some of the I's in the first column will be negative, some positive. this data structure could use the mktab command since it will never change in size.
1.would this be an example of creating the table structure?
typeof array = tab [S I r1];;
2. let' say that this would be the contents of the table structure, what would the initialization of the structure look like?
"armor class" "up to 1-1" "1-1" "2-3" "Over 3"
-10 20 15 8 6
0 15 7 3 2
10 10 3 3 1
3. I would like be able to access specific instance of the integers (I) depending on the input of (S) [reflecting the top row] and I [reflecting the instances of I following the first row, in the first column).
//psuedocode
Prototype find_integer [S I] I;;
fun find_integer(S I)= // S is one of the strings in the first row, and I is one of the Integers in the first column, starting in the second row
//code block here, to return an instance of I starting after the first column and starting after the first row
;;
// for example find_integer ("1-1", 0) would return 15
//find_integer ("Over 3", 10) would return 1
//find_integer ("up to 1-1", 10) would return 3
It's been a few years since I've used scol and I am a bit rusty!
Thanks!
-Dan
ps fwiw, 10 years ago I tried to create a scol based player to work on android devices...it was just too much work for me to handle, dealing with bazillions of hardware issues that never end.
my present project is to create an assistant to help run dungeons and dragons games based on the first edition from the 1970's....keeping track of lots and lots of integers, and perhaps storage, creation, and access to 2d maps, to be instantiated with a touch screen table for the players and access to what the players see (and don't see) running on the dungeon master's own device. so some database stuff and network stuff so that parts of the game can be visible on multiple devices, perhaps remotely as well.
Last edited by hebdemnobad (12-Sep-2024 16:45:04)
Offline
Hello! and welcome back
Scol tab can only handle one type.
If I understand correctly you want to search a value from 2 index.
The col name and the first raw value ?
what you can do is to:
- make a name list of the col names matching the col index
- get the index from the name to search in data
var sHeader = ["armor class" 0]::["up to 1-1" 1]::["1-1" 2]::["2-3" 3]::["Over 3" 4]::nil;;
//typeof data = tab tab I;;
// create data from row index list (-10)::0::10::nil
fun makeData(lrowindex)=
let (sizelist sHeader) -> headersize in
let sizelist lrowindex -> nbrows in
let mktab nbrows nil -> ndata in
(
//create row with default 0 value
let 0 -> i in
while (i < nbrows) do
(
set ndata.(i) = mktab headersize 0;
//set row index value
let nth_list lrowindex i -> index in
set ndata.(i).(0) = index;
set i = i + 1;
);
ndata;
);;
fun setArmourClass(data, name, level, value)=
let switchstri sHeader name -> hindex in
let sizetab data -> tsize in
let -1 -> ret in
let 0 -> i in
(
while ((i < tsize) && (ret == -1)) do
(
if (data.(i).(0) != level) then nil else
(
set data.(i).(hindex) = value;
set ret = 1;
);
set i = i + 1;
);
ret;
);;
fun getArmourClass(data, name, level)=
let switchstri sHeader name -> hindex in
let sizetab data -> tsize in
let -1 -> ret in
let 0 -> i in
(
while ((i < tsize) && (ret == -1)) do
(
if (data.(i).(0) != level) then nil else
(
set ret = data.(i).(hindex);
);
set i = i + 1;
);
ret;
);;
fun main()=
//set data = makeData (-10)::0::10::nil;
let makeData (-10)::0::10::nil -> data in
(
setArmourClass data "up to 1-1" (-10) 20;
setArmourClass data "1-1" (-10) 15;
setArmourClass data "2-3" (-10) 8;
setArmourClass data "Over 3" (-10) 6;
setArmourClass data "up to 1-1" 0 15;
setArmourClass data "1-1" 0 7;
setArmourClass data "2-3" 0 3;
setArmourClass data "Over 3" 0 2;
setArmourClass data "up to 1-1" 10 10;
setArmourClass data "1-1" 10 3;
setArmourClass data "2-3" 10 3;
setArmourClass data "Over 3" 10 1;
_fooS strcat "1-1 : " (itoa getArmourClass data "1-1" 0);
_fooS strcat "Over 3 : " (itoa getArmourClass data "Over 3" 10);
_fooS strcat "up to 1-1 : " (itoa getArmourClass data "up to 1-1" 10);
);
0;;
output is :
1-1 : 7
Over 3 : 1
up to 1-1 : 10
I think you or I inverted "1-1" and "up to 1-1" order
Offline
thanks man I'll take a look at this!
I think the more labor saving method eventually will be to read csv files.
I'm happy to be doing this work again!
-Dan
Offline
thanks you didn't have to do all that!
I did have some problems understanding it but no need to explain it to me...I think it will be easier just to read csv files as that would make the data entry faster, as per my post below let me know how i can do that when you have time.
-Dan
Hello! and welcome back
Scol tab can only handle one type.
If I understand correctly you want to search a value from 2 index.
The col name and the first raw value ?what you can do is to:
- make a name list of the col names matching the col index
- get the index from the name to search in datavar sHeader = ["armor class" 0]::["up to 1-1" 1]::["1-1" 2]::["2-3" 3]::["Over 3" 4]::nil;; //typeof data = tab tab I;; // create data from row index list (-10)::0::10::nil fun makeData(lrowindex)= let (sizelist sHeader) -> headersize in let sizelist lrowindex -> nbrows in let mktab nbrows nil -> ndata in ( //create row with default 0 value let 0 -> i in while (i < nbrows) do ( set ndata.(i) = mktab headersize 0; //set row index value let nth_list lrowindex i -> index in set ndata.(i).(0) = index; set i = i + 1; ); ndata; );; fun setArmourClass(data, name, level, value)= let switchstri sHeader name -> hindex in let sizetab data -> tsize in let -1 -> ret in let 0 -> i in ( while ((i < tsize) && (ret == -1)) do ( if (data.(i).(0) != level) then nil else ( set data.(i).(hindex) = value; set ret = 1; ); set i = i + 1; ); ret; );; fun getArmourClass(data, name, level)= let switchstri sHeader name -> hindex in let sizetab data -> tsize in let -1 -> ret in let 0 -> i in ( while ((i < tsize) && (ret == -1)) do ( if (data.(i).(0) != level) then nil else ( set ret = data.(i).(hindex); ); set i = i + 1; ); ret; );; fun main()= //set data = makeData (-10)::0::10::nil; let makeData (-10)::0::10::nil -> data in ( setArmourClass data "up to 1-1" (-10) 20; setArmourClass data "1-1" (-10) 15; setArmourClass data "2-3" (-10) 8; setArmourClass data "Over 3" (-10) 6; setArmourClass data "up to 1-1" 0 15; setArmourClass data "1-1" 0 7; setArmourClass data "2-3" 0 3; setArmourClass data "Over 3" 0 2; setArmourClass data "up to 1-1" 10 10; setArmourClass data "1-1" 10 3; setArmourClass data "2-3" 10 3; setArmourClass data "Over 3" 10 1; _fooS strcat "1-1 : " (itoa getArmourClass data "1-1" 0); _fooS strcat "Over 3 : " (itoa getArmourClass data "Over 3" 10); _fooS strcat "up to 1-1 : " (itoa getArmourClass data "up to 1-1" 10); ); 0;;
output is :
1-1 : 7
Over 3 : 1
up to 1-1 : 10I think you or I inverted "1-1" and "up to 1-1" order
Offline
i am thinking reading csv files would make data entry easier than hand coding if i have, like, 300 pages of this...as per my other post lmk how i can load a csv file into scol and I'll figure out the api functions posted to redmine...it doesn't appear that you have integrated csv functions into a plugit unless i am missing something
behold a scan of the game I would like to automate, from when I was 12 years old:
Last edited by hebdemnobad (18-Sep-2024 19:55:54)
Offline
Os3dtools.pkg have several functions to read or write csv data
hi i tried this but the interpreter is not compiling i'm sure i'm missing something elementary. here is the relevant csv file
here is the relevant code...i'm rusty i know! (the textfile.scol, textfile.pkg, tools.pkg (copied from C:\Program Files\Scol Voyager\Partition_LockedApp\tools\os3dlib) and monsterfile.csv files are in openspace3d/textfile
fun main()=
_load "textfile/tools.pkg";
_showconsole;
let _getpack (_checkpack "textfile/monsterfile.csv")-> csvfile in
let readCSVdata csvfile "," -> [firstelement tail of list] in //i just want to see if i can read head of return value from readCSVdata and will write code to read from rest of list later
let (hd firstelement)-> datalist in
_fooSList datalist;
0;;
I am able to read the csv file and load it into a string but I don't know how to get the correct return to use the CSV parser / writer api
so this works and puts the output into a text file which reads:
hit dice,up to 1-1 hit dice,1-1 hit dice,2-3 hit dice,Over 3 hit dice
armor class,,,,
-10,20,15,8,6
0,15,7,8,2
10,10,3,3,1
here is the scol code...so i can get the csv file into a string, but not into a form that I can use the CSV parser / writer api with:
fun main()=
_load "textfile/tools.pkg";
_showconsole;
let _checkpack "textfile/monsterfile.csv"-> csvfile in
let _getpack csvfile-> csvfile in
_storepack csvfile "textfile/monsterfileoutput.txt";
0;;
-Dan
Last edited by hebdemnobad (18-Sep-2024 19:46:30)
Offline
To use the OS3D libs file you need to load them in order in the .scol file
_load "tools/os3dlib/tools.pkg"
_load "tools/os3dlib/2dglib.pkg"
_load "yourcode.pkg"
main
Offline