Author Topic: Scripting Help - First time user  (Read 5228 times)

doosh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Scripting Help - First time user
« on: December 05, 2019, 09:59:21 AM »
Hi

I am new to this forum, have not experience in programming, and a first time user of Attract Mode.

I seek some help on creating a basic script that does the following:

- Wheel art games list - Like in the FE HyperSpin
- Full screen video of the game selected from the games list

Any help is appreciated.

Thanks
D

doosh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scripting Help - First time user
« Reply #1 on: December 30, 2019, 11:30:54 AM »
Hi

Just following up of anyone is kindly able to assist me with my request above.

Any help is appreciated.

D

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Scripting Help - First time user
« Reply #2 on: December 30, 2019, 12:08:46 PM »
Start here to learn how to make a simple layout. This should be enough to add your video background.

https://attractmode.gitlab.io/wiki/reference/squirrel-language/

Then look at the included conveyor module or oomeks carrier module for wheel.

https://github.com/oomek/AttractMode-Carrier/blob/master/carrier.nut

pcca-matrix

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Scripting Help - First time user
« Reply #3 on: December 31, 2019, 05:48:04 AM »
if he has no programming experience, read the doc will not help him !

sometimes some simple example can help a lot  ;)

Code: [Select]
flx <- fe.layout.width=1920;
fly <- fe.layout.height=1080;

// modules
fe.load_module("conveyor");

// Wheel
local wheel_x = [ flx*0.94, flx*0.935, flx*0.896, flx*0.865, flx*0.84, flx*0.82, flx*0.78, flx*0.82, flx*0.84, flx*0.865, flx*0.896, flx*0.90, ];
local wheel_y = [ -fly*0.22, -fly*0.105, fly*0.0, fly*0.105, fly*0.215, fly*0.325, fly*0.436, fly*0.61, fly*0.72 fly*0.83, fly*0.935, fly*0.99, ];
local wheel_w = [ flx*0.15, flx*0.15, flx*0.15, flx*0.15, flx*0.15, flx*0.15, flx*0.22, flx*0.15, flx*0.15, flx*0.15, flx*0.15, flx*0.15, ];
local wheel_h = [  fly*0.10,  fly*0.10,  fly*0.10,  fly*0.10,  fly*0.10,  fly*0.10, fly*0.14,  fly*0.10,  fly*0.10,  fly*0.10,  fly*0.10,  fly*0.10, ];
local wheel_r = [  30,  25,  20,  15,  10,   5,   0, -10, -15, -20, -25, -30, ];
local wheel_a = [  90,  90,  90,  90,  90,  90, 90,  90,  90,  90,  90,  90, ];
local num_arts = 8;

class WheelEntry extends ConveyorSlot
{
constructor()
{
base.constructor( ::fe.add_artwork( "wheel") );
}

function on_progress( progress, var )
{     
local p = progress / 0.1;
local slot = p.tointeger();   
p -= slot;
slot++; 
if ( slot < 0 ) slot=0;
if ( slot >=10 ) slot=10;
        m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
        m_obj.y = wheel_y[slot] + p * ( wheel_y[slot+1] - wheel_y[slot] );
        m_obj.width = wheel_w[slot] + p * ( wheel_w[slot+1] - wheel_w[slot] );
        m_obj.height = wheel_h[slot] + p * ( wheel_h[slot+1] - wheel_h[slot] );
        m_obj.rotation = wheel_r[slot] + p * ( wheel_r[slot+1] - wheel_r[slot] );
        m_obj.alpha = wheel_a[slot] + p * ( wheel_a[slot+1] - wheel_a[slot] );       
}
};

local wheel_entries = [];
for ( local i=0; i<num_arts/2; i++ ) {   
    wheel_entries.push( WheelEntry() );
}
local remaining = num_arts - wheel_entries.len();

for ( local i=0; i<remaining; i++ )
wheel_entries.insert( num_arts/2, WheelEntry() );

local conveyor = Conveyor();
conveyor.set_slots( wheel_entries );
conveyor.transition_ms = 50;
try { conveyor.transition_ms = my_config["transition_ms"].tointeger(); } catch ( e ) { }

// Video Snap
local snap = fe.add_artwork("snap", 0, 0, flx, fly);
snap.preserve_aspect_ratio = false;
snap.zorder=-1;

doosh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Scripting Help - First time user
« Reply #4 on: December 31, 2019, 11:35:55 AM »
Thanks guys

I will try the code above and to see what it looks like - thank you.

Stupid question - where do I place the code above (which directory), and what should the file name be called?

Thank you.

Regards

D

asahendrix

  • Full Member
  • ***
  • Posts: 76
    • View Profile
Re: Scripting Help - First time user
« Reply #5 on: December 31, 2019, 07:12:53 PM »
Thanks guys

I will try the code above and to see what it looks like - thank you.

Stupid question - where do I place the code above (which directory), and what should the file name be called?

Thank you.

Regards

D

Welcome to AM! I’m a baby coder and believe me when I say that there is no such thing as a stupid question.

I don’t have my Pi open right now so this is off the top of my head:
-You will put that code in a text file and rename it “layout.nut”. Any layout you create will always need to simply be named “layout”.
-This layout file will go in a layout folder that you create. The name of this folder can be whatever you want - but it’s usually the name that you want to name your layout. For instance, a layout that I am working on is called MatteClean. So, the folder that I created to put my layout file in is called “MatteClean”. Whatever you name you decide on is the name that will show up when you are selecting a layout inside Attract Mode.

-A lot of the media that you want to integrate into your layout either now or in the future will need to be put into your layout folder. If you’re wanting to use game wheels and game art, these jpg or png files will need to go into the system rom folder where your rom files are.

-If I’m not mistaken, the layout folders are under “.attract/layouts” or “.attract/themes” - again this is off the top of my head so someone correct me if I’m wrong. In order to see the “.attract” folder you will need to have show hidden files. I personally use WinSCP to access my AM files. As long as you can get into the “.attract” folder, the rest should be pretty self explanatory.

I hope this helps! Have fun!

sosimple

  • Full Member
  • ***
  • Posts: 57
    • View Profile
Re: Scripting Help - First time user
« Reply #6 on: January 31, 2020, 05:32:42 AM »
You don't actually needs to know coding to create a theme. You just need to change in layout.nut:
0. Find where you change resolution of the theme and try some values to much the size you want.
Also  change in code the resolution not to what resolution is your monitor but what resolution display the theme as big as you like.
For example a theme had in layout.nut
fe.layout.width = 1920
fe.layout.height = 1080
(1920%1080 = 1,77)
My screen resolution is 2160x1440 (2160%1440=1.5)
If i change the resolution to mine, theme is ok, go fullscreen but with black bars and is to small everything (for my 12 inch screen). So everything looks bigger and use all monitor without black bars by setting resolution
fe.layout.width = 1900
fe.layout.height = 1260
Notice i keep aspect retio the same. (1900%1260=1.5)
This is useful for every theme to change it display as we want for the monitor we use. But of course it is not a universal methodology. It will work only for our monitor.

1. Use a theme which looks like the one you want to create.
2. Take a photo you want to use in your theme. Use any photo editing program and make transparent where the screen is.
3. Learn the 4 basic values in the code which represent width, hight, start x position, start y position of the videosnap.
It will be something like this:
// Snap
   flxc = flx*0.5645;   
   flyc = fly*0.2214;
   flwc = flw*0.2813;
   flhc = flh*0.2807;


5. Change those 4 values until the videosnap go where the transparent screen is.
It will be become  like this:
// Snap
   flxc = flx*0.5645+35;    // By + it moves videosnap to the right
   flyc = fly*0.2214-170; // By + moves the videosnap Down
   flwc = flw*0.2813+190; // By + it increases width of videosnap
   flhc = flh*0.2807+215;    // By + it increases the hight of videosnap
You can use + or - to the default values of the theme to change it . Try many values ,start stop attractmode to see the changes untill videosnap go to the transparent place of the backgound image (usually where the screen is)

Other theme may have those values this way:
local t = fe.add_artwork( "snap", 348, 152, 262, 262 );
for example i modified this values to my theme to this:
local t = fe.add_artwork( "snap", 348+240, 152-60, 262+550, 262+380 );


 Those are enough.

At future you may learn the values of moving game list etc.
I may create a thread with directions of doing this and a sample script. Probably a YouTube video also, if and when i found the time if it helps.
I am actually newbie, I don't have the knowledge of others here. But i have created many themes i wanted this way.

Those 2 themes have been modified by me this way. Ok the amiga theme looks exactly the same but I have actually downloaded the same photo (I could have used other but I liked this) , make transparent the screen so to have the part of the picture i wanted because i use the theme in a tablet 12 inch screen and wanted bigger screen. I actually did a bad job if you notice the transparent screen haven't been cut good.
I also changed resolution to have the result you see in the video in a tablet with 12 inch screen and the resolution i wrote above.


In Amstrad theme, notice in cassette, every time i change game, it display on the cassette the game name. And in keyboard you see eg 51/150. I moved those values to go where i wanted.

https://youtu.be/oIwWmuo_gtM

https://youtu.be/uSb-QaIhoeo


I hope those helps.
« Last Edit: January 31, 2020, 06:45:20 AM by sosimple »