Author Topic: Scripting Help - First time user  (Read 320 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: 1032
    • 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: 2
    • 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: 67
    • 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!