TouchSpecial won't add to in-game currency

Status
Not open for further replies.

SSG3

Oh, THAT Youtuber...
the in-game currency/shop mod i'm making... well, isn't working as planned... i've got this TouchSpecial for most collectible items (excluding monitors) that is supposed to add to the in-game currency. here is the full extract in case i made a mistake/typo:

Code:
//Sorry, you can't get money from ring monitors or extra lives, but still, it's nice to have something different.

addHook("ThinkFrame", do
for player in players.iterate
	if player.pounds == nil
		player.pounds = 1
	end
	if player.pence == nil
		player.pence = 0
	end
	if player.hammeramount == nil
		player.hammeramount = 0
	end
	if player.goldtimer == nil
		player.goldtimer = 0
	end
	if player.goldon == nil
		player.goldon = 0
	end
	if (player.pence >= 100)
		player.pounds = $1 + 1
		player.pence = ($1 - 100)
	end
	if player.flashtics == nil
		player.flashtics = 0
	end
	if (player.flashtics >= 3)
		player.flashtics = 1
	end
if player.mo and not player.spectator
and not G_RingSlingerGametype()
	if player.goldon == 1
		if player.flashtics == 1
			player.mo.color = SKINCOLOR_WHITE
		elseif player.flashtics == 2
			player.mo.color = player.skincolor
		end
		player.jumpfactor = skins[player.mo.skin].jumpfactor + skins[player.mo.skin].jumpfactor/5
		player.normalspeed = skins[player.mo.skin].normalspeed + skins[player.mo.skin].normalspeed/3
		player.acceleration = skins[player.mo.skin].acceleration + skins[player.mo.skin].acceleration/2
		player.actionspd = skins[player.mo.skin].actionspd + skins[player.mo.skin].actionspd/4
		player.powers[pw_spacetime] = 0
		player.powers[pw_underwater] = 0
	end
	if (player.goldtimer > 0)
		player.goldtimer = $1 - 1
	end
	if player.goldtimer == 0
	and player.goldon == 1
		player.goldon = 0
		P_RestoreMusic(player)
		player.jumpfactor = skins[player.mo.skin].jumpfactor
		player.normalspeed = skins[player.mo.skin].normalspeed
		player.acceleration = skins[player.mo.skin].acceleration
		player.flashtics = 0
		player.mo.color = player.skincolor
	end
	if player.goldon == 1
		player.flashtics = $1 + 1
	end
end
end
end)

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 10
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_RING")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 10
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_FLINGRING")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 1
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_COIN")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 1
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_FLINGCOIN")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 2
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_BLUEBALL")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 100
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMMY")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD1")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD2")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD3")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD4")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD5")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD6")

addHook("TouchSpecial", function(special, toucher)
	local player = toucher.player
	player.pence = $1 + 50
	S_StartSound(player.mo, special.info.deathsound)
end, "MT_EMERALD7")

//now to draw the HUD to show how much money you have

hud.add(function(v, player)
	v.drawString(160, 10, "Pounds: "..player.pounds.." Pence: "..player.pence, V_MONOSPACE, "left")
end, "game")

//the command for shop now, to buy stuff with the cash you have. no credit cards, just your lousy pocket money.

local function shop(player, arg1, arg2)
	if arg1 == nil
		CONS_Printf(player, "\"Shop <Buy/Sell> <item>\": Buy or sell items. what there is will be sown on your HUD screen in-game.")
	elseif arg1 == "buy"
		if arg2 == nil
			CONS_Printf(player, "Please specify an item you want to buy, e.g. shop buy golden_hammer to buy a Golden Hammer.")
		elseif arg2 == "golden_hammer"
			if player.pence < 25
				if player.pounds > 0
					player.pounds = $1 - 1
					player.pence = $1 + (100 - 25)
					player.hammeramount = $1 + 1
					CONS_Printf(player, "You have successfully purchased a Golden Hammer. Have a nice day, and we hope you shop with the shop.wad interface again!")
				else
					CONS_Printf(player, "You don't have sufficient funds to purchase this item.")
				end
			else
				player.pence = $1 - 25
				player.hammeramount = $1 + 1
				CONS_Printf(player, "You have successfully purchased a Golden Hammer. Have a nice day, and we hope you shop with the shop.wad interface again!")
			end
		end
	elseif arg1 == "sell"
			if arg2 == nil
				CONS_Printf(player, "Pleace specify an item you want to sell, e.g. \"shop sell golden_hammer\" to sell a Golden Hammer.")
			elseif arg2 == "golden_hammer"
				if player.hammeramount > 0
					player.pence = $1 + 25
					CONS_Printf(player, "Sold Golden Hammer for 25p. Thanks, and have a nice day")
					player.hammeramount = $1 - 1
				else
					CONS_Printf(player, "No Golden Hammer to sell!")
				end
			end
		end
	end

COM_AddCommand("shop", shop)

//Phew, some command that was. More will be added in the future, but for now, to code the Golden Hammer's Effects (sorrry, no hammer, but it powers you up in non-ringslinger gametypes (coop, race, comp, custom if applicable, or if you simply turned it off)
//These effects lasts 5 minutes, and flash you when in effect, changes your music when you use it, and can't be used when super.... so, here i go on coding this shit

local function itemuse(player, arg1)
	if arg1 == nil
		CONS_Printf(player, "\"Use <item>\": Use an item if you have one. As this is the inital release, only Golden Hammer (golden_hammer) is available, but feel free to add your own items!")
	elseif arg1 == "golden_hammer"
	and not (player.powers[pw_super])
	and (player.hammeramount > 0)
		local music = P_RandomRange(1, 2)
		if music == 1
			S_ChangeMusic(mus_map58m, true, player)
		elseif music == 2
			S_ChangeMusic(mus_map59m, true, player)
		end
		player.goldtimer = (60*TICRATE)*5
		player.goldon = 1
		player.hammeramount = $1 - 1
	end
end

COM_AddCommand("use", itemuse)

EDIT: its fixed. disregard this thread.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top