clear the screen

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

clear the screen

Post by RayB »

1 - Is there any way to clear the preview screen using script as opposed to the CLR button once you have printed to it with the 'print()' command?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: clear the screen

Post by minmay »

Just type

Code: Select all

clear
in the console and press enter.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

Re: clear the screen

Post by RayB »

Thank you but I was referring to the script itself. If I am in the dungeon maker I don't have the council unless I press F12 and then type clear and then press F12 again to get rid of the council input. If I am going to do all that I might just as well press the CLR button. What I am trying to do is clear the screen with a line of script in my code. I have created a small section of tiles and code on Level 1. I can place an item in a particular tile (I use 0,0), place my start position arrow in another (non-game) area of 3 tiles with buttons on the wall and then hit run. When one of the buttons is pressed the code will look at the item in 0,0 then look at all the levels in the dungeon and tell me how many of that item I have on each level. Another of the buttons will allow me to select a particular level and the third button will tell me what tiles contain the items on that level (ie. 1 at 5,19 - 2 at 6,24 etc.). In cases where there are a lot of items it would be nice to be able to clear the screen with the code at certain intervals because of the 15 lines of print limitation.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: clear the screen

Post by minmay »

Well, you can't actually clear the console from within a script that I know of, but you can get rid of existing lines with

Code: Select all

for i=1,20 do print("") end
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: clear the screen

Post by Isaac »

You could add that to a general utility script as a function, and call it from any other script_entity.

Ut.script:cls()
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

Re: clear the screen

Post by RayB »

Thanks but I was already aware of that method. On my system, after 15 lines, the screen scrolls so line 16 is printed on line 15 and line 1 disappears. After using the loop the screen does clear but all succeeding lines are printed on line 15 rather then starting at the top.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: clear the screen

Post by Isaac »

RayB wrote:Thanks but I was already aware of that method. On my system, after 15 lines, the screen scrolls so line 16 is printed on line 15 and line 1 disappears. After using the loop the screen does clear but all succeeding lines are printed on line 15 rather then starting at the top.
Clear screen relies on the os.execute(), and it's not present in LoG2; aside from that it obviously works via the button. So Petri would have to either mention his secret to this, or add a clear() function.
Last edited by Isaac on Wed May 06, 2015 10:46 pm, edited 2 times in total.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: clear the screen

Post by minmay »

Well, clearing an ingame monitor doesn't necessarily require os.execute(), since it's totally contained within the game, and I assume it's what the OP wanted. There's no way to do it in Grimrock as a user other than typing "clear" though.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: clear the screen

Post by Isaac »

*I would bet that there is some printed escape sequence that will clear the screen, but I haven't found it yet.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: clear the screen

Post by minmay »

Nope, just tried with all 256 characters. None clear the screen.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply