Go Back   StepMania Forums > StepMania Discussion > Themes, NoteSkins, Game Types > Theme/Noteskin Tutorials and Misc. Things

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average. Display Modes
Old 05-17-2009, 09:31 AM   #1
AJ 187
REAL STEPPING ROOTS '09
 
AJ 187's Avatar
 
Join Date: Aug 2006
Location: Chicago
Posts: 1,432
AJ 187 is a 7 bar userAJ 187 is a 7 bar user
Reputation: 115

Send a message via AIM to AJ 187
Post rating: Votes: 0 Score: 0rate    
Rate this thread:
  • Currently 1.00/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
[1]
Default [SM4] Custom MemoryCardDisplay Framework

hi I just made up this framework for a custom MemoryCardDisplay.

Comments should explain most of it.

If it's not clear/you didn't know, to broadcast a message, use
MESSAGEMAN:Broadcast("messageName")
and to send params, pass in a table as the second parameter
MESSAGEMAN:Broadcast("messageName",{ Param1 = "a", Param2 = true })

Code:
--[[
a custom MemoryCardDisplay | AJ @ KKI Labs

The basic idea is by capturing the messages sent about memory cards, as
well as being able to query the memory card state, one can make a custom
MemoryCardDisplay that isn't limited to being a Sprite.

I have included some example code that I would use if I were to flesh this
out fully. It is commented out since you may wish to implement
things differently. Feel free to use this. Interesting things await.
]]
local Player = ...;
assert(Player)

local MemCardDisplay = Def.ActorFrame{};
--[[ begin heavy lifting code ]]
-- parts list:
-- (1) list of states
local cardStates = {
	'MemoryCardState_ready',
	'MemoryCardState_checking',
	'MemoryCardState_late',
	'MemoryCardState_error',
	'MemoryCardState_removed',
	'MemoryCardState_none'
};
-- (1) knowledge of MEMCARDMAN:GetCardState(Player);
-- (2) knowledge of messages
-- 		Message_StorageDevicesChanged
--		(MessageID)(Message_CardRemovedP 1+p); // so 1 or 2

-- the gameplan
-- Message_StorageDevicesChanged is our reset function. It may as well be
-- 		treated as the init function as well, for safety. Might get lucky.

local lastSeenState = 'MemoryCardState_Invalid';

MemCardDisplay[#MemCardDisplay+1] = Def.Actor{
	Name="Controller";
	UpdateCommand=function(self)
		local newMcs = MEMCARDMAN:GetCardState(Player);
		if lastSeenState ~= newMcs then
			-- if you have a generic command you want to do when the state
			-- is changed, place it here.

			-- specific instances are checked below:
			--[[
			for i=1,#cardStates do
				if newMcs == cardStates[i] then
					-- swap states here.
					-- if this were me, it'd be:
					--MESSAGEMAN:Broadcast("CardStateOn",{ State = newMcs });
				end;
				-- this part is optional but recommended if using my method.
				if lastSeenState == cardStates[i] then
					--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
				end;
			end
			]]

			-- StepMania's MemoryCardDisplay just sets the visible values
			-- of the different sprites.

			-- if this were completely implemented by me, I would broadcast
			-- a message with two parameters, on and off. Ideally, these would
			-- be the names of the Actors/ActorFrames/whatever, and they would
			-- have two MessageCommands:
			-- CardStateOnMessageCommand({State})	-- called when CardState is turned on
			-- CardStateOffMessageCommand({State})	-- called when CardState is turned off

			-- and finally update the lastSeenState.
			lastSeenState = newMcs;
		end;
	end;
	StorageDevicesChangedMessageCommand=function(self)
		-- init code
	end;
	CardRemovedP1MessageCommand=function(self)
		if Player == PLAYER_1 then
			-- cleanup, play animation
			--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
		end;
	end;
	CardRemovedP2MessageCommand=function(self)
		if Player == PLAYER_2 then
			-- cleanup, play animation
			--MESSAGEMAN:Broadcast("CardStateOff",{ State = newMcs });
		end;
	end;
};
--[[ end heavy lifting code ]]
return MemCardDisplay;
If you decide to go down the path I did when implementing this, you just basically add CardStateOnMessageCommand/CardStateOffMessageCommand to an ActorFrame containing your objects for the state. My implementation would include an ActorFrame per state to separate everything out. Perhaps you could even put them in their own Lua files and just pull them in with a LoadActor.
__________________
Event mode exists for a reason. Use it.

We're doing it for fun, we're doing it because we can, we're doing it because we're SSC.
Follow @kki_ssc on Twitter for KKI Labs/spinal shark collective news as it breaks!
AJ 187 is offline   Reply With Quote
Old 05-17-2009, 10:06 AM   #2
FSX
Member
 
Join Date: Nov 2006
Posts: 2,045
FSX is a 4 bar user
Reputation: 33

Post rating: Votes: 0 Score: 0rate    
Default

This is pretty cool!
__________________
BAAAAAAAAAAAAAAAAAAAAAAWWWWWWWW
FSX is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom user name akstylish Chit-chat 22 02-11-2009 02:15 PM
Custom mods Reiser Theme/Noteskin Help/Questions/Requests 6 08-09-2008 12:53 AM
Custom I/O-module henke37 StepMania Wish list 0 07-06-2007 12:41 PM
CUSTOM SONGS jeffrey1790 General questions 3 05-30-2007 01:39 AM
End of custom song... StepmaniaFreak Song and Course questions 1 05-28-2007 05:00 AM


All times are GMT. The time now is 12:55 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Translate

Thanks to

SourceForge.net Logo