Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Luke_Nukem

Pages: 1 ... 7 8 [9]
121
Scripting / Re: Passing a "global name" to a function?
« on: June 09, 2014, 02:46:34 AM »
Hey dude. I've refined my example above quite a bit, works an absolute charm!

See here; http://forum.attractmode.org/index.php?topic=8.msg28#msg28

122
Scripting / Re: Colour cycling script.
« on: June 09, 2014, 02:44:37 AM »
updated code, again...

Code: [Select]
cycleVTable <-{
"cnListPinch" : 0, "swListPinch" : 0, "wkListPinch" : 0,
"cnListRed" : 0, "swListRed" : 0, "wkListRed" : 0,
"cnListGreen" : 0, "swListGreen" : 0, "wkListGreen" : 0,
"cnListBlue" : 0, "swListBlue" : 0, "wkListBlue" : 0,
}

function cycleValue( ttime, counter, switcher, workValue, minV, maxV, BY, speed ) {
if (cycleVTable[counter] == 0)
cycleVTable[counter] = ttime;
////////////// 1000 = 1 second //////////////
if (ttime - cycleVTable[counter] > speed){
if (cycleVTable[switcher]==0){
cycleVTable[workValue] += BY;
if (cycleVTable[workValue] >= maxV)
cycleVTable[switcher] = 1;
}
else
if (cycleVTable[switcher]==1){
cycleVTable[workValue]  -= BY;
if (cycleVTable[workValue] <= minV)
cycleVTable[switcher] = 0;
}
cycleVTable[counter] = 0;
}
return cycleVTable[workValue];
}

fe.add_ticks_callback( "textTickles" );
function textTickles( ttime ) {
//To get a negative, need to use a temporary var and - it.
local temp = cycleValue(ttime, "cnListPinch", "swListPinch", "wkListPinch", 10, 25, 1, 20);
romListSurf.pinch_x = -temp;
local RED = cycleValue(ttime,"cnListRed","swListRed","wkListRed",100,254,1,20);
local GREEN = cycleValue(ttime,"cnListGreen","swListGreen","wkListGreen",100,254,1.5,20);
local BLUE = cycleValue(ttime,"cnListBlue","swListBlue","wkListBlue",100,254,2,20);
romList.set_rgb(RED, GREEN, BLUE);
gameTitle.set_rgb(RED, GREEN, BLUE);
listPosition.set_rgb(RED, GREEN, BLUE);
}

And the comment to help explain it;
Code: [Select]
// This function should be pretty self explanatory;
// cycleValue( ttime, this is the tick time.
// counter, this keeps track of time passed since last call.
// switcher, this keeps track of wether to increment or decrement.
// workValue, this is the value that is passed to the function, worked on and returned.
// minV and maxV are the min/max to decrement or increment up to.
// BY, is the amount to increase or decrease workVakue by.
// speed is the length of time to wait to run again. 500 = half second.
////
// This function does require the table to work correctly.

I hope this comes in useful for all sorts of things for everyone...

123
Scripting / Re: Passing a "global name" to a function?
« on: June 08, 2014, 05:40:04 PM »
I came up with this, I've been trying to refine some parts of my layout, and wanted my increment over time code, to be in a single function that could be used for any purpose, rather than copy/paste style.

Code: [Select]
switchVals <-{
"swTEST" : 0,
"tTEST" : 0,
"rTEST" : 0
}

function increment( ttime, counter, switcher, returnVal ) {
if (switchVals[counter] == 0)
switchVals[counter] = ttime;
print("counter = "+switchVals[counter]+"\n");
////////////// 1000 = 1 second //////////////
if (ttime - switchVals[counter] > 100){
print("In to switch block\n");
if (switchVals[switcher]==0){
switchVals[returnVal] += 1;
if (switchVals[returnVal] >= 25){
switchVals[switcher] = 1;
}
}
else
if (switchVals[switcher]==1){
switchVals[returnVal]  -= 1;
if (switchVals[returnVal] <= 10)
switchVals[switcher] = 0;
}
switchVals[counter] = 0;
}
return switchVals[returnVal];
}

fe.add_ticks_callback( "textTickles" );

function textTickles( ttime ) {

switchVals["rTEST"] = increment(ttime,"tTEST","swTEST","rTEST");
print(switchVals["rTEST"]+"\n");
}

I'll probably refine it a bit more after work.

124
Scripting / Re: Passing a "global name" to a function?
« on: June 08, 2014, 12:47:32 PM »
Thanks liquid8d.
I figured I could perhaps use an array to do it, and while looking through the squirrel ref, stumbled across that. The lexical style is damn confusing at best though.
Thanks for the example, it clears it up in my head quite nicely.

125
General / Re: Feature requests?
« on: June 08, 2014, 12:45:26 PM »
It is, especially if you set up the defaults correctly.

eg;
Code: [Select]
executable           ../hyperlaunch/hyperlaunch.exe
args                 "[emulator]" "[romfilename]"
rompath              ../emulators/[emulator]/roms/
romext               .zip
artwork    flyer           ../artwork/[emulator]/flyer
artwork    marquee   ../artwork/[emulator]/marquee
artwork    snap           ../artwork/[emulator]/videos;../artwork/[emulator]/snap
artwork    wheel        ../artwork/[emulator]/wheel

There is the minor problem of although HL is great, it can also suck big time. You'll also need the hyperspin.exe and databases in the attractmode dir.
I prefer the older hyperlaunch release 2.0.

Last thing. warp layout isn't mine, it's raygun's (AM creator). All I've done is branched the master and added "swapper", it will hopefully get pulled upstream.

126
Scripting / Passing a "global name" to a function?
« on: June 07, 2014, 08:39:59 PM »
I've got a tricky one...

Lets say I'm trying to pass a global variable name to a function, not the value of that variable itself.

Code: [Select]
testName <- 0;
function test (x,y,varName){
      local x = x;
      local y = y;
      varName = 1;
    return x+y;
}
local testFun = test(3,5,testName);
print ("testFun = "+testFun+"\n");
print ("testName = "+testName+"\n");

I would expect this to print
Code: [Select]
8
1

Except varName is local to the function, and gets passed a 0.
It then changes the 0 to a 1 in the function, but because it was done locally to that function, testName remains as 0.

I could of course use testName in the function itself, but I'm trying to pass the name of that var to the function. A bit like a pointer.

Anybody have any ideas?

127
General / Re: Feature requests?
« on: June 07, 2014, 08:24:50 PM »
I too was an Hyperspin user. These days i can't stand the slow bloated shitpile.

AttractMode is very easy to use, it's just when you get to themes/plugins etc, that it helps to be familiar with at least one or two programming languages.
Great excuse to learn, if you aren't a programmer of some sort already.

1: There was somebody working on a layout editor, from I understand, they threw in the towel.
I've considered writing one myself, I dunno.

2: This could be done with script by checking the [title] and executing another layout script.

3: I'm using Hyperlaunch with AM for the moment. But also, you can do this in scripts.
Specifically the transitions Transition.FromGame and Transition.ToGame, combine those with being able to have a separate layout for each emulator, and you shouldn't have a problem.
For example, Transition.ToGame could run fe.do_nut("mame.nut"); which would be a script that executes xpadder.exe and sets a profile.

AttractMode is extremely powerful once you start digging in to it. It's just not point and click, and requires a functioning brain with the ability to learn.

Have a look through the extras on github.
Also, I've written my own layout, feel free to have a look https://github.com/Luke-Nukem/attract-extra/tree/master/layouts/swapper

128
Scripting / Re: Colour cycling script.
« on: June 07, 2014, 08:07:47 PM »
Refactored the code quite a bit. The joy of learning.

Code: [Select]
if (ttime - rgbTime > 2){
if (swR==0){
if (romListRed < 254)
romListRed += 1;
if (romListRed >= 254)
swR = 1;
}
else if (swR==1){
if (romListRed > 100)
romListRed  -= 2;
if (romListRed <= 100)
swR = 0;
}
///////////////////////////
if (swG==0){
if (romListGreen < 254)
romListGreen += 2;
if (romListGreen >= 254)
swG = 1;
}
else if (swG==1){
if (romListGreen > 100)
romListGreen  -= 1;
if (romListGreen <= 100)
swG = 0;
}
///////////////////////////
if (swB==0){
if (romListBlue < 254)
romListBlue += 1.5;
if (romListBlue >= 254)
swG = 1;
}
else if (swB==1){
if (romListBlue > 100)
romListBlue  -= 1.5;
if (romListBlue <= 100)
swG = 0;
}
rgbTime = 0;
}

You can use this for other things such as;
Code: [Select]
if (ttime - pinchTime > 0.5){
if (swPinch==0){
romListPinch += 1;
if (romListPinch >= 75){
swPinch = 1;
}
}
else
if (swPinch==1){
romListPinch  -= 1;
if (romListPinch <= 25)
swPinch = 0;
}
pinchTime = 0;
}
romListSurf.pinch_x = -(romListPinch);

129
Scripting / Re: Dynamic change res
« on: June 07, 2014, 02:32:36 PM »
I think you still have to manually activate those scipts with fe.do_nut.

I also rewrote the above code to be much more elegant;
Code: [Select]
local layoutSettings = fe.get_config();
switch (layoutSettings["screenSize"]){
case "1360x768":
switch (layoutSettings["rotated"]){
case "Yes": fe.layout.width=768; fe.layout.height=1360; break;
case "No" : fe.layout.width=1360; fe.layout.height=768; break;
}
break;
case "1280x1024":
switch (layoutSettings["rotated"]){
case "Yes": fe.layout.width=1024; fe.layout.height=1280; break;
case "No" : fe.layout.width=1280; fe.layout.height=1024; break;
}
break;
case "1280x768":
switch (layoutSettings["rotated"]){
case "Yes": fe.layout.width=768; fe.layout.height=1280; break;
case "No" : fe.layout.width=1280; fe.layout.height=768; break;
}
break;
case "1280x720":
switch (layoutSettings["rotated"]){
case "Yes": fe.layout.width=720; fe.layout.height=1280; break;
case "No" : fe.layout.width=1280; fe.layout.height=720; break;
}
break;
}


FOrmatting of it hasn't translated well to the forum though, it's just adding an extra tab to the case "No" line

130
Scripting / Colour cycling script.
« on: June 06, 2014, 06:58:27 PM »
Hi guys. Thought you might like to have a nosey at my script for cycling through colours for an item.
Pretty simple I guess, uses a tick timer and a counter. Set up as 3 individual elements for each colour.

Code: [Select]
fe.add_ticks_callback( "tick" );
//
local swR = 0;
local swG = 0;
local swB = 0;
local romListRed = 0;
local romListGreen = 0;
local romListBlue = 0;
local redTime = 0;
local greenTime = 0;
local blueTime = 0;

function tick( ttime ) {

if (redTime == 0)
redTime = ttime;
if (greenTime == 0)
greenTime = ttime;
if (blueTime == 0)
blueTime = ttime;
/////////////////////////////////////////////////////////
if (ttime - redTime > 0.15){
if (swR==0){
if (romListRed < 254)
romListRed += 3;
if (romListRed >= 254){
swR = 1;
}
}
else
if (swR==1){
if (romListRed > 100)
romListRed  -= 3;
if (romListRed <= 100){
swR = 0;
}
}
redTime = 0;
}
/////////////////////////////////////////////////////////
if (ttime - greenTime > 0.1){
if (swG==0){
if (romListGreen < 254)
romListGreen += 1;
if (romListGreen >= 254){
swG = 1;
}
}
else
if (swR==1){
if (romListGreen > 100)
romListGreen  -= 1;
if (romListGreen <= 100){
swG = 0;
}
}
greenTime = 0;
}
/////////////////////////////////////////////////////////
if (ttime - blueTime > 0.05){
if (swR==0){
if (romListBlue < 254)
romListBlue += 1;
if (romListBlue >= 254){
swR = 1;
}
}
else
if (swR==1){
if (romListBlue > 100)
romListBlue  -= 1;
if (romListBlue <= 100){
swR = 0;
}
}
blueTime = 0;
}
set_bright( romListRed, romListGreen, romListBlue, romList );
}

The set_bright function is from one of the other scripts available, though i did modify it to set each r,g,b colour.

To change how long each colour takes to cycle up and down, edit;
Code: [Select]
if (ttime - redTime > 0.15){
This could be adapted to all sorts of applications i bet..

Cheers!

131
Scripting / Re: Dynamic change res
« on: June 05, 2014, 05:40:24 PM »
I agree there.
Hmm, I'm having difficulty trying to work out how to get the value of the screen rotation...
It doesn't seem to be very open to script?

132
Scripting / Re: Share some Shader info
« on: June 05, 2014, 04:53:16 PM »
Some of those are pretty cool!

Vertex shaders are used for doing things like editing the dimensions.
An example would be, you have an image on screen, which when proccessed, is really 2 polygons together to make a square/rectangle etc. You can then use a vertex shader to maybe throw a sine wave on each vertex (dot in the corner where poly lines meet) to move the position over a time scale.
Or just change the positions so the image looks stretched/pulled on one side.

I actually just pushed to my branch of attract-extras, it has an excellent blur shader. I can't remember where I got it from though.
https://github.com/Luke-Nukem/attract-extra/tree/master/layouts/Swapper

What languages are you proficent in?

133
Scripting / Dynamic change res
« on: June 05, 2014, 01:24:42 PM »
G'day guys.
Thought I'd share this little block with you all.

I wasn't very happy with how AttractMode was handling screen res and rotation, so I ended up brewing up what is just a large if-else block and some options.
This combined with positions/sizes that are divided from the layout width and height, actually becomes quite robust. The only hardcoded positions I tend to have now are a few text strings in corners, everything else is relative to width/height.

Maybe I missed it, but does AttractMode have an actual return global for when it is rotated?
It would be excellent to have this check the global and select the width/height accordingly.

Code: [Select]
class UserConfig {
</ label="Screen Size", help="Select the screen size",
options="1360x768,1280x1024,1280x768,1280x720" />
screenSize="1360x768";

</ label="Screen Rotate", help="Swap X/Y dimensions for rotated screens",
options="Yes,No" />
rotated="No";
}
local layoutSettings = fe.get_config();

if ( layoutSettings["screenSize"] == "1360x768" ){
if ( layoutSettings["rotated"] == "Yes") {
fe.layout.width=768;
fe.layout.height=1360;
}
else if ( layoutSettings["rotated"] == "No") {
fe.layout.width=1360;
fe.layout.height=768;
}
}
else if ( layoutSettings["screenSize"] == "1280x1024" ){
if ( layoutSettings["rotated"] == "Yes"){
fe.layout.width=1024;
fe.layout.height=1280;
}
else if ( layoutSettings["rotated"] == "No") {
fe.layout.width=1280;
fe.layout.height=1024;
}
}
else if ( layoutSettings["screenSize"] == "1280x768" ){
if ( layoutSettings["rotated"] == "Yes") {
fe.layout.width=768;
fe.layout.height=1280;
}
else if ( layoutSettings["rotated"] == "No") {
fe.layout.width=1280;
fe.layout.height=768;
}
}
else if ( layoutSettings["screenSize"] == "1280x720" ){
if ( layoutSettings["rotated"] == "Yes") {
fe.layout.width=720;
fe.layout.height=1280;
}
else if ( layoutSettings["rotated"] == "No") {
fe.layout.width=1280;
fe.layout.height=720;
}
}

134
Scripting / Re: Learning Squirrel
« on: June 05, 2014, 01:46:43 AM »
Great website, thanks for sharing.
If you come across any books at all, please let us know.

135
Scripting / Re: ExtendedObjects and Animate library
« on: June 05, 2014, 01:45:15 AM »
Wow, top work. I will be looking forward to seeing this in action.

Pages: 1 ... 7 8 [9]