The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: THLeaderH on June 30, 2020, 03:04:19 PM

Title: Registration of Squirrel Standard Library
Post by: THLeaderH on June 30, 2020, 03:04:19 PM
Squirrel provides Squirrel Standard Library (http://www.squirrel-lang.org/squirreldoc/stdlib/index.html) that enables us to use basic I/O, string and math functions. However, these need a registration in the C++ code to use them in a squirrel code. For example, the I/O library needs the execution of sqstd_register_iolib (http://www.squirrel-lang.org/squirreldoc/stdlib/stdiolib.html#c.sqstd_register_iolib). Current simutrans does not seem to do this routine and the Standard Library is unavailable.

It would be useful if I can use the Standard Library in squirrel code. Is there any reason not to support them in Simutrans?
Title: Re: Registration of Squirrel Standard Library
Post by: Dwachs on July 01, 2020, 05:20:34 AM
Parts of this lib are used: math, string, and system. I did not see a reason to also register the other parts. Why do want to use this?
Title: Re: Registration of Squirrel Standard Library
Post by: makie on July 01, 2020, 07:29:59 AM
Quotethe I/O library
Open I/O, open a security problem. You can read and write files on the PC of the player. Maybe you want read some information from file in a script.
But this can be miss used too.
Title: Re: Registration of Squirrel Standard Library
Post by: THLeaderH on July 01, 2020, 12:48:39 PM
Yes, I want to use the I/O library to extract some information of games as a file and use them with external programs, only with squirrel scripts. However, I have to admit that supporting I/O brings a security problem as makie put it.
Title: Re: Registration of Squirrel Standard Library
Post by: prissi on July 01, 2020, 01:50:56 PM
One could force the files to be limtied to the simutrans directory by forbidding any path characters like /\:,; or so.