31. marts 2011 - 21:52
#2
Jeg kan ligge 3 eksempler ind, men det er ret meget kode - håber ikke det tager livet af dig blot at kigge på.
Eksemplerne er de koder jeg forventer der er fejl i - eftersom det er de eneste nye koder.
Eksempel 1:
set farm = Conn.execute("SELECT * FROM farmpladser WHERE verden=1")
if farm.eof or farm.bof then
else
PaladsValue = farm("palads")
ColosseumValue = farm("colosseum")
VaabensmedValue = farm("vaabensmed")
StaldValue = farm("stald")
ForsamlingspladsValue = farm("forsamlingsplads")
HandelspladsValue = farm("handelsplads")
MineValue = farm("miner")
GemmestedValue = farm("gemmested")
BymurValue = farm("bymur")
TempelValue = farm("tempel")
PaladsValue2 = TheCity("palads")
ColosseumValue2 = TheCity("colosseum")
VaabensmedValue2 = TheCity("vaabensmed")
StaldValue2 = TheCity("stald")
ForsamlingspladsValue2 = TheCity("forsamlingsplads")
HandelspladsValue2 = TheCity("handelsplads")
Skovhugger2 = TheCity("skovhugger")
Stenmine2 = TheCity("stenmine")
Jernmine2 = TheCity("jernmine")
Landejendom2 = TheCity("landejendom")
Raastoflager2 = TheCity("raastoflager")
GemmestedValue2 = TheCity("gemmested")
BymurValue2 = TheCity("bymur")
TempelValue2 = TheCity("tempel")
PaladsAryWords = Split(PaladsValue, ",")
ColosseumAryWords = Split(ColosseumValue, ",")
VaabensmedAryWords = Split(VaabensmedValue, ",")
StaldAryWords = Split(StaldValue, ",")
ForsamlingspladsAryWords = Split(ForsamlingspladsValue, ",")
HandelspladsAryWords = Split(HandelspladsValue, ",")
MineAryWords = Split(MineValue, ",")
GemmestedAryWords = Split(GemmestedValue, ",")
BymurAryWords = Split(BymurValue, ",")
TempelAryWords = Split(TempelValue, ",")
PaladsFarm = PaladsAryWords(PaladsValue2)
ColosseumFarm = ColosseumAryWords(ColosseumValue2)
VaabensmedFarm = VaabensmedAryWords(VaabensmedValue2)
StaldFarm = StaldAryWords(StaldValue2)
ForsamlingspladsFarm = ForsamlingspladsAryWords(ForsamlingspladsValue2)
HandelspladsFarm = HandelspladsAryWords(HandelspladsValue2)
SkovhuggerFarm = MineAryWords(Skovhugger2)
StenmineFarm = MineAryWords(Stenmine2)
JernmineFarm = MineAryWords(Jernmine2)
GemmestedFarm = GemmestedAryWords(GemmestedValue2)
BymurFarm = BymurAryWords(BymurValue2)
TempelFarm = TempelAryWords(TempelValue2)
TroppeFarm = int(TheCity("gladiuskrigere")) + int(TheCity("spydkastere")) + int((int(TheCity("gladiatorer")) * 5)) + int(TheCity("auxilaris")) + int((int(TheCity("praest")) * 150)) + int((int(TheCity("ballista")) * 7)) + int((int(TheCity("spioner")) * 2)) + int((int(TheCity("rambukke")) * 4)) + int((int(TheCity("kavalerister")) * 5)) + int(TheCity("berserker"))
end if
Eksempel 2: ( det kan godt ligne en mærkelig kode - men den er lavet til, at beregne råstoffer i et browserspil ;) )
<script language=javascript runat=server>
var dt = new Date();
var ms = dt.getMilliseconds();
</script>
<%
' Opstil de oplysninger der skal bruges til Træ-Råstof
WoodPrHour = TheCity("traetime")
SecondsToWoodResult = 3600 / WoodPrHour
SecondsToWood = int(SecondsToWoodResult)
MSToWood = SecondsToWoodResult-SecondsToWood
TraeTid = TheCity("traetid")
TraeMS = TheCity("traems")
NowTid = now()
NowMS = ms
' Beregning af millisekunder-Træ og sekunder-Træ
TraeForskelSeconds = datediff("s", TraeTid,NowTid)
TraeForskelMS = NowMS - TraeMS
if TraeForskelMS < 0 then
TraeForskelSeconds = TraeForskelSeconds + 1
TraeForskelMS = TraeForskelMS + 1000
end if
' Beregning til hvor mange stykker træ byen skal have!
TraeBeregningMS = TraeForskelMS - MSToWood
if TraeBeregningMS < 0 then
SecondsToWood = SecondsToWood + 1
TraeBeregningMS = TraeBeregningMS + 1000
end if
AntalTrae = TraeForskelSeconds / SecondsToWood
AntalTrae = int(AntalTrae)
if AntalTrae >= 1 then
TraeForskelSeconds = datediff("s", TraeTid,NowTid)
TraeForskelMS = NowMS - (TraeMS * AntalTrae)
do while TraeForskelMS < 0
TraeForskelSeconds = TraeForskelSeconds + 1
TraeForskelMS = TraeForskelMS + 1000
loop
TraeBeregningMS = TraeForskelMS - (MSToWood * AntalTrae)
AntalSeconds = 0
do while TraeBeregningMS < 0
AntalSeconds = AntalSeconds + 1
SecondsToWood = SecondsToWood + 1
TraeBeregningMS = TraeBeregningMS + 1000
loop
SecondsToTheWoodResult = 3600 / WoodPrHour
SecondsToTheWood = int(SecondsToTheWoodResult)
MSToTheWood = SecondsToTheWoodResult-SecondsToTheWood
TidNy = SecondsToTheWood * AntalTrae
t = dateadd("s", TidNy,TraeTid)
TraeTiden = Year(t) & "-" & Right("0" & Month(t),2) & "-" & Right("0" & Day(t),2) & " " & Right("0" & Hour(t),2) & ":" & Right("0" & Minute(t),2) & ":" & Right("0" & Second(t),2)
MSTraeNY = (MSToTheWood * AntalTrae)-AntalSeconds
TraeEt = int(TheCity("trae")) + int(AntalTrae)
Resultat = TraeEt - TheCity("lager")
if Resultat > 0 then
TraeEt = TheCity("lager")
end if
else
t = TheCity("traetid")
TraeTiden = Year(t) & "-" & Right("0" & Month(t),2) & "-" & Right("0" & Day(t),2) & " " & Right("0" & Hour(t),2) & ":" & Right("0" & Minute(t),2) & ":" & Right("0" & Second(t),2)
MSTraeNY = TheCity("traems")
TraeEt = TheCity("trae")
end if
%>
Eksempel 3:
<!-- Opdater/Check om pointene matcher bygninger i byen -->
<%
set point = Conn.execute("SELECT * FROM pointtabel WHERE verden=1")
if point.eof or point.bof then
else
PaladsPoint = "0,45,54,63,72,81,90,99,108,117,126,135,144,153,162,171,180,189,198,207,216,225,234,243,252,261,270,279,288,297,306,315,324,333,342,351"
SplitPalads = split(PaladsPoint, ",")
pointpalads = SplitPalads(PaladsValue2)
ColosseumPoint = "0,24,30,33,39,42,48,54,57,63,66,72,78,81,87,90,96,102,105,111,114,120,126,129,135,138,144,150,153,159,162,168,174,177,183,186,192,198,201,207,210"
SplitColosseum = split(ColosseumPoint, ",")
pointcolosseum = SplitColosseum(ColosseumValue2)
VaabensmedPoint = "0,60,72,84,96,108,120,132,144,156,168,180,192,204,216,228,240,252,264,276,288,300,312,324,336,348,360,372,384,396,408"
SplitVaabensmed = split(VaabensmedPoint, ",")
pointvaabensmed = SplitVaabensmed(VaabensmedValue2)
StaldPoint = "0,75,90,105,120,135,150,165,180,195,210,225,240,255,270,285,300,315,330,345,360,375,390,405,420,435"
SplitStald = split(StaldPoint, ",")
pointstald = SplitStald(StaldValue2)
HandelspladsPoint = "0,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87"
SplitHandelsplads = split(HandelspladsPoint, ",")
pointhandelsplads = SplitHandelsplads(HandelspladsValue2)
ForsamlingspladsPoint = "0,18,256"
SplitForsamlingsplads = split(ForsamlingspladsPoint, ",")
pointforsamlingsplads = SplitForsamlingsplads(ForsamlingspladsValue2)
TempelPoint = "0,400"
SplitTempel = split(TempelPoint, ",")
pointtempel = SplitTempel(TempelValue2)
SkovhuggerPoint = "0,12,15,18,18,21,24,27,30,30,33,36,39,42,42,45,48,51,54,54,57,60,63,66,66,69,72,75,78,78,81,84,87,90,90,93"
SplitSkovhugger = split(SkovhuggerPoint, ",")
pointskovhugger = SplitSkovhugger(Skovhugger2)
StenminePoint = "0,12,15,18,18,21,24,27,30,30,33,36,39,42,42,45,48,51,54,54,57,60,63,66,66,69,72,75,78,78,81,84,87,90,90,93"
SplitStenmine = split(StenminePoint, ",")
pointstenmine = SplitStenmine(Stenmine2)
JernminePoint = "0,12,15,18,18,21,24,27,30,30,33,36,39,42,42,45,48,51,54,54,57,60,63,66,66,69,72,75,78,78,81,84,87,90,90,93"
SplitJernmine = split(JernminePoint, ",")
pointjernmine = SplitJernmine(Jernmine2)
LandejendomPoint = "0,18,21,24,30,33,36,39,42,48,51,54,57,60,66,69,72,75,78,84,87,90,93,96,102,105,108,111,114,120,123"
SplitLandejendom = split(LandejendomPoint, ",")
pointlandejendom = SplitLandejendom(Landejendom2)
RaastoflagerPoint = "0,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87"
SplitRaastoflager = split(RaastoflagerPoint, ",")
pointraastoflager = SplitRaastoflager(Raastoflager2)
GemmestedPoint = "0,9,12,12,15,15,18,21,21,24,24,27,30,30,33,33"
SplitGemmested = split(GemmestedPoint, ",")
pointgemmested = SplitGemmested(GemmestedValue2)
BymurPoint = "0,30,36,42,48,54,60,66,72,78,84,90,96,102,108,114,120,126,132,138,144,150,156,162,168,174"
SplitBymur = split(BymurPoint, ",")
pointbymur = SplitBymur(BymurValue2)
end if
%>
<%
totalpoint = int(pointpalads) + int(pointcolosseum) + int(pointvaabensmed) + int(pointstald) + int(pointhandelsplads) + int(pointskovhugger) + int(pointstenmine) + int(pointjernmine) + int(pointraastoflager) + int(pointgemmested) + int(pointbymur) + int(pointlandejendom) + int(pointforsamlingsplads) + int(pointtempel)
%>
<%
set bygnings = Conn.execute("SELECT * FROM bygninger WHERE verden=1")
if bygnings.eof or bygnings.bof then
else
' Så meget skjuler Gemmestedet!
GemmestedSplit = "0,100,150,200,250,300,375,450,525,600,800,1000,1200,1400,1600,2000"
SplitGemmested = split(GemmestedSplit, ",")
hiding = SplitGemmested(GemmestedValue2)
' Så meget træ!
SkovhuggerSplit = "24,36,42,48,54,66,72,84,96,108,126,144,168,186,216,252,288,330,378,432,498,576,660,756,870,1002,1152,1326,1524,1752,2016,2316,2664,3066,3522,4200 "
SplitSkovhugger = split(SkovhuggerSplit, ",")
traetime = SplitSkovhugger(Skovhugger2)
' Så meget sten!
StenmineSplit = "24,36,42,48,54,66,72,84,96,108,126,144,168,186,216,252,288,330,378,432,498,576,660,756,870,1002,1152,1326,1524,1752,2016,2316,2664,3066,3522,4200 "
SplitStenmine = split(StenmineSplit, ",")
stentime = SplitStenmine(Stenmine2)
' Så meget jern!
JernmineSplit = "24,36,42,48,54,66,72,84,96,108,126,144,168,186,216,252,288,330,378,432,498,576,660,756,870,1002,1152,1326,1524,1752,2016,2316,2664,3066,3522,4200 "
SplitJernmine = split(JernmineSplit, ",")
jerntime = SplitJernmine(Jernmine2)
' Så mange indbyggere!
LandejendomSplit = "150,250,288,331,380,437,503,578,665,778,910,1065,1246,1458,1735,2065,2457,2924,3479,4140,4957,5863,6977,8303,9880,11758,13992,16650,19813,24464,30000 "
SplitLandejendom = split(LandejendomSplit, ",")
maxindbygger = SplitLandejendom(Landejendom2)
' Så meget lagerplads!
RaastoflagerSplit = "400,800,960,1152,1382,1659,1991,2488,3110,3888,4860,6075,7594,9492,12340,16042,20854,27111,35244,45817,61853,83501,112727,163454,245181,350000 "
SplitRaastoflager = split(RaastoflagerSplit, ",")
lagercap = SplitRaastoflager(Raastoflager2)
' Så meget bymurs beskyttelse!
BymurSplit = "0,5,9,14,17,22,26,31,38,44,49,54,60,65,71,75,79,83,86,90,93,93,102,107,110,115 "
SplitBymur = split(BymurSplit, ",")
citysafe = SplitBymur(BymurValue2)
end if
%>
Efter dette er der Update-strings ala:
if TheCity("lager") <> lagercap then
UpdateCityInfos12 = Conn.execute("UPDATE byinfo SET lager='"& lagercap &"' WHERE id='"& TheCity("id") &"'")
end if
- Jeg sagde fra starten, at jeg havde skrevet alle sammen. Men da det gik langsomt allerede der - var ét af mine forsøg, at skrive allesammen hver for sig igen. Derfor ser updaten sådan ud.
Nu håber jeg ikke du er druknet.. De mindste spørgsmål - stil dem endelig :)
SW